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

Commit7bc69c4

Browse files
dsymedsyme
dsyme
authored and
dsyme
committed
add WPF path to fsi.exe and cleanup resolution flags
1 parent86fcbe3 commit7bc69c4

File tree

9 files changed

+81
-71
lines changed

9 files changed

+81
-71
lines changed

‎src/fsharp/CompileOps.fs‎

Lines changed: 58 additions & 50 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.EditingAndCompilationfalse
22172217
framework=true
22182218
implicitlyResolveAssemblies=true
22192219
referencedDLLs=[]
@@ -2801,55 +2801,61 @@ 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
2835-
#endif
2836-
try
2837-
[
2838-
match tcConfig.resolutionEnvironmentwith
2839-
#if!FSI_TODO_NETCORE
2840-
| ReferenceResolver.RuntimeLike->
2841-
yield System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
2842-
#endif
2843-
|_->
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+
letruntimeRoot= System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
2813+
letruntimeRootWithoutSlash= runtimeRoot.TrimEnd('/','\\')
2814+
letruntimeRootFacades= Path.Combine(runtimeRootWithoutSlash,"Facades")
2815+
letruntimeRootWPF= Path.Combine(runtimeRootWithoutSlash,"WPF")
2816+
2817+
match tcConfig.resolutionEnvironmentwith
2818+
| ResolutionEnvironment.CompilationAndEvaluation->
2819+
// Default compilation-and-execution-time references on .NET Framework and Mono, e.g. for F# Interactive
2820+
//
2821+
// In the current way of doing things, F# Interactive refers to implementation assemblies.
2822+
yield runtimeRoot
2823+
if Directory.Exists(runtimeRootFacades)then
2824+
yield runtimeRootFacades// System.Runtime.dll is in /usr/lib/mono/4.5/Facades
2825+
if Directory.Exists(runtimeRootWPF)then
2826+
yield runtimeRootWPF// PresentationCore.dll is in C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF
2827+
2828+
| ResolutionEnvironment.EditingAndCompilation_->
2829+
if runningOnMonothen
2830+
// Default compilation-time references on Mono
2831+
//
2832+
// On Mono, the default references come from the implementation assemblies.
2833+
// This is because we have had trouble reliably using MSBuild APIs to compute DotNetFrameworkReferenceAssembliesRootDirectory on Mono.
2834+
yield runtimeRoot
2835+
if Directory.Exists(runtimeRootFacades)then
2836+
yield runtimeRootFacades// System.Runtime.dll is in /usr/lib/mono/4.5/Facades
2837+
if Directory.Exists(runtimeRootWPF)then
2838+
yield runtimeRootWPF// PresentationCore.dll is in C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF
2839+
// On Mono we also add a default reference to the 4.5-api and 4.5-api/Facades directories.
2840+
letruntimeRootApi= runtimeRootWithoutSlash+"-api"
2841+
letruntimeRootApiFacades= Path.Combine(runtimeRootApi,"Facades")
2842+
if Directory.Exists(runtimeRootApi)then
2843+
yield runtimeRootApi
2844+
if Directory.Exists(runtimeRootApiFacades)then
2845+
yield runtimeRootApiFacades
2846+
else
2847+
// Default compilation-time references on .NET Framework
2848+
//
2849+
// This is the normal case for "fsc.exe a.fs". We refer to the reference assemblies folder.
28442850
letframeworkRoot= tcConfig.legacyReferenceResolver.DotNetFrameworkReferenceAssembliesRootDirectory
28452851
letframeworkRootVersion= Path.Combine(frameworkRoot,tcConfig.targetFrameworkVersion)
28462852
yield frameworkRootVersion
28472853
letfacades= Path.Combine(frameworkRootVersion,"Facades")
28482854
if Directory.Exists(facades)then
28492855
yield facades
28502856
]
2851-
with e->
2852-
errorRecovery e range0;[]
2857+
with e->
2858+
errorRecovery e range0;[]
28532859

28542860
membertcConfig.ComputeLightSyntaxInitialStatus(filename)=
28552861
use unwindBuildPhase= PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter
@@ -4854,7 +4860,7 @@ type LoadClosure =
48544860

48554861
[<RequireQualifiedAccess>]
48564862
typeCodeContext=
4857-
|Evaluation// in fsi.exe
4863+
|CompilationAndEvaluation// in fsi.exe
48584864
| Compilation// in fsc.exe
48594865
| Editing// in VS
48604866

