Skip to content

Sync from Azure DevOps: release/dev17.12 #18741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: release/dev17.12
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,11 @@ tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstanda
/tests/AheadOfTime/Trimming/output.txt
*.svclog
micro.exe
positive.exe
positive.exe
/tests/FSharp.Compiler.ComponentTests/FSharpChecker/StandardError.txt
/tests/FSharp.Compiler.ComponentTests/FSharpChecker/StandardOutput.txt

# ilverify baseline result files
*.bsl.actual
/src/FSharp.DependencyManager.Nuget/StandardError.txt
/src/FSharp.DependencyManager.Nuget/StandardOutput.txt
2 changes: 2 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ extends:
enablePublishBuildAssets: true
enablePublishUsingPipelines: $(_PublishUsingPipelines)
enableSourceBuild: true
sourceBuildParameters:
enableInternalSources: true
enableTelemetry: true
helixRepo: dotnet/fsharp
jobs:
Expand Down
8 changes: 8 additions & 0 deletions eng/SourceBuildPrebuiltBaseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,12 @@
<!-- Tracked in https://github.com/dotnet/source-build/issues/3438 -->
<UsagePattern IdentityGlob="Microsoft.VisualStudio.Setup.Configuration.Interop/3.2.2146" />
</IgnorePatterns>

<Usages>
<Usage Id="Microsoft.Build.Framework" Version="17.12.36" IsDirectDependency="true"/>
<Usage Id="Microsoft.Build.Tasks.Core" Version="17.12.36" IsDirectDependency="true"/>
<Usage Id="Microsoft.Build.Utilities.Core" Version="17.12.36" IsDirectDependency="true"/>
<Usage Id="Microsoft.NET.StringTools" Version="17.12.36"/>
<Usage Id="System.Formats.Asn1" Version="8.0.1"/>
</Usages>
</UsageData>
4 changes: 2 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<!-- F# Version components -->
<FSMajorVersion>9</FSMajorVersion>
<FSMinorVersion>0</FSMinorVersion>
<FSBuildVersion>101</FSBuildVersion>
<FSBuildVersion>102</FSBuildVersion>
<FSRevisionVersion>0</FSRevisionVersion>
<!-- -->
<!-- F# Language version -->
Expand Down Expand Up @@ -94,7 +94,7 @@
<MicrosoftVisualStudioShellPackagesVersion>17.10.40152</MicrosoftVisualStudioShellPackagesVersion>
<VisualStudioProjectSystemPackagesVersion>17.10.526-pre-g1b474069f5</VisualStudioProjectSystemPackagesVersion>
<MicrosoftVisualStudioThreadingPackagesVersion>17.10.41</MicrosoftVisualStudioThreadingPackagesVersion>
<MicrosoftBuildVersion>17.11.0-preview-24178-03</MicrosoftBuildVersion>
<MicrosoftBuildVersion>17.12.36</MicrosoftBuildVersion>
<!-- Roslyn packages -->
<MicrosoftCodeAnalysisEditorFeaturesVersion>$(RoslynVersion)</MicrosoftCodeAnalysisEditorFeaturesVersion>
<MicrosoftCodeAnalysisEditorFeaturesTextVersion>$(RoslynVersion)</MicrosoftCodeAnalysisEditorFeaturesTextVersion>
Expand Down
7 changes: 7 additions & 0 deletions eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ while [[ $# > 0 ]]; do
tfm=$2
shift
;;
# nop implementations of runtime* args sourcebuild might pass in on internal builds
--runtimesourcefeed)
shift
;;
--runtimesourcefeedkey)
shift
;;
/p:*)
properties="$properties $1"
;;
Expand Down
69 changes: 42 additions & 27 deletions src/Compiler/Driver/ScriptClosure.fs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ type LoadClosure =
/// The resolved package references along with the ranges of the #r positions in each file.
PackageReferences: (range * string list)[]

/// The raw package manager lines in the script
PackageManagerLines: Map<string, PackageManagerLine list>

/// Whether we're decided to use .NET Framework analysis for this script
UseDesktopFramework: bool

Expand Down Expand Up @@ -82,7 +85,8 @@ type CodeContext =
module ScriptPreprocessClosure =

/// Represents an input to the closure finding process
type ClosureSource = ClosureSource of fileName: string * referenceRange: range * sourceText: ISourceText * parseRequired: bool
type ClosureSource =
| ClosureSource of fileName: string * referenceRange: range * sourceText: ISourceText * Position option * parseRequired: bool

/// Represents an output of the closure finding process
type ClosureFile =
Expand Down Expand Up @@ -253,7 +257,7 @@ module ScriptPreprocessClosure =
| Some(n: int) -> new StreamReader(stream, Encoding.GetEncoding n)

let source = reader.ReadToEnd()
[ ClosureSource(fileName, m, SourceText.ofString source, parseRequired) ]
[ ClosureSource(fileName, m, SourceText.ofString source, None, parseRequired) ]
with RecoverableException exn ->
errorRecovery exn m
[]
Expand Down Expand Up @@ -313,12 +317,23 @@ module ScriptPreprocessClosure =
let packageReferences = Dictionary<range, string list>(HashIdentity.Structural)

// Resolve the packages
let rec resolveDependencyManagerSources scriptName =
let rec resolveDependencyManagerSources scriptName (caret: Position option) =
let caretLine =
match caret with
| None -> Int32.MinValue
| Some pos -> pos.Line

let isEditorCursorInPackageLines (line: PackageManagerLine) =
caretLine >= line.Range.StartLine && caretLine <= line.Range.EndLine

[
if not (loadScripts.Contains scriptName) then
for kv in tcConfig.packageManagerLines do
let packageManagerKey, packageManagerLines = kv.Key, kv.Value

let packageManagerLines =
packageManagerLines |> List.filter (not << isEditorCursorInPackageLines)

match packageManagerLines with
| [] -> ()
| packageManagerLine :: _ ->
Expand Down Expand Up @@ -426,7 +441,7 @@ module ScriptPreprocessClosure =
let scriptText = stream.ReadAllText()
loadScripts.Add script |> ignore
let iSourceText = SourceText.ofString scriptText
yield! processClosureSource (ClosureSource(script, m, iSourceText, true))
yield! processClosureSource (ClosureSource(script, m, iSourceText, None, true))

else
// Send outputs via diagnostics
Expand All @@ -443,7 +458,7 @@ module ScriptPreprocessClosure =
tcConfig <- TcConfig.Create(tcConfigB, validate = false)
]

