Skip to content

Commit

Permalink
Fixed merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ncave committed Dec 8, 2023
1 parent cb453d2 commit 60036ee
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"name": "FCS Test",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/artifacts/bin/fcs-test/Debug/net7.0/fcs-test.dll",
"program": "${workspaceFolder}/artifacts/bin/fcs-test/Debug/net8.0/fcs-test.dll",
"args": [],
"cwd": "${workspaceFolder}/fcs/fcs-test",
"console": "internalConsole",
Expand Down
2 changes: 0 additions & 2 deletions buildtools/AssemblyCheck/AssemblyCheck.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<UseAppHost Condition="'$(DotNetBuildFromSource)' == 'true'">false</UseAppHost>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions buildtools/buildtools.targets
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
BeforeTargets="CoreCompile">

<PropertyGroup>
<FsLexPath Condition="'$(FsLexPath)' == ''">$(ArtifactsDir)\bin\fslex\Release\net7.0\fslex.dll</FsLexPath>
<FsLexPath Condition="'$(FsLexPath)' == ''">$(ArtifactsDir)\bin\fslex\Release\net8.0\fslex.dll</FsLexPath>
</PropertyGroup>

<!-- Create the output directory -->
Expand All @@ -44,7 +44,7 @@
BeforeTargets="CoreCompile">

<PropertyGroup>
<FsYaccPath Condition="'$(FsYaccPath)' == ''">$(ArtifactsDir)\bin\fsyacc\Release\net7.0\fsyacc.dll</FsYaccPath>
<FsYaccPath Condition="'$(FsYaccPath)' == ''">$(ArtifactsDir)\bin\fsyacc\Release\net8.0\fsyacc.dll</FsYaccPath>
</PropertyGroup>

<!-- Create the output directory -->
Expand Down
2 changes: 0 additions & 2 deletions buildtools/fslex/fslex.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<DefineConstants>INTERNALIZED_FSLEXYACC_RUNTIME;$(DefineConstants)</DefineConstants>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<UseAppHost Condition="'$(DotNetBuildFromSource)' == 'true'">false</UseAppHost>
<RollForward Condition="'$(BUILDING_USING_DOTNET)' == 'true'">LatestMajor</RollForward>
Expand Down
2 changes: 0 additions & 2 deletions buildtools/fsyacc/fsyacc.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<DefineConstants>INTERNALIZED_FSLEXYACC_RUNTIME;$(DefineConstants)</DefineConstants>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<UseAppHost Condition="'$(DotNetBuildFromSource)' == 'true'">false</UseAppHost>
<RollForward Condition="'$(BUILDING_USING_DOTNET)' == 'true'">LatestMajor</RollForward>
Expand Down
8 changes: 4 additions & 4 deletions fcs/fcs-test/fcs-test.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
</PropertyGroup>

Expand All @@ -19,9 +19,9 @@
</ItemGroup>

<ItemGroup>
<!-- <PackageReference Include="FSharp.Core" Version="7.0.0" /> -->
<PackageReference Include="Buildalyzer" Version="4.1.6" />
<PackageReference Include="Fable.Core" Version="4.0.0-*" />
<!-- <PackageReference Include="FSharp.Core" Version="8.0.0" /> -->
<PackageReference Include="Buildalyzer" Version="5.0.1" />
<PackageReference Include="Fable.Core" Version="4.1.0" />
<PackageReference Include="Fable.Import.Browser" Version="1.4.0" />
</ItemGroup>
</Project>
22 changes: 15 additions & 7 deletions fcs/service_slim.fs
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,14 @@ module internal ParseAndCheck =
// restore all cached typecheck entries above file
cachedAbove |> Array.iter (fun (key, value) -> compilerState.checkCache.TryAdd(key, value) |> ignore)

let ParseFile (fileName: string, sourceHash: int, source: Lazy<string>, parsingOptions: FSharpParsingOptions, compilerState) =
let ParseFile (fileName: string, sourceHash: int, source: Lazy<string>, parsingOptions: FSharpParsingOptions, compilerState, ct) =
let parseCacheKey = fileName, sourceHash
compilerState.parseCache.GetOrAdd(parseCacheKey, fun _ ->
ClearStaleCache(fileName, parsingOptions, compilerState)
let sourceText = SourceText.ofString source.Value
let parseErrors, parseTreeOpt, anyErrors = ParseAndCheckFile.parseFile (sourceText, fileName, parsingOptions, userOpName, suggestNamesForErrors, captureIdentifiersWhenParsing)
let flatErrors = compilerState.tcConfig.flatErrors
let parseErrors, parseTreeOpt, anyErrors =
ParseAndCheckFile.parseFile (sourceText, fileName, parsingOptions, userOpName, suggestNamesForErrors, flatErrors, captureIdentifiersWhenParsing, ct)
let dependencyFiles = [||] // interactions have no dependencies
FSharpParseFileResults (parseErrors, parseTreeOpt, anyErrors, dependencyFiles) )

Expand All @@ -213,7 +215,9 @@ module internal ParseAndCheck =
|> Cancellable.runWithoutCancellation

let fileName = parseResults.FileName
let tcErrors = DiagnosticHelpers.CreateDiagnostics (diagnosticsOptions, false, fileName, (capturingLogger.GetDiagnostics()), suggestNamesForErrors)
let flatErrors = compilerState.tcConfig.flatErrors
let parseDiagnostics = capturingLogger.GetDiagnostics()
let tcErrors = DiagnosticHelpers.CreateDiagnostics (diagnosticsOptions, false, fileName, parseDiagnostics, suggestNamesForErrors, flatErrors, None)
(tcResult, tcErrors), (tcState, moduleNamesDict)

let CheckFile (projectFileName: string, parseResults: FSharpParseFileResults, tcState: TcState, moduleNamesDict: ModuleNamesDict, compilerState) =
Expand Down Expand Up @@ -295,17 +299,19 @@ type InteractiveChecker internal (compilerStateCache) =
/// Compile project to file. If project has already been type checked,
/// check results will be taken from the cache.
member _.Compile(fileNames: string[], sourceReader: string -> int * Lazy<string>, outFile: string) = async {
let! ct = Async.CancellationToken
let! compilerState = compilerStateCache.Get()
let parsingOptions = FSharpParsingOptions.FromTcConfig(compilerState.tcConfig, fileNames, false)
let parseResults = fileNames |> Array.map (fun fileName ->
let sourceHash, source = sourceReader fileName
ParseFile(fileName, sourceHash, source, parsingOptions, compilerState))
ParseFile(fileName, sourceHash, source, parsingOptions, compilerState, ct))

let (tcState, topAttrs, tcImplFiles, _tcEnvAtEnd, _moduleNamesDict, _tcErrors) =
TypeCheckClosedInputSet (parseResults, compilerState.tcInitialState, compilerState, None)

let ctok = CompilationThreadToken()
let errors, diagnosticsLogger, _loggerProvider = CompileHelpers.mkCompilationDiagnosticsHandlers()
let flatErrors = compilerState.tcConfig.flatErrors
let errors, diagnosticsLogger, _loggerProvider = CompileHelpers.mkCompilationDiagnosticsHandlers(flatErrors)
let exitCode =
CompileHelpers.tryCompile diagnosticsLogger (fun exiter ->
CompileFromTypedAst (ctok, compilerState.tcGlobals, compilerState.tcImports, tcState.Ccu,
Expand All @@ -319,6 +325,7 @@ type InteractiveChecker internal (compilerStateCache) =
/// Already parsed files will be cached so subsequent compilations will be faster.
member _.ParseAndCheckProject (projectFileName: string, fileNames: string[], sourceReader: string -> int * Lazy<string>,
?lastFile: string, ?subscriber: FSharpImplementationFileContents -> unit) = async {
let! ct = Async.CancellationToken
let! compilerState = compilerStateCache.Get()
// parse files
let parsingOptions = FSharpParsingOptions.FromTcConfig(compilerState.tcConfig, fileNames, false)
Expand All @@ -332,7 +339,7 @@ type InteractiveChecker internal (compilerStateCache) =

let parseFile fileName =
let sourceHash, source = sourceReader fileName
ParseFile(fileName, sourceHash, source, parsingOptions, compilerState)
ParseFile(fileName, sourceHash, source, parsingOptions, compilerState, ct)

// Don't parallelize if we have cached files, as it would create issues with invalidation
if compilerState.parseCache.Count = 0 then
Expand All @@ -358,6 +365,7 @@ type InteractiveChecker internal (compilerStateCache) =
/// up to and including the file requested. Returns parse and typecheck results containing
/// name resolutions and symbol uses for the file requested only, so intellisense etc. works.
member _.ParseAndCheckFileInProject (projectFileName: string, fileNames: string[], sourceReader: string -> int * Lazy<string>, fileName: string) = async {
let! ct = Async.CancellationToken
let! compilerState = compilerStateCache.Get()

// get files before file
Expand All @@ -368,7 +376,7 @@ type InteractiveChecker internal (compilerStateCache) =
let parsingOptions = FSharpParsingOptions.FromTcConfig(compilerState.tcConfig, fileNames, false)
let parseFile fileName =
let sourceHash, source = sourceReader fileName
ParseFile (fileName, sourceHash, source, parsingOptions, compilerState)
ParseFile (fileName, sourceHash, source, parsingOptions, compilerState, ct)
let parseResults = fileNamesBeforeFile |> Array.map parseFile

// type check files before file
Expand Down
2 changes: 2 additions & 0 deletions src/Compiler/Service/service.fs
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,15 @@ module CompileHelpers =

diagnostics.ToArray(), result

#if !FABLE_CLI
let setOutputStreams execute =
// Set the output streams, if requested
match execute with
| Some(writer, error) ->
Console.SetOut writer
Console.SetError error
| None -> ()
#endif

type SourceTextHash = int64
type CacheStamp = int64
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Service/service.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ open FSharp.Compiler.DiagnosticsLogger
open FSharp.Compiler.Driver

module internal CompileHelpers =
val mkCompilationDiagnosticsHandlers: unit -> ResizeArray<FSharpDiagnostic> * DiagnosticsLogger * IDiagnosticsLoggerProvider
val mkCompilationDiagnosticsHandlers: bool -> ResizeArray<FSharpDiagnostic> * DiagnosticsLogger * IDiagnosticsLoggerProvider
val tryCompile: DiagnosticsLogger -> (StopProcessingExiter -> unit) -> int

[<Experimental "This type is experimental and likely to be removed in the future.">]
Expand Down

0 comments on commit 60036ee

Please sign in to comment.