@@ -4887,7 +4893,7 @@ module private ScriptPreprocessClosure =
48874893
// .fsx -- EDITING + !COMPILED\INTERACTIVE
48884894
letdefines=
48894895
match codeContextwith
4890-
| CodeContext.Evaluation->["INTERACTIVE"]
4896+
| CodeContext.CompilationAndEvaluation->["INTERACTIVE"]
48914897
| CodeContext.Compilation->["COMPILED"]
48924898
| CodeContext.Editing->"EDITING"::(if IsScript filenamethen["INTERACTIVE"]else["COMPILED"])
48934899
letlexbuf= UnicodeLexing.StringAsLexbuf source
@@ -4898,7 +4904,7 @@ module private ScriptPreprocessClosure =
48984904
/// Create a TcConfig for load closure starting from a single .fsx file
48994905
letCreateScriptSourceTcConfig(legacyReferenceResolver,defaultFSharpBinariesDir,filename:string,codeContext,useSimpleResolution,useFsiAuxLib,basicReferences,applyCommandLineArgs,assumeDotNetFramework)=
49004906
letprojectDir= Path.GetDirectoryName(filename)
4901-
letisInteractive=(codeContext= CodeContext.Evaluation)
4907+
letisInteractive=(codeContext= CodeContext.CompilationAndEvaluation)
49024908
letisInvalidationSupported=(codeContext= CodeContext.Editing)
49034909
lettcConfigB= TcConfigBuilder.CreateNew(legacyReferenceResolver, defaultFSharpBinariesDir,true(* optimize for memory*), projectDir, isInteractive, isInvalidationSupported, defaultCopyFSharpCore=false)
49044910
applyCommandLineArgs tcConfigB
@@ -4908,12 +4914,14 @@ module private ScriptPreprocessClosure =
49084914

49094915
tcConfigB.resolutionEnvironment<-
49104916
match codeContextwith
4911-
| CodeContext.Editing-> ReferenceResolver.DesignTimeLike
4917+
| CodeContext.Editing-> ResolutionEnvironment.EditingAndCompilationtrue
4918+
| CodeContext.Compilation-> ResolutionEnvironment.EditingAndCompilationfalse
4919+
| CodeContext.CompilationAndEvaluation->
49124920
#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
4921+
// "CompilationAndEvaluation" assembly resolution for F# Interactive is not yet properly figured out on .NET Core
4922+
ResolutionEnvironment.EditingAndCompilationfalse
49154923
#else
4916-
| CodeContext.Compilation| CodeContext.Evaluation-> ReferenceResolver.RuntimeLike
4924+
ResolutionEnvironment.CompilationAndEvaluation
49174925
#endif
49184926
tcConfigB.framework<-false
49194927
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.EditingAndCompilation and ResolutionEnvironment.EditingTime.
292292
match resolutionEnvironmentwith
293-
| CompileTimeLike->yield"{TargetFrameworkDirectory}"
294-
| DesignTimeLike| RuntimeLike->()
293+
| ResolutionEnvironment.EditingAndCompilationfalse->yield"{TargetFrameworkDirectory}"
294+
| ResolutionEnvironment.EditingAndCompilationtrue
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.EditingAndCompilationtrue
306+
| ResolutionEnvironment.CompilationAndEvaluation->yield"{TargetFrameworkDirectory}"
307+
| ResolutionEnvironment.EditingAndCompilationfalse->()
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 compiled. Uses reference assemblies (not implementation assemblies).
16+
| EditingAndCompilationofisEditing: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.EditingAndCompilation,[|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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ type internal FsiDynamicCompiler
12911291
letsourceFiles= sourceFiles|> List.map(fun nm-> tcConfig.ResolveSourceFile(m, nm, tcConfig.implicitIncludeDir),m)
12921292

12931293
// 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)
1294+
letclosure= LoadClosure.ComputeClosureOfSourceFiles(ctok, TcConfig.Create(tcConfigB,validate=false), sourceFiles, CodeContext.CompilationAndEvaluation,lexResourceManager=lexResourceManager)
12951295

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

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

24652465
#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
2466+
// "CompilationAndEvaluation" assembly resolution for F# Interactive is not yet properly figured out on .NET Core
2467+
do tcConfigB.resolutionEnvironment<-ResolutionEnvironment.EditingAndCompilationfalse
24682468
do tcConfigB.useSimpleResolution<-true
24692469
do SetTargetProfile tcConfigB"netcore"// always assume System.Runtime codegen
24702470
//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.EditingAndCompilationtrue)
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="")]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public ProjectOptions(ConfigCanonicalName configCanonicalName)
7171

7272
publicstringRootNamespace;
7373

74-
publicboolCompileAndExecute;
74+
publicboolCompilationAndEvaluation;
7575

7676
/// <devdoc>must be an int if not null.</devdoc>
7777
publicobjectUserLocaleId;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp