Skip to content
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
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"rollForward": false
},
"fsharp-analyzers": {
"version": "0.35.0",
"version": "0.37.2",
"commands": [
"fsharp-analyzers"
],
Expand Down
19 changes: 14 additions & 5 deletions .paket/Paket.Restore.targets
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,9 @@
<OmitContent Condition="%(PaketReferencesFileLinesInfo.Splits) &gt;= 7">$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[6])</OmitContent>
<ImportTargets Condition="%(PaketReferencesFileLinesInfo.Splits) &gt;= 8">$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[7])</ImportTargets>
<Aliases Condition="%(PaketReferencesFileLinesInfo.Splits) &gt;= 9">$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[8])</Aliases>
<ReferenceCondition Condition="%(PaketReferencesFileLinesInfo.Splits) &gt;= 10">$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[9])</ReferenceCondition>
</PaketReferencesFileLinesInfo>
<PackageReference Condition=" '$(ManagePackageVersionsCentrally)' != 'true' Or '%(PaketReferencesFileLinesInfo.Reference)' == 'Direct' " Include="%(PaketReferencesFileLinesInfo.PackageName)">
<PackageReference Condition=" ('$(ManagePackageVersionsCentrally)' != 'true' Or '%(PaketReferencesFileLinesInfo.Reference)' == 'Direct') AND ('%(PaketReferencesFileLinesInfo.ReferenceCondition)' == 'true' Or $(%(PaketReferencesFileLinesInfo.ReferenceCondition)) == 'true')" Include="%(PaketReferencesFileLinesInfo.PackageName)">
<Version Condition=" '$(ManagePackageVersionsCentrally)' != 'true' ">%(PaketReferencesFileLinesInfo.PackageVersion)</Version>
<PrivateAssets Condition=" ('%(PaketReferencesFileLinesInfo.AllPrivateAssets)' == 'true') Or ('$(PackAsTool)' == 'true') ">All</PrivateAssets>
<ExcludeAssets Condition=" %(PaketReferencesFileLinesInfo.CopyLocal) == 'false' or %(PaketReferencesFileLinesInfo.AllPrivateAssets) == 'exclude'">runtime</ExcludeAssets>
Expand All @@ -251,10 +252,8 @@
<Aliases Condition=" %(PaketReferencesFileLinesInfo.Aliases) != ''">%(PaketReferencesFileLinesInfo.Aliases)</Aliases>
<Publish Condition=" '$(PackAsTool)' == 'true' ">true</Publish>
<AllowExplicitVersion>true</AllowExplicitVersion>

</PackageReference>

<PackageVersion Include="%(PaketReferencesFileLinesInfo.PackageName)">
<PackageVersion Condition="('$(ManagePackageVersionsCentrally)' != 'true' Or '%(PaketReferencesFileLinesInfo.Reference)' == 'Direct') AND ('%(PaketReferencesFileLinesInfo.ReferenceCondition)' == 'true' Or $(%(PaketReferencesFileLinesInfo.ReferenceCondition)) == 'true')" Include="%(PaketReferencesFileLinesInfo.PackageName)">
<Version>%(PaketReferencesFileLinesInfo.PackageVersion)</Version>
</PackageVersion>
</ItemGroup>
Expand Down Expand Up @@ -319,7 +318,17 @@
</ItemGroup>

