Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9e2f161

Browse files
authored
Merge pull request #3500 from dsyme/fix-refs1
add WPF path to fsi.exe and cleanup resolution flags
2 parents336600a +e2ea101 commit9e2f161

File tree

8 files changed

+85
-68
lines changed

8 files changed

+85
-68
lines changed

‎src/fsharp/CompileOps.fs‎

Lines changed: 62 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,7 +2213,7 @@ type TcConfigBuilder =
22132213
useFsiAuxLib=false
22142214
implicitOpens=[]
22152215
includes=[]
2216-
resolutionEnvironment=ReferenceResolver.CompileTimeLike
2216+
resolutionEnvironment=ResolutionEnvironment.EditingOrCompilationfalse
22172217
framework=true
22182218
implicitlyResolveAssemblies=true
22192219
referencedDLLs=[]
@@ -2801,55 +2801,67 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
28012801
// This call can fail if no CLR is found (this is the path to mscorlib)
28022802
membertcConfig.GetTargetFrameworkDirectories()=
28032803
use unwindBuildPhase= PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter
2804-
match tcConfig.clrRootwith
2805-
| Some x->
2806-
[tcConfig.MakePathAbsolute x]
2807-
| None->
2808-
#if ENABLE_MONO_SUPPORT
2809-
if runningOnMonothen
2810-
[letruntimeRoot= System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
2811-
letruntimeRootWithoutSlash= runtimeRoot.TrimEnd('/','\\')
2812-
letapi= runtimeRootWithoutSlash+"-api"
2813-
letrootFacades= Path.Combine(runtimeRootWithoutSlash,"Facades")
2814-
letapiFacades= Path.Combine(api,"Facades")
2815-
match tcConfig.resolutionEnvironmentwith
2816-
#if!FSI_TODO_NETCORE
2817-
// For F# Interactive code we must inly reference impementation assemblies
2818-
| ReferenceResolver.RuntimeLike->
2819-
yield runtimeRoot
2820-
if Directory.Exists(rootFacades)then
2821-
yield rootFacades// System.Runtime.dll is in /usr/lib/mono/4.5/Facades
2822-
#endif
2823-
|_->
2824-
// The default FSharp.Core is found in lib/mono/4.5
2825-
yield runtimeRoot
2826-
if Directory.Exists(rootFacades)then
2827-
yield rootFacades// System.Runtime.dll is in /usr/lib/mono/4.5/Facades
2828-
// It's not clear why we would need to reference the 4.5-api directory.
2829-
if Directory.Exists(api)then
2830-
yield api
2831-
if Directory.Exists(apiFacades)then
2832-
yield apiFacades
2833-
]
2834-
else
2804+
try
2805+
[
2806+
// Check if we are given an explicit framework root - if so, use that
2807+
match tcConfig.clrRootwith
2808+
| Some x->
2809+
yield tcConfig.MakePathAbsolute x
2810+
2811+
| None->
2812+
#if FSI_TODO_NETCORE// there is no really good notion of runtime directory on .NETCore
2813+
letruntimeRoot= Path.GetDirectoryName(typeof<System.Object>.Assembly.Location)
2814+
#else
2815+
letruntimeRoot= System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
28352816
#endif
2836-
try
2837-
[
2838-
match tcConfig.resolutionEnvironmentwith
2839-
#if!FSI_TODO_NETCORE
2840-
| ReferenceResolver.RuntimeLike->
2841-
yield System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
2817+
letruntimeRootWithoutSlash= runtimeRoot.TrimEnd('/','\\')
2818+
letruntimeRootFacades= Path.Combine(runtimeRootWithoutSlash,"Facades")
2819+
letruntimeRootWPF= Path.Combine(runtimeRootWithoutSlash,"WPF")
2820+
2821+
match tcConfig.resolutionEnvironmentwith
2822+
| ResolutionEnvironment.CompilationAndEvaluation->
2823+
// Default compilation-and-execution-time references on .NET Framework and Mono, e.g. for F# Interactive
2824+
//
2825+
// In the current way of doing things, F# Interactive refers to implementation assemblies.
2826+
yield runtimeRoot
2827+
if Directory.Exists(runtimeRootFacades)then
2828+
yield runtimeRootFacades// System.Runtime.dll is in /usr/lib/mono/4.5/Facades
2829+
if Directory.Exists(runtimeRootWPF)then
2830+
yield runtimeRootWPF// PresentationCore.dll is in C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF
2831+
2832+
| ResolutionEnvironment.EditingOrCompilation_->
2833+
#if ENABLE_MONO_SUPPORT
2834+
if runningOnMonothen
2835+
// Default compilation-time references on Mono
2836+
//
2837+
// On Mono, the default references come from the implementation assemblies.
2838+
// This is because we have had trouble reliably using MSBuild APIs to compute DotNetFrameworkReferenceAssembliesRootDirectory on Mono.
2839+
yield runtimeRoot
2840+
if Directory.Exists(runtimeRootFacades)then
2841+
yield runtimeRootFacades// System.Runtime.dll is in /usr/lib/mono/4.5/Facades
2842+
if Directory.Exists(runtimeRootWPF)then
2843+
yield runtimeRootWPF// PresentationCore.dll is in C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF
2844+
// On Mono we also add a default reference to the 4.5-api and 4.5-api/Facades directories.
2845+
letruntimeRootApi= runtimeRootWithoutSlash+"-api"
2846+
letruntimeRootApiFacades= Path.Combine(runtimeRootApi,"Facades")
2847+
if Directory.Exists(runtimeRootApi)then
2848+
yield runtimeRootApi
2849+
if Directory.Exists(runtimeRootApiFacades)then
2850+
yield runtimeRootApiFacades
2851+
else
28422852
#endif
2843-
|_->
2853+
// Default compilation-time references on .NET Framework
2854+
//
2855+
// This is the normal case for "fsc.exe a.fs". We refer to the reference assemblies folder.
28442856
letframeworkRoot= tcConfig.legacyReferenceResolver.DotNetFrameworkReferenceAssembliesRootDirectory
28452857
letframeworkRootVersion= Path.Combine(frameworkRoot,tcConfig.targetFrameworkVersion)
28462858
yield frameworkRootVersion
28472859
letfacades= Path.Combine(frameworkRootVersion,"Facades")
28482860
if Directory.Exists(facades)then
28492861
yield facades
28502862
]
2851-
with e->
2852-
errorRecovery e range0;[]
2863+
with e->
2864+
errorRecovery e range0;[]
28532865

28542866
membertcConfig.ComputeLightSyntaxInitialStatus(filename)=
28552867
use unwindBuildPhase= PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter
@@ -4854,7 +4866,7 @@ type LoadClosure =
48544866

48554867
[<RequireQualifiedAccess>]
48564868
typeCodeContext=
4857-
|Evaluation// in fsi.exe
4869+
|CompilationAndEvaluation// in fsi.exe
48584870
| Compilation// in fsc.exe
48594871
| Editing// in VS
48604872

@@ -4887,7 +4899,7 @@ module private ScriptPreprocessClosure =
48874899
// .fsx -- EDITING + !COMPILED\INTERACTIVE
48884900
letdefines=
48894901
match codeContextwith
4890-
| CodeContext.Evaluation->["INTERACTIVE"]
4902+
| CodeContext.CompilationAndEvaluation->["INTERACTIVE"]
48914903
| CodeContext.Compilation->["COMPILED"]
48924904
| CodeContext.Editing->"EDITING"::(if IsScript filenamethen["INTERACTIVE"]else["COMPILED"])
48934905
letlexbuf= UnicodeLexing.StringAsLexbuf source
@@ -4898,7 +4910,7 @@ module private ScriptPreprocessClosure =
48984910
/// Create a TcConfig for load closure starting from a single .fsx file
48994911
letCreateScriptSourceTcConfig(legacyReferenceResolver,defaultFSharpBinariesDir,filename:string,codeContext,useSimpleResolution,useFsiAuxLib,basicReferences,applyCommandLineArgs,assumeDotNetFramework)=
49004912
letprojectDir= Path.GetDirectoryName(filename)
4901-
letisInteractive=(codeContext= CodeContext.Evaluation)
4913+
letisInteractive=(codeContext= CodeContext.CompilationAndEvaluation)
49024914
letisInvalidationSupported=(codeContext= CodeContext.Editing)
49034915
lettcConfigB= TcConfigBuilder.CreateNew(legacyReferenceResolver, defaultFSharpBinariesDir,true(* optimize for memory*), projectDir, isInteractive, isInvalidationSupported, defaultCopyFSharpCore=false)
49044916
applyCommandLineArgs tcConfigB
@@ -4908,12 +4920,14 @@ module private ScriptPreprocessClosure =
49084920

49094921
tcConfigB.resolutionEnvironment<-
49104922
match codeContextwith
4911-
| CodeContext.Editing-> ReferenceResolver.DesignTimeLike
4923+
| CodeContext.Editing-> ResolutionEnvironment.EditingOrCompilationtrue
4924+
| CodeContext.Compilation-> ResolutionEnvironment.EditingOrCompilationfalse
4925+
| CodeContext.CompilationAndEvaluation->
49124926
#if FSI_TODO_NETCORE
4913-
// "RuntimeLike" assembly resolution for F# Interactive is not yet properly figured out on .NET Core
4914-
| CodeContext.Compilation| CodeContext.Evaluation-> ReferenceResolver.CompileTimeLike
4927+
// "CompilationAndEvaluation" assembly resolution for F# Interactive is not yet properly figured out on .NET Core
4928+
ResolutionEnvironment.EditingOrCompilationfalse
49154929
#else
4916-
| CodeContext.Compilation| CodeContext.Evaluation-> ReferenceResolver.RuntimeLike
4930+
ResolutionEnvironment.CompilationAndEvaluation
49174931
#endif
49184932
tcConfigB.framework<-false
49194933
tcConfigB.useSimpleResolution<- useSimpleResolution

‎src/fsharp/CompileOps.fsi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ val ReportWarningAsError : globalWarnLevel: int * specificWarnOff: int list * sp
761761

762762
[<RequireQualifiedAccess>]
763763
type CodeContext=
764-
|Evaluation
764+
|CompilationAndEvaluation
765765
| Compilation
766766
| Editing
767767

‎src/fsharp/MSBuildReferenceResolver.fs‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,12 @@ module internal Microsoft.FSharp.Compiler.MSBuildReferenceResolver
287287

288288
letregistry= sprintf"{Registry:%s,%s,%s%s}" frameworkRegistryBase targetFrameworkVersion assemblyFoldersSuffix assemblyFoldersConditions
289289

290-
[|// When compiling scripts, for some reason we have always historically put TargetFrameworkDirectory first
291-
// It is unclear why.
290+
[|// When compiling scripts using fsc.exe, for some reason we have always historically put TargetFrameworkDirectory first
291+
// It is unclear why. This is the only place we look at the 'isdifference between ResolutionEnvironment.EditingOrCompilation and ResolutionEnvironment.EditingTime.
292292
match resolutionEnvironmentwith
293-
| CompileTimeLike->yield"{TargetFrameworkDirectory}"
294-
| DesignTimeLike| RuntimeLike->()
293+
| ResolutionEnvironment.EditingOrCompilationfalse->yield"{TargetFrameworkDirectory}"
294+
| ResolutionEnvironment.EditingOrCompilationtrue
295+
| ResolutionEnvironment.CompilationAndEvaluation->()
295296

296297
// Quick-resolve straight to filename first
297298
if allowRawFileNamethen
@@ -301,8 +302,9 @@ module internal Microsoft.FSharp.Compiler.MSBuildReferenceResolver
301302
yield implicitIncludeDir// Usually the project directory
302303

303304
match resolutionEnvironmentwith
304-
| DesignTimeLike| RuntimeLike->yield"{TargetFrameworkDirectory}"
305-
| CompileTimeLike->()
305+
| ResolutionEnvironment.EditingOrCompilationtrue
306+
| ResolutionEnvironment.CompilationAndEvaluation->yield"{TargetFrameworkDirectory}"
307+
| ResolutionEnvironment.EditingOrCompilationfalse->()
306308

307309
yield registry
308310
yield"{AssemblyFolders}"

‎src/fsharp/ReferenceResolver.fs‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ module internal ReferenceResolver =
1010

1111
exceptioninternal ResolutionFailure
1212

13+
[<RequireQualifiedAccess>]
1314
typeResolutionEnvironment=
14-
/// Indicates a script or source being compiled
15-
| CompileTimeLike
16-
/// Indicates a script or source being interpreted
17-
| RuntimeLike
18-
/// Indicates a script or source being edited
19-
| DesignTimeLike
15+
/// Indicates a script or source being edited or compiled. Uses reference assemblies (not implementation assemblies).
16+
| EditingOrCompilationofisEditing:bool
17+
/// Indicates a script or source being dynamically compiled and executed. Uses implementation assemblies.
18+
| CompilationAndEvaluation
2019

2120
typeResolvedFile=
2221
{/// Item specification.

‎src/fsharp/SimulatedMSBuildReferenceResolver.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ let fscoreDir =
208208
System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
209209

210210
letresolve s=
211-
SimulatedMSBuildResolver.Resolve(ResolutionEnvironment.CompileTimeLike,[|for ain s->(a,"")|],"v4.5.1",[SimulatedMSBuildResolver.DotNetFrameworkReferenceAssembliesRootDirectory+@"\v4.5.1"],"","", fscoreDir,[],__SOURCE_DIRECTORY__,ignore,(fun _ _->()),(fun _ _->()))
211+
SimulatedMSBuildResolver.Resolve(ResolutionEnvironment.EditingOrCompilation,[|for ain s->(a,"")|],"v4.5.1",[SimulatedMSBuildResolver.DotNetFrameworkReferenceAssembliesRootDirectory+@"\v4.5.1"],"","", fscoreDir,[],__SOURCE_DIRECTORY__,ignore,(fun _ _->()),(fun _ _->()))
212212

213213
// Resolve partial name to something on search path
214214
resolve["FSharp.Core"]

‎src/fsharp/fsi/fsi.fs‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ open Microsoft.FSharp.Compiler.Tast
4848
openMicrosoft.FSharp.Compiler.Tastops
4949
openMicrosoft.FSharp.Compiler.TcGlobals
5050
openMicrosoft.FSharp.Compiler.SourceCodeServices
51+
openMicrosoft.FSharp.Compiler.ReferenceResolver
5152

5253
openInternal.Utilities
5354
openInternal.Utilities.Collections
@@ -1291,7 +1292,7 @@ type internal FsiDynamicCompiler
12911292
letsourceFiles= sourceFiles|> List.map(fun nm-> tcConfig.ResolveSourceFile(m, nm, tcConfig.implicitIncludeDir),m)
12921293

12931294
// Close the #load graph on each file and gather the inputs from the scripts.
1294-
letclosure= LoadClosure.ComputeClosureOfSourceFiles(ctok, TcConfig.Create(tcConfigB,validate=false), sourceFiles, CodeContext.Evaluation,lexResourceManager=lexResourceManager)
1295+
letclosure= LoadClosure.ComputeClosureOfSourceFiles(ctok, TcConfig.Create(tcConfigB,validate=false), sourceFiles, CodeContext.CompilationAndEvaluation,lexResourceManager=lexResourceManager)
12951296

12961297
// Intent "[Loading %s]\n" (String.concat "\n and " sourceFiles)
12971298
fsiConsoleOutput.uprintf"[%s"(FSIstrings.SR.fsiLoadingFilesPrefixText())
@@ -2459,12 +2460,12 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i
24592460

24602461
lettcConfigB= TcConfigBuilder.CreateNew(legacyReferenceResolver, defaultFSharpBinariesDir=defaultFSharpBinariesDir, optimizeForMemory=true, implicitIncludeDir=currentDirectory, isInteractive=true, isInvalidationSupported=false, defaultCopyFSharpCore=false)
24612462
lettcConfigP= TcConfigProvider.BasedOnMutableBuilder(tcConfigB)
2462-
do tcConfigB.resolutionEnvironment<-ReferenceResolver.RuntimeLike// See Bug 3608
2463+
do tcConfigB.resolutionEnvironment<-ResolutionEnvironment.CompilationAndEvaluation// See Bug 3608
24632464
do tcConfigB.useFsiAuxLib<- fsi.UseFsiAuxLib
24642465

24652466
#if FSI_TODO_NETCORE
2466-
// "RuntimeLike" assembly resolution for F# Interactive is not yet properly figured out on .NET Core
2467-
do tcConfigB.resolutionEnvironment<-ReferenceResolver.DesignTimeLike
2467+
// "CompilationAndEvaluation" assembly resolution for F# Interactive is not yet properly figured out on .NET Core
2468+
do tcConfigB.resolutionEnvironment<-ResolutionEnvironment.EditingOrCompilationfalse
24682469
do tcConfigB.useSimpleResolution<-true
24692470
do SetTargetProfile tcConfigB"netcore"// always assume System.Runtime codegen
24702471
//do SetTargetProfile tcConfigB "privatecorelib" // always assume System.Private.CoreLib codegen

‎src/fsharp/vs/IncrementalBuild.fs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,8 @@ type IncrementalBuilder(tcGlobals,frameworkTcImports, nonFrameworkAssemblyInputs
17011701
// The following uses more memory but means we don't take read-exclusions on the DLLs we reference
17021702
// Could detect well-known assemblies--ie System.dll--and open them with read-locks
17031703
tcConfigB.openBinariesInMemory<-true
1704-
tcConfigB.resolutionEnvironment<-(if useScriptResolutionRulesthen ReferenceResolver.DesignTimeLikeelse ReferenceResolver.CompileTimeLike)
1704+
1705+
tcConfigB.resolutionEnvironment<-(ReferenceResolver.ResolutionEnvironment.EditingOrCompilationtrue)
17051706

17061707
tcConfigB.conditionalCompilationDefines<-
17071708
letdefine=if useScriptResolutionRulesthen"INTERACTIVE"else"COMPILED"

‎vsintegration/src/FSharp.ProjectSystem.Base/Project/GlobalSuppressions.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
[assembly:SuppressMessage("Microsoft.Design","CA1051:DoNotDeclareVisibleInstanceFields",Scope="member",Target="Microsoft.VisualStudio.Package.ProjectOptions.#BugReportFileName",MessageId="")]
161161
[assembly:SuppressMessage("Microsoft.Design","CA1051:DoNotDeclareVisibleInstanceFields",Scope="member",Target="Microsoft.VisualStudio.Package.ProjectOptions.#CheckedArithmetic",MessageId="")]
162162
[assembly:SuppressMessage("Microsoft.Design","CA1051:DoNotDeclareVisibleInstanceFields",Scope="member",Target="Microsoft.VisualStudio.Package.ProjectOptions.#CodePage",MessageId="")]
163-
[assembly:SuppressMessage("Microsoft.Design","CA1051:DoNotDeclareVisibleInstanceFields",Scope="member",Target="Microsoft.VisualStudio.Package.ProjectOptions.#CompileAndExecute",MessageId="")]
163+
[assembly:SuppressMessage("Microsoft.Design","CA1051:DoNotDeclareVisibleInstanceFields",Scope="member",Target="Microsoft.VisualStudio.Package.ProjectOptions.#CompilationAndEvaluation",MessageId="")]
164164
[assembly:SuppressMessage("Microsoft.Design","CA1051:DoNotDeclareVisibleInstanceFields",Scope="member",Target="Microsoft.VisualStudio.Package.ProjectOptions.#DefinedPreProcessorSymbols",MessageId="")]
165165
[assembly:SuppressMessage("Microsoft.Design","CA1051:DoNotDeclareVisibleInstanceFields",Scope="member",Target="Microsoft.VisualStudio.Package.ProjectOptions.#DisplayCommandLineHelp",MessageId="")]
166166
[assembly:SuppressMessage("Microsoft.Design","CA1051:DoNotDeclareVisibleInstanceFields",Scope="member",Target="Microsoft.VisualStudio.Package.ProjectOptions.#EmitManifest",MessageId="")]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp