@@ -2381,11 +2381,8 @@ type AssemblyResolution =
23812381 | Some aref -> aref
23822382 | None ->
23832383 let readerSettings : ILBinaryReader.ILReaderOptions = { pdbPath= None; ilGlobals = EcmaILGlobals; optimizeForMemory= false } // ??
2384- let reader = ILBinaryReader.OpenILModuleReaderAfterReadingAllBytes this.resolvedPath readerSettings
2385- try
2386- mkRefToILAssembly reader.ILModuleDef.ManifestOfAssembly
2387- finally
2388- ILBinaryReader.CloseILModuleReader reader
2384+ use reader = ILBinaryReader.OpenILModuleReaderAfterReadingAllBytes this.resolvedPath readerSettings
2385+ mkRefToILAssembly reader.ILModuleDef.ManifestOfAssembly
23892386 this.ilAssemblyRef := Some( assRef)
23902387 assRef
23912388
@@ -2469,21 +2466,17 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
24692466 let filename = ComputeMakePathAbsolute data.implicitIncludeDir primaryAssemblyFilename
24702467 try
24712468
2472- let ilReader = OpenILBinary( filename, data.optimizeForMemory, data.openBinariesInMemory, None, None, data.primaryAssembly.Name, data.noDebugData, data.shadowCopyReferences)
2473- try
2474- let ilModule = ilReader.ILModuleDef
2469+ use ilReader = OpenILBinary( filename, data.optimizeForMemory, data.openBinariesInMemory, None, None, data.primaryAssembly.Name, data.noDebugData, data.shadowCopyReferences)
2470+ let ilModule = ilReader.ILModuleDef
24752471
2476- match ilModule.ManifestOfAssembly.Version with
2477- | Some( v1, v2, v3,_) ->
2478- if v1 = 1 us then
2479- warning( Error( FSComp.SR.buildRequiresCLI2( filename), rangeStartup))
2480- let clrRoot = Some( Path.GetDirectoryName( FileSystem.GetFullPathShim( filename)))
2481-
2482- clrRoot, ( int v1, sprintf " v%d .%d " v1 v2), ( v1= 5 us && v2= 0 us && v3= 5 us) // SL5 mscorlib is 5.0.5.0
2483- | _ ->
2484- failwith ( FSComp.SR.buildCouldNotReadVersionInfoFromMscorlib())
2485- finally
2486- ILBinaryReader.CloseILModuleReader ilReader
2472+ match ilModule.ManifestOfAssembly.Version with
2473+ | Some( v1, v2, v3,_) ->
2474+ if v1 = 1 us then
2475+ warning( Error( FSComp.SR.buildRequiresCLI2( filename), rangeStartup))
2476+ let clrRoot = Some( Path.GetDirectoryName( FileSystem.GetFullPathShim( filename)))
2477+ clrRoot, ( int v1, sprintf " v%d .%d " v1 v2), ( v1= 5 us && v2= 0 us && v3= 5 us) // SL5 mscorlib is 5.0.5.0
2478+ | _ ->
2479+ failwith ( FSComp.SR.buildCouldNotReadVersionInfoFromMscorlib())
24872480 with _ ->
24882481 error( Error( FSComp.SR.buildCannotReadAssembly( filename), rangeStartup))
24892482 | _ ->
@@ -2531,13 +2524,10 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
25312524 | Some( fslibFilename) ->
25322525 let filename = ComputeMakePathAbsolute data.implicitIncludeDir fslibFilename
25332526 try
2534- let ilReader = OpenILBinary( filename, data.optimizeForMemory, data.openBinariesInMemory, None, None, data.primaryAssembly.Name, data.noDebugData, data.shadowCopyReferences)
2535- try
2536- checkFSharpBinaryCompatWithMscorlib filename ilReader.ILAssemblyRefs ilReader.ILModuleDef.ManifestOfAssembly.Version rangeStartup;
2537- let fslibRoot = Path.GetDirectoryName( FileSystem.GetFullPathShim( filename))
2538- fslibRoot (* , sprintf "v%d.%d" v1 v2 *)
2539- finally
2540- ILBinaryReader.CloseILModuleReader ilReader
2527+ use ilReader = OpenILBinary( filename, data.optimizeForMemory, data.openBinariesInMemory, None, None, data.primaryAssembly.Name, data.noDebugData, data.shadowCopyReferences)
2528+ checkFSharpBinaryCompatWithMscorlib filename ilReader.ILAssemblyRefs ilReader.ILModuleDef.ManifestOfAssembly.Version rangeStartup;
2529+ let fslibRoot = Path.GetDirectoryName( FileSystem.GetFullPathShim( filename))
2530+ fslibRoot (* , sprintf "v%d.%d" v1 v2 *)
25412531 with _ ->
25422532 error( Error( FSComp.SR.buildCannotReadAssembly( filename), rangeStartup))
25432533 | _ ->
@@ -2806,12 +2796,9 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
28062796 else
28072797 try
28082798 let readerSettings : ILBinaryReader.ILReaderOptions = { pdbPath= None; ilGlobals = EcmaILGlobals; optimizeForMemory= false }
2809- let reader = ILBinaryReader.OpenILModuleReaderAfterReadingAllBytes resolved readerSettings
2810- try
2811- let assRef = mkRefToILAssembly reader.ILModuleDef.ManifestOfAssembly
2812- assRef.QualifiedName
2813- finally
2814- ILBinaryReader.CloseILModuleReader reader
2799+ use reader = ILBinaryReader.OpenILModuleReaderAfterReadingAllBytes resolved readerSettings
2800+ let assRef = mkRefToILAssembly reader.ILModuleDef.ManifestOfAssembly
2801+ assRef.QualifiedName
28152802 with e ->
28162803 " "
28172804 Some
@@ -3851,7 +3838,7 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
38513838
38523839 let ilILBinaryReader = OpenILBinary( filename, tcConfig.optimizeForMemory, tcConfig.openBinariesInMemory, ilGlobalsOpt, pdbPathOption, tcConfig.primaryAssembly.Name, tcConfig.noDebugData, tcConfig.shadowCopyReferences)
38533840
3854- tcImports.AttachDisposeAction( fun _ -> ILBinaryReader.CloseILModuleReader ilILBinaryReader)
3841+ tcImports.AttachDisposeAction( fun _ -> ( ilILBinaryReader :> IDisposable ) .Dispose () )
38553842 ilILBinaryReader.ILModuleDef, ilILBinaryReader.ILAssemblyRefs
38563843 with e ->
38573844 error( Error( FSComp.SR.buildErrorOpeningBinaryFile( filename, e.Message), m))
0 commit comments