<Error Text="Error Because of PAKET_ERROR_ON_MSBUILD_EXEC (not calling fix-nuspecs)" Condition=" '$(PAKET_ERROR_ON_MSBUILD_EXEC)' == 'true' " />
<Exec Condition="@(_NuspecFiles) != ''" Command='$(PaketCommand) fix-nuspecs files "@(_NuspecFiles)" project-file "$(PaketProjectFile)" ' />
<Exec Condition="@(_NuspecFiles) != ''" Command='$(PaketCommand) show-conditions -s' ConsoleToMSBuild="true" StandardOutputImportance="low">
<Output TaskParameter="ConsoleOutput" ItemName="_ConditionProperties"/>
</Exec>
<ItemGroup>
<_DefinedConditionProperties Include="@(_ConditionProperties)" Condition="$(%(Identity)) == 'true'"/>
</ItemGroup>
<PropertyGroup>
<_ConditionsParameter></_ConditionsParameter>
<_ConditionsParameter Condition="@(_DefinedConditionProperties) != ''">--conditions @(_DefinedConditionProperties)</_ConditionsParameter>
</PropertyGroup>
<Exec Condition="@(_NuspecFiles) != ''" Command='$(PaketCommand) fix-nuspecs files "@(_NuspecFiles)" project-file "$(PaketProjectFile)" $(_ConditionsParameter)' />
<Error Condition="@(_NuspecFiles) == ''" Text='Could not find nuspec files in "$(AdjustedNuspecOutputPath)" (Version: "$(PackageVersion)"), therefore we cannot call "paket fix-nuspecs" and have to error out!' />

<ConvertToAbsolutePath Condition="@(_NuspecFiles) != ''" Paths="@(_NuspecFiles)">
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Changed

- Update FSharp.Analyzers.SDK to `0.37.2`, which bumps FSharp.Core to `10.1.201` and FSharp.Compiler.Service to `43.12.201`, and adapt to the corresponding FCS syntax-tree API changes.

### Fixed

