Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
527a3662
F
fsharp
项目概览
dotNET Platform
/
fsharp
12 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fsharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
527a3662
编写于
1月 05, 2021
作者:
K
Kevin Ransom (msft)
提交者:
GitHub
1月 05, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix sdk refs (#10839)
上级
45948f16
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
147 addition
and
108 deletion
+147
-108
src/fsharp/CompilerConfig.fs
src/fsharp/CompilerConfig.fs
+38
-13
src/fsharp/CompilerConfig.fsi
src/fsharp/CompilerConfig.fsi
+9
-4
src/fsharp/FxResolver.fs
src/fsharp/FxResolver.fs
+33
-31
src/fsharp/ScriptClosure.fs
src/fsharp/ScriptClosure.fs
+16
-9
src/fsharp/fsc.fs
src/fsharp/fsc.fs
+19
-18
src/fsharp/fsi/fsi.fs
src/fsharp/fsi/fsi.fs
+12
-16
src/fsharp/service/IncrementalBuild.fs
src/fsharp/service/IncrementalBuild.fs
+20
-17
未找到文件。
src/fsharp/CompilerConfig.fs
浏览文件 @
527a3662
...
...
@@ -316,7 +316,8 @@ type PackageManagerLine =
[<
NoEquality
;
NoComparison
>]
type
TcConfigBuilder
=
{
mutable
primaryAssembly
:
PrimaryAssembly
{
mutable
primaryAssembly
:
PrimaryAssembly
mutable
noFeedback
:
bool
mutable
stackReserveSize
:
int32
option
mutable
implicitIncludeDir
:
string
(* normally "." *)
...
...
@@ -400,7 +401,6 @@ type TcConfigBuilder =
mutable
includewin32manifest
:
bool
mutable
linkResources
:
string
list
mutable
legacyReferenceResolver
:
LegacyReferenceResolver
mutable
fxResolver
:
FxResolver
mutable
showFullPaths
:
bool
mutable
errorStyle
:
ErrorStyle
...
...
@@ -464,6 +464,10 @@ type TcConfigBuilder =
/// When false FSI will lock referenced assemblies requiring process restart, false = disable Shadow Copy false (*default*)
mutable
shadowCopyReferences
:
bool
mutable
useSdkRefs
:
bool
mutable
fxResolver
:
FxResolver
/// specify the error range for FxResolver
mutable
rangeForErrors
:
range
/// Override the SDK directory used by FxResolver, used for FCS only
mutable
sdkDirOverride
:
string
option
...
...
@@ -571,7 +575,6 @@ type TcConfigBuilder =
includewin32manifest
=
true
linkResources
=
[]
legacyReferenceResolver
=
null
fxResolver
=
Unchecked
.
defaultof
<_>
showFullPaths
=
false
errorStyle
=
ErrorStyle
.
DefaultErrors
...
...
@@ -611,6 +614,8 @@ type TcConfigBuilder =
copyFSharpCore
=
CopyFSharpCoreFlag
.
No
shadowCopyReferences
=
false
useSdkRefs
=
true
fxResolver
=
Unchecked
.
defaultof
<
FxResolver
>
rangeForErrors
=
range0
sdkDirOverride
=
None
tryGetMetadataSnapshot
=
(
fun
_
->
None
)
internalTestSpanStackReferring
=
false
...
...
@@ -638,8 +643,16 @@ type TcConfigBuilder =
}
|>
Seq
.
distinct
static
member
CreateNew
(
legacyReferenceResolver
,
fxResolver
,
defaultFSharpBinariesDir
,
reduceMemoryUsage
,
implicitIncludeDir
,
isInteractive
,
isInvalidationSupported
,
defaultCopyFSharpCore
,
tryGetMetadataSnapshot
)
=
static
member
CreateNew
(
legacyReferenceResolver
,
defaultFSharpBinariesDir
,
reduceMemoryUsage
,
implicitIncludeDir
,
isInteractive
,
isInvalidationSupported
,
defaultCopyFSharpCore
,
tryGetMetadataSnapshot
,
sdkDirOverride
,
rangeForErrors
)
=
Debug
.
Assert
(
FileSystem
.
IsPathRootedShim
implicitIncludeDir
,
sprintf
"implicitIncludeDir should be absolute: '%s'"
implicitIncludeDir
)
...
...
@@ -652,15 +665,29 @@ type TcConfigBuilder =
defaultFSharpBinariesDir
=
defaultFSharpBinariesDir
reduceMemoryUsage
=
reduceMemoryUsage
legacyReferenceResolver
=
legacyReferenceResolver
fxResolver
=
fxResolver
isInteractive
=
isInteractive
isInvalidationSupported
=
isInvalidationSupported
copyFSharpCore
=
defaultCopyFSharpCore
tryGetMetadataSnapshot
=
tryGetMetadataSnapshot
useFsiAuxLib
=
isInteractive
rangeForErrors
=
rangeForErrors
sdkDirOverride
=
sdkDirOverride
}
tcConfigBuilder
member
tcConfigB
.
FxResolver
=
let
resolver
=
lazy
(
let
assumeDotNetFramework
=
Some
(
tcConfigB
.
primaryAssembly
=
PrimaryAssembly
.
Mscorlib
)
FxResolver
(
assumeDotNetFramework
,
tcConfigB
.
implicitIncludeDir
,
rangeForErrors
=
tcConfigB
.
rangeForErrors
,
useSdkRefs
=
tcConfigB
.
useSdkRefs
,
isInteractive
=
tcConfigB
.
isInteractive
,
sdkDirOverride
=
tcConfigB
.
sdkDirOverride
))
if
tcConfigB
.
fxResolver
=
Unchecked
.
defaultof
<
FxResolver
>
then
lock
tcConfigB
(
fun
()
->
if
tcConfigB
.
fxResolver
=
Unchecked
.
defaultof
<
FxResolver
>
then
tcConfigB
.
fxResolver
<-
resolver
.
Force
()
)
tcConfigB
.
fxResolver
member
tcConfigB
.
ResolveSourceFile
(
m
,
nm
,
pathLoadedFrom
)
=
use
unwindBuildPhase
=
PushThreadBuildPhaseUntilUnwind
BuildPhase
.
Parameter
ResolveFileUsingPaths
(
tcConfigB
.
includes
@
[
pathLoadedFrom
],
m
,
nm
)
...
...
@@ -885,9 +912,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) =
#
endif
None
,
data
.
legacyReferenceResolver
.
Impl
.
HighestInstalledNetFrameworkVersion
()
let
systemAssemblies
=
data
.
fxResolver
.
GetSystemAssemblies
()
member
x
.
FxResolver
=
data
.
fxResolver
member
x
.
FxResolver
=
data
.
FxResolver
member
x
.
primaryAssembly
=
data
.
primaryAssembly
member
x
.
noFeedback
=
data
.
noFeedback
member
x
.
stackReserveSize
=
data
.
stackReserveSize
...
...
@@ -1166,7 +1191,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) =
try
FileSystem
.
SafeExists
filename
&&
((
tcConfig
.
GetTargetFrameworkDirectories
()
|>
List
.
exists
(
fun
clrRoot
->
clrRoot
=
Path
.
GetDirectoryName
filename
))
||
(
systemAssemblies
.
Contains
(
fileNameWithoutExtension
filename
))
||
(
tcConfig
.
FxResolver
.
GetSystemAssemblies
()
.
Contains
(
fileNameWithoutExtension
filename
))
||
tcConfig
.
FxResolver
.
IsInReferenceAssemblyPackDirectory
filename
)
with
_
->
false
...
...
src/fsharp/CompilerConfig.fsi
浏览文件 @
527a3662
...
...
@@ -214,7 +214,6 @@ type TcConfigBuilder =
mutable
includewin32manifest
:
bool
mutable
linkResources
:
string
list
mutable
legacyReferenceResolver
:
LegacyReferenceResolver
mutable
fxResolver
:
FxResolver
mutable
showFullPaths
:
bool
mutable
errorStyle
:
ErrorStyle
mutable
utf8output
:
bool
...
...
@@ -257,6 +256,8 @@ type TcConfigBuilder =
mutable
copyFSharpCore
:
CopyFSharpCoreFlag
mutable
shadowCopyReferences
:
bool
mutable
useSdkRefs
:
bool
mutable
fxResolver
:
FxResolver
mutable
rangeForErrors
:
range
mutable
sdkDirOverride
:
string
option
/// A function to call to try to get an object that acts as a snapshot of the metadata section of a .NET binary,
...
...
@@ -278,14 +279,15 @@ type TcConfigBuilder =
static
member
CreateNew
:
legacyReferenceResolver
:
LegacyReferenceResolver
*
fxResolver
:
FxResolver
*
defaultFSharpBinariesDir
:
string
*
reduceMemoryUsage
:
ReduceMemoryFlag
*
implicitIncludeDir
:
string
*
isInteractive
:
bool
*
isInvalidationSupported
:
bool
*
defaultCopyFSharpCore
:
CopyFSharpCoreFlag
*
tryGetMetadataSnapshot
:
ILReaderTryGetMetadataSnapshot
tryGetMetadataSnapshot
:
ILReaderTryGetMetadataSnapshot
*
sdkDirOverride
:
string
option
*
rangeForErrors
:
range
->
TcConfigBuilder
member
DecideNames
:
string
list
->
outfile
:
string
*
pdbfile
:
string
option
*
assemblyName
:
string
...
...
@@ -317,6 +319,9 @@ type TcConfigBuilder =
member
AddLoadedSource
:
m
:
range
*
originalPath
:
string
*
pathLoadedFrom
:
string
->
unit
member
FxResolver
:
FxResolver
/// Immutable TcConfig, modifications are made via a TcConfigBuilder
[<
Sealed
>]
type
TcConfig
=
...
...
src/fsharp/FxResolver.fs
浏览文件 @
527a3662
...
...
@@ -763,6 +763,7 @@ type internal FxResolver(assumeDotNetFramework: bool option, projectDir: string,
// The set of references entered into the TcConfigBuilder for scripts prior to computing the load closure.
member
_.
GetDefaultReferences
(
useFsiAuxLib
,
assumeDotNetFramework
)
=
let
defaultReferences
=
if
assumeDotNetFramework
then
getDotNetFrameworkDefaultReferences
useFsiAuxLib
,
assumeDotNetFramework
else
...
...
@@ -797,4 +798,5 @@ type internal FxResolver(assumeDotNetFramework: bool option, projectDir: string,
getDotNetFrameworkDefaultReferences
useFsiAuxLib
,
true
else
getDotNetCoreImplementationReferences
useFsiAuxLib
,
assumeDotNetFramework
defaultReferences
src/fsharp/ScriptClosure.fs
浏览文件 @
527a3662
...
...
@@ -130,13 +130,20 @@ module ScriptPreprocessClosure =
let
isInvalidationSupported
=
(
codeContext
=
CodeContext
.
Editing
)
let
rangeForErrors
=
mkFirstLineOfFile
filename
let
fxResolver
=
FxResolver
(
Some
assumeDotNetFramework
,
projectDir
,
rangeForErrors
=
rangeForErrors
,
useSdkRefs
=
useSdkRefs
,
isInteractive
=
isInteractive
,
sdkDirOverride
=
sdkDirOverride
)
let
tcConfigB
=
TcConfigBuilder
.
CreateNew
(
legacyReferenceResolver
,
fxResolver
,
defaultFSharpBinariesDir
,
reduceMemoryUsage
,
projectDir
,
isInteractive
,
isInvalidationSupported
,
CopyFSharpCoreFlag
.
No
,
tryGetMetadataSnapshot
)
let
tcb
=
TcConfigBuilder
.
CreateNew
(
legacyReferenceResolver
,
defaultFSharpBinariesDir
,
reduceMemoryUsage
,
projectDir
,
isInteractive
,
isInvalidationSupported
,
CopyFSharpCoreFlag
.
No
,
tryGetMetadataSnapshot
,
sdkDirOverride
,
rangeForErrors
)
tcb
.
useSdkRefs
<-
useSdkRefs
tcb
applyCommandLineArgs
tcConfigB
...
...
@@ -147,7 +154,7 @@ module ScriptPreprocessClosure =
|
None
->
let
errorLogger
=
CapturingErrorLogger
(
"ScriptDefaultReferences"
)
use
unwindEL
=
PushErrorLoggerPhaseUntilUnwind
(
fun
_
->
errorLogger
)
let
references
,
assumeDotNetFramework
=
f
xResolver
.
GetDefaultReferences
(
useFsiAuxLib
,
assumeDotNetFramework
)
let
references
,
assumeDotNetFramework
=
tcConfigB
.
F
xResolver
.
GetDefaultReferences
(
useFsiAuxLib
,
assumeDotNetFramework
)
// Add script references
for
reference
in
references
do
tcConfigB
.
AddReferencedAssemblyByPath
(
range0
,
reference
)
...
...
src/fsharp/fsc.fs
浏览文件 @
527a3662
...
...
@@ -445,16 +445,20 @@ let main1(ctok, argv, legacyReferenceResolver, bannerAlreadyPrinted,
let
tryGetMetadataSnapshot
=
(
fun
_
->
None
)
let
fxResolver
=
FxResolver
(
None
,
directoryBuildingFrom
,
rangeForErrors
=
range0
,
useSdkRefs
=
true
,
isInteractive
=
false
,
sdkDirOverride
=
None
)
let
defaultFSharpBinariesDir
=
FSharpEnvironment
.
BinFolderOfDefaultFSharpCompiler
(
FSharpEnvironment
.
tryCurrentDomain
()
).
Value
let
tcConfigB
=
TcConfigBuilder
.
CreateNew
(
legacyReferenceResolver
,
fxResolver
,
defaultFSharpBinariesDir
,
reduceMemoryUsage
=
reduceMemoryUsage
,
implicitIncludeDir
=
directoryBuildingFrom
,
isInteractive
=
false
,
isInvalidationSupported
=
false
,
TcConfigBuilder
.
CreateNew
(
legacyReferenceResolver
,
defaultFSharpBinariesDir
,
reduceMemoryUsage
=
reduceMemoryUsage
,
implicitIncludeDir
=
directoryBuildingFrom
,
isInteractive
=
false
,
isInvalidationSupported
=
false
,
defaultCopyFSharpCore
=
defaultCopyFSharpCore
,
tryGetMetadataSnapshot
=
tryGetMetadataSnapshot
)
tryGetMetadataSnapshot
=
tryGetMetadataSnapshot
,
sdkDirOverride
=
None
,
rangeForErrors
=
range0
)
// Preset: --optimize+ -g --tailcalls+ (see 4505)
SetOptimizeSwitch
tcConfigB
OptionSwitch
.
On
...
...
@@ -484,9 +488,6 @@ let main1(ctok, argv, legacyReferenceResolver, bannerAlreadyPrinted,
delayForFlagsLogger
.
ForwardDelayedDiagnostics
tcConfigB
exiter
.
Exit
1
let
assumeDotNetFramework
=
(
tcConfigB
.
primaryAssembly
=
PrimaryAssembly
.
Mscorlib
)
tcConfigB
.
fxResolver
<-
FxResolver
(
Some
assumeDotNetFramework
,
directoryBuildingFrom
,
rangeForErrors
=
range0
,
useSdkRefs
=
true
,
isInteractive
=
false
,
sdkDirOverride
=
None
)
tcConfigB
.
conditionalCompilationDefines
<-
"COMPILED"
::
tcConfigB
.
conditionalCompilationDefines
// Display the banner text, if necessary
...
...
@@ -633,16 +634,16 @@ let main1OfAst
let
directoryBuildingFrom
=
Directory
.
GetCurrentDirectory
()
let
fxResolver
=
FxResolver
(
None
,
directoryBuildingFrom
,
rangeForErrors
=
range0
,
useSdkRefs
=
true
,
isInteractive
=
false
,
sdkDirOverride
=
None
)
let
defaultFSharpBinariesDir
=
FSharpEnvironment
.
BinFolderOfDefaultFSharpCompiler
(
FSharpEnvironment
.
tryCurrentDomain
()
).
Value
let
tcConfigB
=
TcConfigBuilder
.
CreateNew
(
legacyReferenceResolver
,
fxResolver
,
defaultFSharpBinariesDir
,
TcConfigBuilder
.
CreateNew
(
legacyReferenceResolver
,
defaultFSharpBinariesDir
,
reduceMemoryUsage
=
reduceMemoryUsage
,
implicitIncludeDir
=
directoryBuildingFrom
,
isInteractive
=
false
,
isInvalidationSupported
=
false
,
defaultCopyFSharpCore
=
CopyFSharpCoreFlag
.
No
,
tryGetMetadataSnapshot
=
tryGetMetadataSnapshot
)
tryGetMetadataSnapshot
=
tryGetMetadataSnapshot
,
sdkDirOverride
=
None
,
rangeForErrors
=
range0
)
let
primaryAssembly
=
// temporary workaround until https://github.com/dotnet/fsharp/pull/8043 is merged:
...
...
src/fsharp/fsi/fsi.fs
浏览文件 @
527a3662
...
...
@@ -841,7 +841,7 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig,
member
_.
WriteReferencesAndExit
=
writeReferencesAndExit
member
_.
DependencyProvider
=
dependencyProvider
member
_.
FxResolver
=
tcConfigB
.
f
xResolver
member
_.
FxResolver
=
tcConfigB
.
F
xResolver
/// Set the current ui culture for the current thread.
let
internal
SetCurrentUICultureForThread
(
lcid
:
int
option
)
=
...
...
@@ -2757,21 +2757,17 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i
|
None
->
SimulatedMSBuildReferenceResolver
.
getResolver
()
|
Some
rr
->
rr
// We know the target framework up front
let
assumeDotNetFramework
=
not
FSharpEnvironment
.
isRunningOnCoreClr
let
fxResolver
=
FxResolver
(
Some
assumeDotNetFramework
,
currentDirectory
,
rangeForErrors
=
range0
,
useSdkRefs
=
true
,
isInteractive
=
true
,
sdkDirOverride
=
None
)
let
tcConfigB
=
TcConfigBuilder
.
CreateNew
(
legacyReferenceResolver
,
fxResolver
,
defaultFSharpBinariesDir
=
defaultFSharpBinariesDir
,
reduceMemoryUsage
=
ReduceMemoryFlag
.
Yes
,
implicitIncludeDir
=
currentDirectory
,
isInteractive
=
true
,
isInvalidationSupported
=
false
,
defaultCopyFSharpCore
=
CopyFSharpCoreFlag
.
No
,
tryGetMetadataSnapshot
=
tryGetMetadataSnapshot
)
tryGetMetadataSnapshot
=
tryGetMetadataSnapshot
,
sdkDirOverride
=
None
,
rangeForErrors
=
range0
)
let
tcConfigP
=
TcConfigProvider
.
BasedOnMutableBuilder
(
tcConfigB
)
do
tcConfigB
.
resolutionEnvironment
<-
LegacyResolutionEnvironment
.
CompilationAndEvaluation
// See Bug 3608
...
...
src/fsharp/service/IncrementalBuild.fs
浏览文件 @
527a3662
...
...
@@ -1303,29 +1303,32 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput
|
Some
idx
->
Some
(
commandLineArgs
.[
idx
].
Substring
(
switchString
.
Length
))
|
_
->
None
let
assumeDotNetFramework
=
match
loadClosureOpt
with
|
None
->
None
|
Some
loadClosure
->
Some
loadClosure
.
UseDesktopFramework
let
sdkDirOverride
=
match
loadClosureOpt
with
|
None
->
None
|
Some
loadClosure
->
loadClosure
.
SdkDirOverride
let
fxResolver
=
FxResolver
(
assumeDotNetFramework
,
projectDirectory
,
rangeForErrors
=
range0
,
useSdkRefs
=
true
,
isInteractive
=
false
,
sdkDirOverride
=
sdkDirOverride
)
// see also fsc.fs: runFromCommandLineToImportingAssemblies(), as there are many similarities to where the PS creates a tcConfigB
let
tcConfigB
=
TcConfigBuilder
.
CreateNew
(
legacyReferenceResolver
,
fxResolver
,
defaultFSharpBinariesDir
,
implicitIncludeDir
=
projectDirectory
,
reduceMemoryUsage
=
ReduceMemoryFlag
.
Yes
,
isInteractive
=
useScriptResolutionRules
,
isInvalidationSupported
=
true
,
defaultCopyFSharpCore
=
CopyFSharpCoreFlag
.
No
,
tryGetMetadataSnapshot
=
tryGetMetadataSnapshot
)
tryGetMetadataSnapshot
=
tryGetMetadataSnapshot
,
sdkDirOverride
=
sdkDirOverride
,
rangeForErrors
=
range0
)
tcConfigB
.
primaryAssembly
<-
match
loadClosureOpt
with
|
None
->
PrimaryAssembly
.
Mscorlib
|
Some
loadClosure
->
if
loadClosure
.
UseDesktopFramework
then
PrimaryAssembly
.
Mscorlib
else
PrimaryAssembly
.
System_Runtime
tcConfigB
.
resolutionEnvironment
<-
(
LegacyResolutionEnvironment
.
EditingOrCompilation
true
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录