8000 Update fcs 43.9.300 + Misc build/formatting fixes by TheAngryByrd · Pull Request #232 · ionide/proj-info · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update fcs 43.9.300 + Misc build/formatting fixes #232

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

Merged
merged 6 commits into from
May 17, 2025
Merged
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
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"fantomas": {
"version": "7.0.0",
"version": "7.0.1",
"commands": [
"fantomas"
],
Expand Down
8 changes: 4 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<FSharpCoreVersion>6.0.0</FSharpCoreVersion>
<!-- However for the FCS project, FSharpCoreCompilerVersion needs to match whats specified in
the FSharp.Compiler.Service dependency -->
<FSharpCoreCompilerVersion>9.0.201</FSharpCoreCompilerVersion>
<FSharpCompilerVersion>43.9.201</FSharpCompilerVersion>
<ExpectoVersion>10.2.1</ExpectoVersion>
<FSharpCoreCompilerVersion>9.0.300</FSharpCoreCompilerVersion>
<FSharpCompilerVersion>43.9.300</FSharpCompilerVersion>
Comment on lines +10 to +11
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The meat.

<ExpectoVersion>10.2.3</ExpectoVersion>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly faster expecto tests, though our tests are still slow.

<FakeVersion>6.1.3</FakeVersion>
<NuGetAuditMode>direct</NuGetAuditMode>
</PropertyGroup>
Expand Down Expand Up @@ -38,7 +38,7 @@
<PackageVersion Include="Expecto" Version="$(ExpectoVersion)" />
<PackageVersion Include="Expecto.Diff" Version="$(ExpectoVersion)" />
<PackageVersion Include="MedallionShell" Version="1.5.1" />
<PackageVersion Include="YoloDev.Expecto.TestSdk" Version="0.14.3" />
<PackageVersion Include="YoloDev.Expecto.TestSdk" Version="0.15.3" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
<!-- Build Dependencies-->
Expand Down
1 change: 1 addition & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dotnet run --project ./build/build.fsproj -- -t %*
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tired of having to remember the build syntax. Add cmd/sh variants.

6 changes: 6 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

set -eu
set -o pipefail

FAKE_DETAILED_ERRORS=true dotnet run --project ./build/build.fsproj -- -t "$@"
43 changes: 32 additions & 11 deletions build/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@ System.Environment.CurrentDirectory <- (Path.combine __SOURCE_DIRECTORY__ "..")
// --------------------------------------------------------------------------------------
let isNullOrWhiteSpace = System.String.IsNullOrWhiteSpace

let environVarAsBoolOrDefault varName defaultValue =
let truthyConsts = [
"1"
"Y"
"YES"
"T"
"TRUE"
]

try
let envvar = (Environment.environVar varName).ToUpper()

truthyConsts
|> List.exists ((=) envvar)
with _ ->
defaultValue


let isCI = lazy (environVarAsBoolOrDefault "CI" false)

let exec cmd args dir env =
let proc =
CreateProcess.fromRawCommandLine cmd args
Expand Down Expand Up @@ -49,7 +69,7 @@ let init args =
| true, v -> v
| _ -> false

let packages () = !! "src/**/*.nupkg"
let packages () = !!"src/**/*.nupkg"

Target.create
"Clean"
Expand Down Expand Up @@ -86,9 +106,15 @@ let init args =
try
exec "dotnet" $"new globaljson --force --sdk-version {tfmToSdkMap.[tfm]} --roll-forward LatestMinor" "test" Map.empty

let failedOnFocus =
if isCI.Value then
"Expecto.fail-on-focused-tests=true"
else
""

exec
"dotnet"
$"test --blame --blame-hang-timeout 60s --framework {tfm} --logger trx --logger GitHubActions -c {configuration} .\\Ionide.ProjInfo.Tests\\Ionide.ProjInfo.Tests.fsproj"
$"test --blame --blame-hang-timeout 60s --framework {tfm} --logger trx --logger GitHubActions -c %s{configuration} .\\Ionide.ProjInfo.Tests\\Ionide.ProjInfo.Tests.fsproj -- %s{failedOnFocus}"
"test"
(Map.ofSeq [ "BuildNet9", tfmToBuildNet9Map.[tfm].ToString() ])
|> ignore
Expand Down Expand Up @@ -173,17 +199,12 @@ let init args =

[<EntryPoint>]
let main args =
init (
(args
|> List.ofArray)
)
List.ofArray args
|> init

try
match args with
| [| target |] -> Target.runOrDefaultWithArguments target
| _ -> Target.runOrDefaultWithArguments "Default"

Target.runOrDefaultWithArguments "Default"
0
with e ->
printfn "%A" e
eprintfn "%A" e
1
7 changes: 5 additions & 2 deletions src/Ionide.ProjInfo.ProjectSystem/WorkspacePeek.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ module WorkspacePeek =
| Slnx
| Fsx

[<return:Struct>]
[<return: Struct>]
let inline (|HasExt|_|) (ext: string) (file: FileInfo) =
if file.Extension = ext then ValueSome() else ValueNone
if file.Extension = ext then
ValueSome()
else
ValueNone

let private partitionByChoice3 =
let foldBy (a, b, c) t =
Expand Down
38 changes: 12 additions & 26 deletions src/Ionide.ProjInfo/FsLibLog.fs
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,7 @@ module Providers =
let pushPropertyMethodCall = Expression.Call(null, pushPropertyMethod, nameParam, valueParam, destructureObjectParam)

let pushProperty =
Expression
.Lambda<Func<string, obj, bool, IDisposable>>(pushPropertyMethodCall, nameParam, valueParam, destructureObjectParam)
.Compile()
Expression.Lambda<Func<string, obj, bool, IDisposable>>(pushPropertyMethodCall, nameParam, valueParam, destructureObjectParam).Compile()

fun key value destructure -> pushProperty.Invoke(key, value, destructure)

Expand Down Expand Up @@ -581,9 +579,7 @@ module Providers =
let methodCall = Expression.Call(null, method, exrs)

let func =
Expression
.Lambda<Func<string, obj, bool, obj>>(methodCall, propertyNameParam, valueParam, destructureObjectsParam)
.Compile()
Expression.Lambda<Func<string, obj, bool, obj>>(methodCall, propertyNameParam, valueParam, destructureObjectsParam).Compile()

fun name -> func.Invoke("SourceContext", name, false)

Expand Down Expand Up @@ -646,10 +642,7 @@ module Providers =

let isEnabledMethodCall = Expression.Call(instanceCast, isEnabledMethodInfo, levelCast)

let isEnabled =
Expression
.Lambda<Func<obj, obj, bool>>(isEnabledMethodCall, instanceParam, levelParam)
.Compile()
let isEnabled = Expression.Lambda<Func<obj, obj, bool>>(isEnabledMethodCall, instanceParam, levelParam).Compile()

let writeMethodInfo =
loggerType.GetMethod(
Expand Down Expand Up @@ -688,9 +681,7 @@ module Providers =
Expression.Call(instanceCast, writeExceptionMethodInfo, levelCast, exceptionParam, messageParam, propertyValuesParam)

let writeException =
Expression
.Lambda<Action<obj, obj, exn, string, obj[]>>(writeMethodExp, instanceParam, levelParam, exceptionParam, messageParam, propertyValuesParam)
.Compile()
Expression.Lambda<Action<obj, obj, exn, string, obj[]>>(writeMethodExp, instanceParam, levelParam, exceptionParam, messageParam, propertyValuesParam).Compile()

{
Write = (fun logger level message formattedParmeters -> write.Invoke(logger, level, m 10000 essage, formattedParmeters))
Expand Down Expand Up @@ -779,9 +770,7 @@ module Providers =
let createLoggerMethodExp = Expression.Call(instanceCast, createLoggerMethodInfo, nameParam)

let createLogger =
Expression
.Lambda<Func<ILoggerFactory, string, ILogger>>(createLoggerMethodExp, instanceParam, nameParam)
.Compile()
Expression.Lambda<Func<ILoggerFactory, string, ILogger>>(createLoggerMethodExp, instanceParam, nameParam).Compile()

createLogger
|> FuncConvert.FromFunc
Expand Down Expand Up @@ -814,9 +803,7 @@ module Providers =
let isEnabledMethodCall = Expression.Call(instanceCast, isEnabledMethodInfo, levelCast)


Expression
.Lambda<Func<ILogger, MicrosoftLogLevel, bool>>(isEnabledMethodCall, instanceParam, levelParam)
.Compile()
Expression.Lambda<Func<ILogger, MicrosoftLogLevel, bool>>(isEnabledMethodCall, instanceParam, levelParam).Compile()
|> FuncConvert.FromFunc

let write, writeError =
Expand Down Expand Up @@ -909,9 +896,7 @@ module Providers =
let stateParam = Expression.Parameter(typedefof<obj>)
let beginScopeMethodCall = Expression.Call(instanceCast, beginScopeMethodInfo, stateParam)

Expression
.Lambda<Func<ILogger, obj, IDisposable>>(beginScopeMethodCall, instanceParam, stateParam)
.Compile()
Expression.Lambda<Func<ILogger, obj, IDisposable>>(beginScopeMethodCall, instanceParam, stateParam).Compile()
|> FuncConvert.FromFunc

{
Expand Down Expand Up @@ -991,12 +976,13 @@ module LogProvider =

let mutable private currentLogProvider = None

let private knownProviders = [
let private knownProviders =
[
#if !FABLE_COMPILER
(SerilogProvider.isAvailable, SerilogProvider.create)
(MicrosoftExtensionsLoggingProvider.isAvailable, MicrosoftExtensionsLoggingProvider.create)
(SerilogProvider.isAvailable, SerilogProvider.create)
(MicrosoftExtensionsLoggingProvider.isAvailable, MicrosoftExtensionsLoggingProvider.create)
#endif
]
]

/// Greedy search for first available LogProvider. Order of known providers matters.
let private resolvedLogger =
Expand Down
98 changes: 56 additions & 42 deletions src/Ionide.ProjInfo/InspectSln.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ module InspectSln =

let private tryLoadSolutionModel (slnFilePath: string) =
// use the VS library to parse the solution
match SolutionSerializers.GetSerializerByMoniker(slnFilePath) with
| null -> Error (exn $"Unsupported solution file format %s{Path.GetExtension(slnFilePath)}")
| serializer ->
try
let model = serializer.OpenAsync(slnFilePath, CancellationToken.None).GetAwaiter().GetResult()
Ok(model)
with
| ex -> Error ex
match SolutionSerializers.GetSerializerByMoniker(slnFilePath) with
| null -> Error(exn $"Unsupported solution file format %s{Path.GetExtension(slnFilePath)}")
| serializer ->
try
let model = serializer.OpenAsync(slnFilePath, CancellationToken.None).GetAwaiter().GetResult()
Ok(model)
with ex ->
Error ex

/// Parses a file on disk and returns data about its contents. Supports sln, slnf, and slnx files.
let tryParseSln (slnFilePath: string) =
Expand All @@ -74,41 +74,55 @@ module InspectSln =
normalizeDirSeparators
>> makeAbs

let parseItem (item: Model.SolutionItemModel): SolutionItem =
{
Guid = item.Id
Name = ""
Kind = SolutionItemKind.Unknown
}

let parseProject (project: Model.SolutionProjectModel): SolutionItem =
{ Guid = project.Id
Name= makeAbsoluteFromSlnDir project.FilePath
Kind = SolutionItemKind.MSBuildFormat [] // TODO: could theoretically parse configurations here
}

let parseFolder (folder: Model.SolutionFolderModel): SolutionItem =
{
Guid = folder.Id
Name = makeAbsoluteFromSlnDir folder.Path
Kind =
SolutionItemKind.Folder (
sln.SolutionItems |> Seq.filter (fun item -> not (isNull item.Parent) && item.Parent.Id = folder.Id) |> Seq.map (fun p -> parseItem p, string p.Id) |> List.ofSeq |> List.unzip)
}
let parseItem (item: Model.SolutionItemModel) : SolutionItem = {
Guid = item.Id
Name = ""
Kind = SolutionItemKind.Unknown
}

let parseProject (project: Model.SolutionProjectModel) : SolutionItem = {
Guid = project.Id
Name = makeAbsoluteFromSlnDir project.FilePath
Kind = SolutionItemKind.MSBuildFormat [] // TODO: could theoretically parse configurations here
}

let parseFolder (folder: Model.SolutionFolderModel) : SolutionItem = {
Guid = folder.Id
Name = makeAbsoluteFromSlnDir folder.Path
Kind =
SolutionItemKind.Folder(
sln.SolutionItems
|> Seq.filter (fun item ->
not (isNull item.Parent)
&& item.Parent.Id = folder.Id
)
|> Seq.map (fun p -> parseItem p, string p.Id)
|> List.ofSeq
|> List.unzip
)
}

// three kinds of items - projects, folders, items
// yield them all here
let projectsWeCareAbout =
match projectsToRead with
| None -> sln.SolutionProjects :> seq<_>
| Some filteredProjects -> sln.SolutionProjects |> Seq.filter (fun slnProject -> filteredProjects.Contains(makeAbsoluteFromSlnDir slnProject.FilePath))

let allItems =
[
yield! projectsWeCareAbout |> Seq.map parseProject
yield! sln.SolutionFolders |> Seq.map parseFolder
yield! sln.SolutionItems |> Seq.filter (fun item -> isNull item.Parent) |> Seq.map parseItem
]
| Some filteredProjects ->
sln.SolutionProjects
|> Seq.filter (fun slnProject -> filteredProjects.Contains(makeAbsoluteFromSlnDir slnProject.FilePath))

let allItems = [
yield!
projectsWeCareAbout
|> Seq.map parseProject
yield!
sln.SolutionFolders
|> Seq.map parseFolder
yield!
sln.SolutionItems
|> Seq.filter (fun item -> isNull item.Parent)
|> Seq.map parseItem
]

let data = {
Items = allItems
Expand All @@ -122,18 +136,18 @@ module InspectSln =
let options = new JsonDocumentOptions(AllowTrailingCommas = true, CommentHandling = JsonCommentHandling.Skip)
let text = JsonDocument.Parse(File.ReadAllText(slnfPath), options)
let solutionElement = text.RootElement.GetProperty("solution")
let slnPath = solutionElement.GetProperty("path").GetString();
let slnPath = solutionElement.GetProperty("path").GetString()

let projects =
solutionElement.GetProperty("projects").EnumerateArray()
|> Seq.map (fun p -> p.GetString())
|> Set.ofSeq

slnPath, projects

match tryLoadSolutionModel slnFilePath with
| Ok sln ->
Ok (parseSln sln (Some projectsToRead))
| Error ex ->
Error ex
| Ok sln -> Ok(parseSln sln (Some projectsToRead))
| Error ex -> Error ex

if slnFilePath.EndsWith(".slnf") then
parseSlnf slnFilePath
Expand Down
4 changes: 2 additions & 2 deletions src/Ionide.ProjInfo/Types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ module Types =
Properties: Property list
CustomProperties: Property list
} with

/// ResolvedTargetPath is the path to the primary reference assembly for this project.
/// For projects that produce ReferenceAssemblies, this is the path to the reference assembly.
/// For other projects, this is the same as TargetPath.
member x.ResolvedTargetPath =
defaultArg x.TargetRefPath x.TargetPath
member x.ResolvedTargetPath = defaultArg x.TargetRefPath x.TargetPath

/// Represents a `<Compile>` node within an fsproj file.
type CompileItem = {
Expand Down
7 changes: 2 additions & 5 deletions test/Ionide.ProjInfo.Tests/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ let main argv =
let toolsPath = Init.init (IO.DirectoryInfo Environment.CurrentDirectory) None

let args = [
CLIArguments.Printer (TestPrinters.summaryPrinter defaultConfig.printer)
CLIArguments.Printer(TestPrinters.summaryPrinter defaultConfig.printer)
CLIArguments.Verbosity LogLevel.Verbose
]

Tests.runTestsWithCLIArgs
args
argv
tests
Tests.runTestsWithCLIArgs args argv tests
0