- [Disable inline values by default to restore pipeline hints](https://github.com/ionide/FsAutoComplete/pull/1456) - `InlineValueProvider` is no longer advertised by default, restoring pipeline hints during normal editing (closes [#1214](https://github.com/ionide/FsAutoComplete/issues/1214))
Expand Down
2 changes: 1 addition & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ nuget Microsoft.Build.Utilities.Core >= 17.4 copy_local:false
nuget Microsoft.Build.Tasks.Core >= 17.4 copy_local: false
nuget Nuget.Frameworks >= 6.3 copy_local: false
nuget Microsoft.CodeAnalysis
nuget FSharp.Analyzers.SDK 0.35.0
nuget FSharp.Analyzers.SDK 0.37.2
nuget ICSharpCode.Decompiler
nuget Mono.Cecil >= 0.11.4
nuget FSharpLint.Core
Expand Down
12 changes: 6 additions & 6 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ NUGET
FParsec (1.1.1) - restriction: || (== net10.0) (== net8.0) (== net9.0) (&& (== netstandard2.0) (>= net5.0)) (&& (== netstandard2.1) (>= net5.0))
FSharp.Core (>= 4.3.4)
FSharp.Analyzers.Build (0.3)
FSharp.Analyzers.SDK (0.35)
FSharp.Compiler.Service (43.10.101) - restriction: || (== net10.0) (== net8.0) (== net9.0) (&& (== netstandard2.0) (>= net8.0)) (&& (== netstandard2.1) (>= net8.0))
FSharp.Core (10.0.101) - restriction: || (== net10.0) (== net8.0) (== net9.0) (&& (== netstandard2.0) (>= net8.0)) (&& (== netstandard2.1) (>= net8.0))
FSharp.Analyzers.SDK (0.37.2)
FSharp.Compiler.Service (>= 43.12.201) - restriction: || (== net10.0) (== net8.0) (== net9.0) (&& (== netstandard2.0) (>= net8.0)) (&& (== netstandard2.1) (>= net8.0))
FSharp.Core (10.1.201) - restriction: || (== net10.0) (== net8.0) (== net9.0) (&& (== netstandard2.0) (>= net8.0)) (&& (== netstandard2.1) (>= net8.0))
McMaster.NETCore.Plugins (>= 2.0) - restriction: || (== net10.0) (== net8.0) (== net9.0) (&& (== netstandard2.0) (>= net8.0)) (&& (== netstandard2.1) (>= net8.0))
Microsoft.Extensions.Logging.Abstractions (>= 6.0) - restriction: || (== net10.0) (== net8.0) (== net9.0) (&& (== netstandard2.0) (>= net8.0)) (&& (== netstandard2.1) (>= net8.0))
FSharp.Compiler.Service (43.10.101)
FSharp.Core (10.0.101)
FSharp.Compiler.Service (43.12.201)
FSharp.Core (10.1.201)
System.Buffers (>= 4.6)
System.Collections.Immutable (>= 9.0)
System.Diagnostics.DiagnosticSource (>= 9.0)
Expand All @@ -72,7 +72,7 @@ NUGET
Fsharp.Control.Reactive (5.0.5) - restriction: || (== net10.0) (== net8.0) (== net9.0) (&& (== netstandard2.0) (>= net8.0)) (&& (== netstandard2.1) (>= net8.0))
FSharp.Core (>= 4.7.2)
System.Reactive (>= 5.0 < 6.0)
FSharp.Core (10.0.101)
FSharp.Core (10.1.201)
FSharp.Data.Adaptive (1.2.18)
FSharp.Core (>= 4.7)
System.Reflection.Emit.Lightweight (>= 4.6)
Expand Down
23 changes: 20 additions & 3 deletions src/FsAutoComplete.Core/FCSPatches.fs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ module SyntaxTreeOps =

| SynExpr.Match(expr = e; clauses = cl) -> walkExpr e || walkMatchClauses cl

| SynExpr.LetOrUse(bindings = bs; body = e) -> walkBinds bs || walkExpr e
| SynExpr.LetOrUse letOrUse -> walkBinds letOrUse.Bindings || walkExpr letOrUse.Body

| SynExpr.TryWith(tryExpr = e; withCases = cl) -> walkExpr e || walkMatchClauses cl

Expand Down Expand Up @@ -243,15 +243,32 @@ type LanguageVersionShim(versionText: string) =
static let LanguageVersionTy =
lazy (Type.GetType("FSharp.Compiler.Features+LanguageVersion, FSharp.Compiler.Service"))

static let ctor = lazy (LanguageVersionTy.Value.GetConstructor([| typeof<string> |]))
// FCS 43.12 changed the LanguageVersion constructor from `(string)` to
// `(string, disabledFeaturesArray: _ option)`, so we can't look it up by an exact
// signature. Find the constructor whose first parameter is the version string instead.
static let ctor =
lazy
(LanguageVersionTy.Value.GetConstructors()
|> Array.find (fun c ->
let ps = c.GetParameters()
ps.Length >= 1 && ps.[0].ParameterType = typeof<string>))

static let isPreviewEnabled =
lazy (ReflectionDelegates.createGetter<bool> LanguageVersionTy.Value "IsPreviewEnabled")

static let supportsFeature =
lazy (ReflectionDelegates.createFuncArity1<bool> LanguageVersionTy.Value LanguageFeatureShim.Type "SupportsFeature")

let realLanguageVersion = ctor.Value.Invoke([| versionText |])
// Pass the version text as the first argument and null (= None / default) for any
// additional optional parameters the constructor may have gained.
let realLanguageVersion =
let c = ctor.Value

let args =
c.GetParameters()
|> Array.mapi (fun i _ -> if i = 0 then box versionText else null)

c.Invoke(args)

member x.IsPreviewEnabled = isPreviewEnabled.Value realLanguageVersion

Expand Down
2 changes: 1 addition & 1 deletion src/FsAutoComplete.Core/InlayHints.fs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ let tryGetExplicitTypeInfo (text: IFSACSourceText, ast: ParsedInput) (pos: Posit
member visitor.VisitPat(path, defaultTraverse, pat) =
let invalidPositionForTypeAnnotation (path: SyntaxNode list) =
match path with
| SyntaxNode.SynExpr(SynExpr.LetOrUse(isUse = true)) :: _ ->
| SyntaxNode.SynExpr(SynExpr.LetOrUse letOrUse) :: _ when letOrUse.IsUse ->
// use! value =
true
| _ -> false
Expand Down
16 changes: 8 additions & 8 deletions src/FsAutoComplete.Core/TestAdapter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ let getExpectoTests (ast: ParsedInput) : TestAdapterEntry<range> list =
visitExpr parent cond
visitExpr parent trueBranch
falseBranchOpt |> Option.iter (visitExpr parent)
| SynExpr.LetOrUse(bindings = bindings; body = body) ->
visitBindings parent bindings
visitExpr parent body
| SynExpr.LetOrUse letOrUse ->
visitBindings parent letOrUse.Bindings
visitExpr parent letOrUse.Body
| SynExpr.Record(_, _, fields, _) ->
fields
|> List.choose (fun (SynExprRecordField(expr = expr)) -> expr)
Expand All @@ -237,7 +237,7 @@ let getExpectoTests (ast: ParsedInput) : TestAdapterEntry<range> list =
let rec visitDeclarations prefix decls =
for declaration in decls do
match declaration with
| SynModuleDecl.Let(_, bindings, _) -> visitBindings prefix bindings
| SynModuleDecl.Let(bindings = bindings) -> visitBindings prefix bindings
| SynModuleDecl.NestedModule(decls = decls) -> visitDeclarations prefix decls
| _ -> ()

Expand Down Expand Up @@ -289,7 +289,7 @@ let getNUnitTest (ast: ParsedInput) : TestAdapterEntry<range> list =
let rec visitMember (parent: TestAdapterEntry<range>) =
function
| SynMemberDefn.Member(b, _) -> visitBinding parent b
| SynMemberDefn.LetBindings(bindings, _, _, _) ->
| SynMemberDefn.LetBindings(bindings = bindings) ->
for b in bindings do
visitBinding parent b
| SynMemberDefn.NestedType(typeDef, _, _) -> visitTypeDef parent typeDef
Expand Down Expand Up @@ -366,7 +366,7 @@ let getNUnitTest (ast: ParsedInput) : TestAdapterEntry<range> list =

for declaration in decls do
match declaration with
| SynModuleDecl.Let(_, bindings, _) ->
| SynModuleDecl.Let(bindings = bindings) ->
for b in bindings do
visitBinding parent b
| SynModuleDecl.NestedModule(moduleInfo = ci; decls = decls) ->
Expand Down Expand Up @@ -463,7 +463,7 @@ let getXUnitTest ast : TestAdapterEntry<range> list =
let rec visitMember (parent: TestAdapterEntry<range>) =
function
| SynMemberDefn.Member(b, _) -> visitBinding parent b
| SynMemberDefn.LetBindings(bindings, _, _, _) ->
| SynMemberDefn.LetBindings(bindings = bindings) ->
for b in bindings do
visitBinding parent b
| SynMemberDefn.NestedType(typeDef, _, _) -> visitTypeDef parent typeDef
Expand Down Expand Up @@ -540,7 +540,7 @@ let getXUnitTest ast : TestAdapterEntry<range> list =

for declaration in decls do
match declaration with
| SynModuleDecl.Let(_, bindings, _) ->
| SynModuleDecl.Let(bindings = bindings) ->
for b in bindings do
visitBinding parent b
| SynModuleDecl.NestedModule(moduleInfo = ci; decls = decls) ->
Expand Down
10 changes: 5 additions & 5 deletions src/FsAutoComplete.Core/UnionPatternMatchCaseGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ let private tryFindPatternMatchExprInParsedInput (pos: Position) (parsedInput: P
getIfPosInRange decl.Range (fun () ->
match decl with
| SynModuleDecl.Exception(SynExceptionDefn(members = synMembers), _) -> List.tryPick walkSynMemberDefn synMembers
| SynModuleDecl.Let(_isRecursive, bindings, _range) -> List.tryPick walkBinding bindings
| SynModuleDecl.Let(bindings = bindings) -> List.tryPick walkBinding bindings
| SynModuleDecl.ModuleAbbrev(_lhs, _rhs, _range) -> None
| SynModuleDecl.NamespaceFragment(fragment) -> walkSynModuleOrNamespace fragment
| SynModuleDecl.NestedModule(decls = modules) -> List.tryPick walkSynModuleDecl modules
Expand Down Expand Up @@ -119,7 +119,7 @@ let private tryFindPatternMatchExprInParsedInput (pos: Position) (parsedInput: P
| SynMemberDefn.Member(binding, _range) -> walkBinding binding
| SynMemberDefn.NestedType(typeDef, _access, _range) -> walkSynTypeDefn typeDef
| SynMemberDefn.ValField(_field, _range) -> None
| SynMemberDefn.LetBindings(bindings, _isStatic, _isRec, _range) -> List.tryPick walkBinding bindings
| SynMemberDefn.LetBindings(bindings = bindings) -> List.tryPick walkBinding bindings
| SynMemberDefn.GetSetMember(_get, _set, _range, _) -> None
| SynMemberDefn.Open _
| SynMemberDefn.ImplicitInherit _
Expand Down Expand Up @@ -230,9 +230,9 @@ let private tryFindPatternMatchExprInParsedInput (pos: Position) (parsedInput: P

| SynExpr.TypeApp(synExpr, _, _synTypeList, _commas, _, _, _range) -> walkExpr synExpr

| SynExpr.LetOrUse(body = synExpr; bindings = synBindingList) ->
walkExpr synExpr
|> Option.orElseWith (fun _ -> List.tryPick walkBinding synBindingList)
| SynExpr.LetOrUse letOrUse ->
walkExpr letOrUse.Body
|> Option.orElseWith (fun _ -> List.tryPick walkBinding letOrUse.Bindings)

| SynExpr.TryWith(tryExpr = synExpr) -> walkExpr synExpr

Expand Down
10 changes: 5 additions & 5 deletions src/FsAutoComplete.Core/UntypedAstUtils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,9 @@ module Syntax =
| SynExpr.TypeApp(e, _, tys, _, _, _, _) ->
List.iter walkType tys
walkExpr e
| SynExpr.LetOrUse(bindings = bindings; body = e; range = _) ->
List.iter walkBinding bindings
walkExpr e
| SynExpr.LetOrUse letOrUse ->
List.iter walkBinding letOrUse.Bindings
walkExpr letOrUse.Body
| SynExpr.TryWith(tryExpr = e; withCases = clauses; range = _) ->
List.iter walkClause clauses
walkExpr e
Expand Down Expand Up @@ -445,7 +445,7 @@ module Syntax =
| SynMemberDefn.ImplicitInherit(inheritType = t; inheritArgs = e) ->
walkType t
walkExpr e
| SynMemberDefn.LetBindings(bindings, _, _, _) -> List.iter walkBinding bindings
| SynMemberDefn.LetBindings(bindings = bindings) -> List.iter walkBinding bindings
| SynMemberDefn.Interface(t, _, members, _) ->
walkType t
members |> Option.iter (List.iter walkMember)
Expand Down Expand Up @@ -531,7 +531,7 @@ module Syntax =
| SynModuleDecl.NestedModule(info, _, modules, _, _, _) ->
walkComponentInfo info
List.iter walkSynModuleDecl modules
| SynModuleDecl.Let(_, bindings, _) -> List.iter walkBinding bindings
| SynModuleDecl.Let(bindings = bindings) -> List.iter walkBinding bindings
| SynModuleDecl.Expr(expr, _) -> walkExpr expr
| SynModuleDecl.Types(types, _) -> List.iter walkTypeDefn types
| SynModuleDecl.Attributes(attributes = AllAttrs attrs; range = _) -> List.iter walkAttribute attrs
Expand Down
6 changes: 3 additions & 3 deletions src/FsAutoComplete/LspServers/AdaptiveServerState.fs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ type AdaptiveState
if enableAnalyzers then
let mutable assemblyLoadStats =
{ AnalyzerAssemblies = 0
Analyzers = 0
AnalyzerNames = []
FailedAssemblies = 0 }

let excludeInclude =
Expand All @@ -287,7 +287,7 @@ type AdaptiveState

assemblyLoadStats <-
{ AnalyzerAssemblies = assemblyLoadStats.AnalyzerAssemblies + stats.AnalyzerAssemblies
Analyzers = assemblyLoadStats.Analyzers + stats.Analyzers
AnalyzerNames = assemblyLoadStats.AnalyzerNames @ stats.AnalyzerNames
FailedAssemblies = assemblyLoadStats.FailedAssemblies + stats.FailedAssemblies }


Expand All @@ -298,7 +298,7 @@ type AdaptiveState

assemblyLoadStats <-
{ AnalyzerAssemblies = assemblyLoadStats.AnalyzerAssemblies + stats.AnalyzerAssemblies
Analyzers = assemblyLoadStats.Analyzers + stats.Analyzers
AnalyzerNames = assemblyLoadStats.AnalyzerNames @ stats.AnalyzerNames
FailedAssemblies = assemblyLoadStats.FailedAssemblies + stats.FailedAssemblies }

)
Expand Down
1 change: 0 additions & 1 deletion test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3684,7 +3684,6 @@ let tests textFactory state =
AddExplicitTypeAnnotationTests.tests state
AdjustConstantTests.tests state
ToInterpolatedStringTests.tests state
ToInterpolatedStringTests.unavailableTests state
addMissingEqualsToTypeDefinitionTests state
addMissingFunKeywordTests state
addMissingInstanceMemberTests state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ open Utils.CursorbasedTests
open FsAutoComplete.CodeFix
open FsAutoComplete.FCSPatches

let langVersion60Config =
// NOTE: language versions <= 7.0 are "out of support" in FCS 43.12+ and cause the
// project to fail to load, so we pin to 8.0 (LTS), which still supports string interpolation.
let langVersion80Config =
{ defaultConfigDto with
FSIExtraSharedParameters = Some [| "--langversion:6.0" |] }
FSIExtraSharedParameters = Some [| "--langversion:8.0" |] }

let tests state =
serverTestList (nameof ToInterpolatedString) state langVersion60Config None (fun server ->
serverTestList (nameof ToInterpolatedString) state langVersion80Config None (fun server ->
[ let selectCodeFix = CodeFix.withTitle ToInterpolatedString.title

testCaseAsync "simple integer string format"
Expand Down Expand Up @@ -341,6 +343,17 @@ let tests state =
Expect.equal true (languageVersion.SupportsFeature LanguageFeatureShim) ""
}

// String interpolation was introduced in F# 5.0, so an older language version must report
// it as unsupported. This replaces the former `unavailableTests` server test: every language
// version still supported by FCS now includes the feature, so the negative case can only be
// exercised at the unit level (constructing the shim does not require the version to compile).
testCaseAsync "Reflecting into LanguageVersion - feature unsupported in older version"
<| async {
let feature = LanguageFeatureShim("StringInterpolation")
let languageVersion = LanguageVersionShim("4.7")
Expect.equal false (languageVersion.SupportsFeature feature) ""
}

testCaseAsync "Multiline applications are not supported"
<| CodeFix.checkNotApplicable
server
Expand All @@ -353,22 +366,3 @@ let tests state =
selectCodeFix

])

let langVersion47Config =
{ defaultConfigDto with
FSIExtraSharedParameters = Some [| "--langversion:4.7" |] }

let unavailableTests state =
serverTestList $"unavailable {(nameof ToInterpolatedString)}" state langVersion47Config None (fun server ->
[ let selectCodeFix = CodeFix.withTitle ToInterpolatedString.title

testCaseAsync "codefix not available for langversion"
<| CodeFix.checkNotApplicable
server
"""
let a = sprintf$0 "Hey %i" 3
"""
Diagnostics.acceptAll
selectCodeFix

])
Loading