and processClosureSource (ClosureSource(fileName, m, sourceText, parseRequired)) =
and processClosureSource (ClosureSource(fileName, m, sourceText, caret, parseRequired)) =
[
if not (observedSources.HaveSeen(fileName)) then
observedSources.SetSeen(fileName)
Expand Down Expand Up @@ -473,7 +488,7 @@ module ScriptPreprocessClosure =

tcConfig <- tcConfigResult // We accumulate the tcConfig in order to collect assembly references

yield! resolveDependencyManagerSources fileName
yield! resolveDependencyManagerSources fileName caret

let postSources = tcConfig.GetAvailableLoadedSources()

Expand All @@ -483,7 +498,7 @@ module ScriptPreprocessClosure =
else
[]

yield! resolveDependencyManagerSources fileName
yield! resolveDependencyManagerSources fileName caret

for m, subFile in sources do
if IsScript subFile then
Expand Down Expand Up @@ -540,7 +555,7 @@ module ScriptPreprocessClosure =
| _ -> lastClosureFile

/// Reduce the full directive closure into LoadClosure
let GetLoadClosure (rootFilename, closureFiles, tcConfig: TcConfig, codeContext, packageReferences, earlierDiagnostics) =
let GetLoadClosure (rootFilename, closureFiles, tcConfig: TcConfig, codeContext, packageReferences, earlierDiagnostics) : LoadClosure =

// Mark the last file as isLastCompiland.
let closureFiles =
Expand Down Expand Up @@ -612,23 +627,21 @@ module ScriptPreprocessClosure =
// Filter out non-root errors and warnings
let allRootDiagnostics = allRootDiagnostics |> List.filter (fst >> isRootRange)

let result: LoadClosure =
{
SourceFiles = List.groupBy fst sourceFiles |> List.map (map2Of2 (List.map snd))
References = List.groupBy fst references |> List.map (map2Of2 (List.map snd))
PackageReferences = packageReferences
UseDesktopFramework = (tcConfig.primaryAssembly = PrimaryAssembly.Mscorlib)
SdkDirOverride = tcConfig.sdkDirOverride
UnresolvedReferences = unresolvedReferences
Inputs = sourceInputs
NoWarns = List.groupBy fst globalNoWarns |> List.map (map2Of2 (List.map snd))
OriginalLoadReferences = tcConfig.loadedSources
ResolutionDiagnostics = resolutionDiagnostics
AllRootFileDiagnostics = allRootDiagnostics
LoadClosureRootFileDiagnostics = loadClosureRootDiagnostics
}

result
{
SourceFiles = List.groupBy fst sourceFiles |> List.map (map2Of2 (List.map snd))
References = List.groupBy fst references |> List.map (map2Of2 (List.map snd))
PackageReferences = packageReferences
PackageManagerLines = tcConfig.packageManagerLines
UseDesktopFramework = (tcConfig.primaryAssembly = PrimaryAssembly.Mscorlib)
SdkDirOverride = tcConfig.sdkDirOverride
UnresolvedReferences = unresolvedReferences
Inputs = sourceInputs
NoWarns = List.groupBy fst globalNoWarns |> List.map (map2Of2 (List.map snd))
OriginalLoadReferences = tcConfig.loadedSources
ResolutionDiagnostics = resolutionDiagnostics
AllRootFileDiagnostics = allRootDiagnostics
LoadClosureRootFileDiagnostics = loadClosureRootDiagnostics
}

/// Given source text, find the full load closure. Used from service.fs, when editing a script file
let GetFullClosureOfScriptText
Expand All @@ -637,6 +650,7 @@ module ScriptPreprocessClosure =
defaultFSharpBinariesDir,
fileName,
sourceText,
caret,
codeContext,
useSimpleResolution,
useFsiAuxLib,
Expand All @@ -649,7 +663,6 @@ module ScriptPreprocessClosure =
reduceMemoryUsage,
dependencyProvider
) =

// Resolve the basic references such as FSharp.Core.dll first, before processing any #I directives in the script
//
// This is tries to mimic the action of running the script in F# Interactive - the initial context for scripting is created
Expand Down Expand Up @@ -700,7 +713,7 @@ module ScriptPreprocessClosure =
reduceMemoryUsage
)

let closureSources = [ ClosureSource(fileName, range0, sourceText, true) ]
let closureSources = [ ClosureSource(fileName, range0, sourceText, caret, true) ]

let closureFiles, tcConfig, packageReferences =
FindClosureFiles(fileName, closureSources, tcConfig, codeContext, lexResourceManager, dependencyProvider)
Expand Down Expand Up @@ -742,6 +755,7 @@ type LoadClosure with
defaultFSharpBinariesDir,
fileName: string,
sourceText: ISourceText,
caret: Position option,
implicitDefines,
useSimpleResolution: bool,
useFsiAuxLib,
Expand All @@ -762,6 +776,7 @@ type LoadClosure with
defaultFSharpBinariesDir,
fileName,
sourceText,
caret,
implicitDefines,
useSimpleResolution,
useFsiAuxLib,
Expand Down
4 changes: 4 additions & 0 deletions src/Compiler/Driver/ScriptClosure.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ type LoadClosure =
/// The resolved package references along with the ranges of the #r positions in each file.
PackageReferences: (range * string list)[]

/// The raw package manager lines in the script
PackageManagerLines: Map<string, PackageManagerLine list>

/// Whether we're decided to use .NET Framework analysis for this script
UseDesktopFramework: bool

