Skip to content

Commit e8f803b

Browse files
committed
Merge branch 'fix-regression' of https://github.com/dsyme/visualfsharp into dsyme-fix-regression
2 parents 89a25de + 0cdd740 commit e8f803b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+370
-683
lines changed

src/absil/il.fsi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ type PublicKey =
118118
member IsKeyToken: bool
119119
member Key: byte[]
120120
member KeyToken: byte[]
121+
static member KeyAsToken: byte[] -> PublicKey
121122

122123
type ILVersionInfo = uint16 * uint16 * uint16 * uint16
123124

src/absil/illib.fs

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ module Eventually =
620620

621621
let force e = Option.get (forceWhile (fun () -> true) e)
622622

623-
/// Keep running the computation bit by bit until a time limit is reached.
623+
/// Keep running the computation bit by bit until a time limit is reached.
624624
/// The runner gets called each time the computation is restarted
625625
let repeatedlyProgressUntilDoneOrTimeShareOver timeShareInMilliseconds runner e =
626626
let sw = new System.Diagnostics.Stopwatch()
@@ -942,64 +942,66 @@ type LayeredMultiMap<'Key,'Value when 'Key : equality and 'Key : comparison>(con
942942
module Shim =
943943

944944
open System.IO
945-
[<AbstractClass>]
946-
type FileSystem() =
947-
abstract ReadAllBytesShim: fileName:string -> byte[]
948-
default this.ReadAllBytesShim (fileName:string) =
949-
use stream = this.FileStreamReadShim fileName
950-
let len = stream.Length
951-
let buf = Array.zeroCreate<byte> (int len)
952-
stream.Read(buf, 0, (int len)) |> ignore
953-
buf
954945

946+
type IFileSystem =
947+
abstract ReadAllBytesShim: fileName:string -> byte[]
955948
abstract FileStreamReadShim: fileName:string -> System.IO.Stream
956949
abstract FileStreamCreateShim: fileName:string -> System.IO.Stream
957-
abstract GetFullPathShim: fileName:string -> string
950+
abstract FileStreamWriteExistingShim: fileName:string -> System.IO.Stream
958951
/// Take in a filename with an absolute path, and return the same filename
959952
/// but canonicalized with respect to extra path separators (e.g. C:\\\\foo.txt)
960953
/// and '..' portions
961-
abstract SafeGetFullPath: fileName:string -> string
954+
abstract GetFullPathShim: fileName:string -> string
962955
abstract IsPathRootedShim: path:string -> bool
963-
964-
abstract IsInvalidFilename: filename:string -> bool
956+
abstract IsInvalidPathShim: filename:string -> bool
965957
abstract GetTempPathShim : unit -> string
966958
abstract GetLastWriteTimeShim: fileName:string -> System.DateTime
967959
abstract SafeExists: fileName:string -> bool
968960
abstract FileDelete: fileName:string -> unit
969961
abstract AssemblyLoadFrom: fileName:string -> System.Reflection.Assembly
970962
abstract AssemblyLoad: assemblyName:System.Reflection.AssemblyName -> System.Reflection.Assembly
971963

972-
default this.AssemblyLoadFrom(fileName:string) =
973-
#if FX_ATLEAST_40_COMPILER_LOCATION
974-
System.Reflection.Assembly.UnsafeLoadFrom fileName
975-
#else
976-
System.Reflection.Assembly.LoadFrom fileName
977-
#endif
978-
default this.AssemblyLoad(assemblyName:System.Reflection.AssemblyName) = System.Reflection.Assembly.Load assemblyName
979-
980-
981-
let mutable FileSystem =
982-
{ new FileSystem() with
983-
override __.ReadAllBytesShim (fileName:string) = File.ReadAllBytes fileName
964+
type DefaultFileSystem() =
965+
interface IFileSystem with
966+
member __.AssemblyLoadFrom(fileName:string) =
967+
#if FX_ATLEAST_40_COMPILER_LOCATION
968+
System.Reflection.Assembly.UnsafeLoadFrom fileName
969+
#else
970+
System.Reflection.Assembly.LoadFrom fileName
971+
#endif
972+
member __.AssemblyLoad(assemblyName:System.Reflection.AssemblyName) = System.Reflection.Assembly.Load assemblyName
973+
974+
member __.ReadAllBytesShim (fileName:string) = File.ReadAllBytes fileName
984975
member __.FileStreamReadShim (fileName:string) = new FileStream(fileName,FileMode.Open,FileAccess.Read,FileShare.ReadWrite) :> Stream
985976
member __.FileStreamCreateShim (fileName:string) = new FileStream(fileName,FileMode.Create,FileAccess.Write,FileShare.Read ,0x1000,false) :> Stream
977+
member __.FileStreamWriteExistingShim (fileName:string) = new FileStream(fileName,FileMode.Open,FileAccess.Write,FileShare.Read ,0x1000,false) :> Stream
986978
member __.GetFullPathShim (fileName:string) = System.IO.Path.GetFullPath fileName
987-
member __.SafeGetFullPath (fileName:string) =
988-
//System.Diagnostics.Debug.Assert(Path.IsPathRooted(fileName), sprintf "SafeGetFullPath: '%s' is not absolute" fileName)
989-
Path.GetFullPath fileName
990979

991980
member __.IsPathRootedShim (path:string) = Path.IsPathRooted path
992981

993-
member __.IsInvalidFilename(filename:string) =
994-
String.IsNullOrEmpty(filename) || filename.IndexOfAny(Path.GetInvalidFileNameChars()) <> -1
982+
member __.IsInvalidPathShim(path:string) =
983+
let isInvalidPath(p:string) =
984+
String.IsNullOrEmpty(p) || p.IndexOfAny(System.IO.Path.GetInvalidPathChars()) <> -1
985+
986+
let isInvalidFilename(p:string) =
987+
String.IsNullOrEmpty(p) || p.IndexOfAny(System.IO.Path.GetInvalidFileNameChars()) <> -1
988+
989+
let isInvalidDirectory(d:string) =
990+
d=null || d.IndexOfAny(Path.GetInvalidPathChars()) <> -1
991+
992+
isInvalidPath (path) ||
993+
let directory = Path.GetDirectoryName(path)
994+
let filename = Path.GetFileName(path)
995+
isInvalidDirectory(directory) || isInvalidFilename(filename)
995996

996997
member __.GetTempPathShim() = System.IO.Path.GetTempPath()
997998

998999
member __.GetLastWriteTimeShim (fileName:string) = File.GetLastWriteTime fileName
9991000
member __.SafeExists (fileName:string) = System.IO.File.Exists fileName
1000-
member __.FileDelete (fileName:string) = System.IO.File.Delete fileName }
1001+
member __.FileDelete (fileName:string) = System.IO.File.Delete fileName
10011002

10021003
type System.Text.Encoding with
10031004
static member GetEncodingShim(n:int) =
10041005
System.Text.Encoding.GetEncoding(n)
10051006

1007+
let mutable FileSystem = DefaultFileSystem() :> IFileSystem

src/absil/ilsupp.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -676,10 +676,10 @@ let linkNativeResources (unlinkedResources:byte[] list) (ulLinkedResourceBaseRV
676676
// Conversion was successful, so read the object file
677677
objBytes <- FileSystem.ReadAllBytesShim(tempObjFileName) ;
678678
//Array.Copy(objBytes, pbUnlinkedResource, pbUnlinkedResource.Length)
679-
System.IO.File.Delete(tempObjFileName)
679+
FileSystem.FileDelete(tempObjFileName)
680680
finally
681681
// clean up the temp files
682-
List.iter (fun tempResFileName -> System.IO.File.Delete(tempResFileName)) tempResFiles
682+
List.iter (fun tempResFileName -> FileSystem.FileDelete(tempResFileName)) tempResFiles
683683

684684
// Part 2: Read the COFF file held in pbUnlinkedResource, spit it out into pResBuffer and apply the COFF fixups
685685
// pResBuffer will become the .rsrc section of the PE file
@@ -1090,7 +1090,7 @@ let hashSizeOfMD5 = 16
10901090
// In this case, catch the failure, and not set a checksum.
10911091
let internal setCheckSum (url:string, writer:ISymUnmanagedDocumentWriter) =
10921092
try
1093-
use file = new FileStream(url, FileMode.Open, FileAccess.Read, FileShare.Read)
1093+
use file = FileSystem.FileStreamReadShim(url)
10941094
use md5 = System.Security.Cryptography.MD5.Create()
10951095
let checkSum = md5.ComputeHash(file)
10961096
if (checkSum.Length = hashSizeOfMD5) then

src/absil/ilwrite.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4496,7 +4496,7 @@ let writeBinaryAndReportMappings (outfile, ilg, pdbfile: string option, signer:
44964496
reportTime showTimes "Generate PDB Info"
44974497

44984498
// Now we have the debug data we can go back and fill in the debug directory in the image
4499-
let fs2 = new FileStream(outfile, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read, 0x1000, false)
4499+
let fs2 = FileSystem.FileStreamWriteExistingShim(outfile)
45004500
let os2 = new BinaryWriter(fs2)
45014501
try
45024502
// write the IMAGE_DEBUG_DIRECTORY

src/fsharp/CompileOps.fs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ open Microsoft.FSharp.Compiler.MSBuildResolver
4040
open Microsoft.FSharp.Compiler.TypeRelations
4141
open Microsoft.FSharp.Compiler.NameResolution
4242
open Microsoft.FSharp.Compiler.PrettyNaming
43-
open Internal.Utilities.FileSystem
4443
open Internal.Utilities.Collections
4544
open Internal.Utilities.Filename
4645
open Microsoft.FSharp.Compiler.Import
@@ -1353,7 +1352,7 @@ let SanitizeFileName fileName implicitIncludeDir =
13531352
// - if you have a #line directive, e.g.
13541353
// # 1000 "Line01.fs"
13551354
// then it also asserts. But these are edge cases that can be fixed later, e.g. in bug 4651.
1356-
//System.Diagnostics.Debug.Assert(System.IO.Path.IsPathRooted(fileName), sprintf "filename should be absolute: '%s'" fileName)
1355+
//System.Diagnostics.Debug.Assert(FileSystem.IsPathRootedShim(fileName), sprintf "filename should be absolute: '%s'" fileName)
13571356
try
13581357
let fullPath = FileSystem.GetFullPathShim(fileName)
13591358
let currentDir = implicitIncludeDir
@@ -2220,7 +2219,7 @@ type TcConfigBuilder =
22202219
tcConfigB.includes <- tcConfigB.includes ++ absolutePath
22212220

22222221
member tcConfigB.AddLoadedSource(m,path,pathLoadedFrom) =
2223-
if Path.IsInvalidPath(path) then
2222+
if FileSystem.IsInvalidPathShim(path) then
22242223
warning(Error(FSComp.SR.buildInvalidFilename(path),m))
22252224
else
22262225
let path =
@@ -2237,7 +2236,7 @@ type TcConfigBuilder =
22372236
tcConfigB.embedResources <- tcConfigB.embedResources ++ filename
22382237

22392238
member tcConfigB.AddReferencedAssemblyByPath (m,path) =
2240-
if Path.IsInvalidPath(path) then
2239+
if FileSystem.IsInvalidPathShim(path) then
22412240
warning(Error(FSComp.SR.buildInvalidAssemblyName(path),m))
22422241
elif not (List.mem (AssemblyReference(m,path)) tcConfigB.referencedDLLs) then // NOTE: We keep same paths if range is different.
22432242
tcConfigB.referencedDLLs <- tcConfigB.referencedDLLs ++ AssemblyReference(m,path)
@@ -2614,16 +2613,8 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
26142613
| Some x ->
26152614
[tcConfig.MakePathAbsolute x]
26162615
| None ->
2617-
// When running on Mono we lead everyone to believe we're doing .NET 2.0 compilation
2618-
// by default.
26192616
if runningOnMono then
2620-
let mono10SysDir = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
2621-
assert(mono10SysDir.EndsWith("1.0",StringComparison.Ordinal));
2622-
let mono20SysDir = Path.Combine(Path.GetDirectoryName mono10SysDir, "2.0")
2623-
if Directory.Exists(mono20SysDir) then
2624-
[mono20SysDir]
2625-
else
2626-
[mono10SysDir]
2617+
[System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()]
26272618
else
26282619
try
26292620
match tcConfig.resolutionEnvironment with
@@ -3838,7 +3829,7 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
38383829
outputFile = tcConfig.outputFile
38393830
showResolutionMessages = tcConfig.showExtensionTypeMessages
38403831
referencedAssemblies = [| for r in resolutions.GetAssemblyResolutions() -> r.resolvedPath |]
3841-
temporaryFolder = Path.GetTempPath() }
3832+
temporaryFolder = FileSystem.GetTempPathShim() }
38423833

38433834
// The type provider should not hold strong references to disposed
38443835
// TcImport objects. So the callbacks provided in the type provider config
@@ -4637,7 +4628,7 @@ module private ScriptPreprocessClosure =
46374628

46384629
let SourceFileOfFilename(filename,m,inputCodePage:int option) : ClosureDirective list =
46394630
try
4640-
let filename = FileSystem.SafeGetFullPath(filename)
4631+
let filename = FileSystem.GetFullPathShim(filename)
46414632
use stream = FileSystem.FileStreamReadShim filename
46424633
use reader =
46434634
match inputCodePage with
@@ -4676,7 +4667,7 @@ module private ScriptPreprocessClosure =
46764667
match closureDirective with
46774668
| ClosedSourceFile _ as csf -> [csf]
46784669
| SourceFile(filename,m,source) ->
4679-
let filename = FileSystem.SafeGetFullPath(filename)
4670+
let filename = FileSystem.GetFullPathShim(filename)
46804671
if observedSources.HaveSeen(filename) then []
46814672
else
46824673
observedSources.SetSeen(filename)
@@ -4727,7 +4718,7 @@ module private ScriptPreprocessClosure =
47274718
for directive in closureDirectives do
47284719
match directive with
47294720
| ClosedSourceFile(filename,m,input,_,_,noWarns) ->
4730-
let filename = FileSystem.SafeGetFullPath(filename)
4721+
let filename = FileSystem.GetFullPathShim(filename)
47314722
sourceFiles := (filename,m) :: !sourceFiles
47324723
globalNoWarns := (!globalNoWarns @ noWarns)
47334724
sourceInputs := (filename,input) :: !sourceInputs

src/fsharp/CompileOps.fsi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ val IsOptimizationDataResource : ILResource -> bool
578578

579579
/// Determine if an IL resource attached to an F# assemnly is an F# quotation data resource for reflected definitions
580580
val IsReflectedDefinitionsResource : ILResource -> bool
581+
val GetSignatureDataResourceName : ILResource -> string
581582

582583
#if NO_COMPILER_BACKEND
583584
#else

src/fsharp/CompileOptions.fs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,12 +744,10 @@ let vsSpecificFlags (tcConfigB: TcConfigBuilder) =
744744

745745
let internalFlags (tcConfigB:TcConfigBuilder) =
746746
[
747-
CompilerOption("use-incremental-build", tagNone, OptionUnit (fun () -> tcConfigB.useIncrementalBuilder <- true), None, None)
748747
CompilerOption("stamps", tagNone, OptionUnit (fun () -> ()), Some(InternalCommandLineOption("--stamps", rangeCmdArgs)), None);
749748
CompilerOption("ranges", tagNone, OptionSet Tastops.DebugPrint.layoutRanges, Some(InternalCommandLineOption("--ranges", rangeCmdArgs)), None);
750749
CompilerOption("terms" , tagNone, OptionUnit (fun () -> tcConfigB.showTerms <- true), Some(InternalCommandLineOption("--terms", rangeCmdArgs)), None);
751750
CompilerOption("termsfile" , tagNone, OptionUnit (fun () -> tcConfigB.writeTermsToFiles <- true), Some(InternalCommandLineOption("--termsfile", rangeCmdArgs)), None);
752-
CompilerOption("use-incremental-build", tagNone, OptionUnit (fun () -> tcConfigB.useIncrementalBuilder <- true), None, None)
753751
#if DEBUG
754752
CompilerOption("debug-parse", tagNone, OptionUnit (fun () -> Internal.Utilities.Text.Parsing.Flags.debug <- true), Some(InternalCommandLineOption("--debug-parse", rangeCmdArgs)), None);
755753
CompilerOption("ilfiles", tagNone, OptionUnit (fun () -> tcConfigB.writeGeneratedILFiles <- true), Some(InternalCommandLineOption("--ilfiles", rangeCmdArgs)), None);

src/fsharp/CompileOptions.fsi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,4 @@ val DoWithErrorColor : bool -> (unit -> 'a) -> 'a
9898
val ReportTime : TcConfig -> string -> unit
9999
val GetAbbrevFlagSet : TcConfigBuilder -> bool -> Set<string>
100100
val PostProcessCompilerArgs : string Set -> string [] -> string list
101+
val ParseCompilerOptions : (string -> unit) * CompilerOptionBlock list * string list -> unit

src/fsharp/ConstraintSolver.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,7 +1872,7 @@ and CanMemberSigsMatchUpToCheck
18721872
let calledArgTy = rfinfo.FieldType
18731873
rfinfo.Name, calledArgTy
18741874

1875-
subsumeArg (CalledArg((-1, 0), false, NotOptional, false, Some name, ReflectedArgInfo.None, calledArgTy)) caller) )) ++ (fun () ->
1875+
subsumeArg (CalledArg((-1, 0), false, NotOptional, false, Some (mkSynId m name), ReflectedArgInfo.None, calledArgTy)) caller) )) ++ (fun () ->
18761876

18771877
// - Always take the return type into account for
18781878
// -- op_Explicit, op_Implicit
@@ -2004,7 +2004,7 @@ and ReportNoCandidatesError (csenv:ConstraintSolverEnv) (nUnnamedCallerArgs,nNam
20042004
let missingArgs = List.drop nReqd cmeth.AllUnnamedCalledArgs
20052005
match NamesOfCalledArgs missingArgs with
20062006
| [] -> (false, "")
2007-
| names -> (true, String.concat ";" names)
2007+
| names -> (true, String.concat ";" (List.map textOfId names))
20082008
else (false, "")
20092009

20102010
match suggestNamesForMissingArguments with

src/fsharp/ExtensionTyping.fs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Microsoft.FSharp.Compiler
66

7+
#if EXTENSIONTYPING
8+
79
module internal ExtensionTyping =
810
open System
911
open System.IO
@@ -15,7 +17,6 @@ module internal ExtensionTyping =
1517
open Microsoft.FSharp.Compiler.AbstractIL.IL
1618
open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics // dprintfn
1719
open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library // frontAndBack
18-
open Internal.Utilities.FileSystem
1920

2021
type TypeProviderDesignation = TypeProviderDesignation of string
2122

@@ -1218,3 +1219,4 @@ module internal ExtensionTyping =
12181219
let IsGeneratedTypeDirectReference (st: Tainted<ProvidedType>, m) =
12191220
st.PUntaint((fun st -> st.TryGetTyconRef() |> isNone), m)
12201221

1222+
#endif

0 commit comments

Comments
 (0)