Expand Down Expand Up @@ -80,6 +83,7 @@ type LoadClosure =
defaultFSharpBinariesDir: string *
fileName: string *
sourceText: ISourceText *
caret: Position option *
implicitDefines: CodeContext *
useSimpleResolution: bool *
useFsiAuxLib: bool *
Expand Down
8 changes: 8 additions & 0 deletions src/Compiler/Service/BackgroundCompiler.fs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ type internal IBackgroundCompiler =
abstract member GetProjectOptionsFromScript:
fileName: string *
sourceText: ISourceText *
caret: Position option *
previewEnabled: bool option *
loadedTimeStamp: System.DateTime option *
otherFlags: string array option *
Expand All @@ -126,6 +127,7 @@ type internal IBackgroundCompiler =
abstract GetProjectSnapshotFromScript:
fileName: string *
sourceText: ISourceTextNew *
caret: Position option *
documentSource: DocumentSource *
previewEnabled: bool option *
loadedTimeStamp: System.DateTime option *
Expand Down Expand Up @@ -1307,6 +1309,7 @@ type internal BackgroundCompiler
(
fileName,
sourceText,
caret,
previewEnabled,
loadedTimeStamp,
otherFlags,
Expand Down Expand Up @@ -1357,6 +1360,7 @@ type internal BackgroundCompiler
FSharpCheckerResultsSettings.defaultFSharpBinariesDir,
fileName,
sourceText,
caret,
CodeContext.Editing,
useSimpleResolution,
useFsiAuxLib,
Expand Down Expand Up @@ -1592,6 +1596,7 @@ type internal BackgroundCompiler
(
fileName: string,
sourceText: ISourceText,
caret: Position option,
previewEnabled: bool option,
loadedTimeStamp: DateTime option,
otherFlags: string array option,
Expand All @@ -1605,6 +1610,7 @@ type internal BackgroundCompiler
self.GetProjectOptionsFromScript(
fileName,
sourceText,
caret,
previewEnabled,
loadedTimeStamp,
otherFlags,
Expand All @@ -1620,6 +1626,7 @@ type internal BackgroundCompiler
(
fileName: string,
sourceText: ISourceTextNew,
caret: Position option,
documentSource: DocumentSource,
previewEnabled: bool option,
loadedTimeStamp: DateTime option,
Expand All @@ -1636,6 +1643,7 @@ type internal BackgroundCompiler
self.GetProjectOptionsFromScript(
fileName,
sourceText,
caret,
previewEnabled,
loadedTimeStamp,
otherFlags,
Expand Down
2 changes: 2 additions & 0 deletions src/Compiler/Service/BackgroundCompiler.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ type internal IBackgroundCompiler =
abstract GetProjectOptionsFromScript:
fileName: string *
sourceText: ISourceText *
caret: Position option *
previewEnabled: bool option *
loadedTimeStamp: System.DateTime option *
otherFlags: string array option *
Expand All @@ -104,6 +105,7 @@ type internal IBackgroundCompiler =
abstract GetProjectSnapshotFromScript:
fileName: string *
sourceText: ISourceTextNew *
caret: Position option *
documentSource: DocumentSource *
previewEnabled: bool option *
loadedTimeStamp: System.DateTime option *
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/Service/FSharpCheckerResults.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3946,6 +3946,7 @@ type FsiInteractiveChecker(legacyReferenceResolver, tcConfig: TcConfig, tcGlobal
defaultFSharpBinariesDir,
fileName,
sourceText,
None,
CodeContext.Editing,
tcConfig.useSimpleResolution,
tcConfig.useFsiAuxLib,
Expand Down
4 changes: 4 additions & 0 deletions src/Compiler/Service/TransparentCompiler.fs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ type internal TransparentCompiler
defaultFSharpBinariesDir,
fileName,
source,
None,
CodeContext.Editing,
useSimpleResolution,
useFsiAuxLib,
Expand Down Expand Up @@ -2251,6 +2252,7 @@ type internal TransparentCompiler
(
fileName: string,
sourceText: ISourceText,
caret: Position option,
previewEnabled: bool option,
loadedTimeStamp: DateTime option,
otherFlags: string array option,
Expand All @@ -2268,6 +2270,7 @@ type internal TransparentCompiler
bc.GetProjectSnapshotFromScript(
fileName,
SourceTextNew.ofISourceText sourceText,
caret,
DocumentSource.FileSystem,
previewEnabled,
loadedTimeStamp,
Expand All @@ -2288,6 +2291,7 @@ type internal TransparentCompiler
(
fileName: string,
sourceText: ISourceTextNew,
caret: Position option,
documentSource: DocumentSource,
previewEnabled: bool option,
loadedTimeStamp: DateTime option,
Expand Down
Loading
Loading