diff --git a/Documentation/src/analyzer-rules/analyzer-rules.md b/Documentation/src/analyzer-rules/analyzer-rules.md index 594b7849e..8fe4263d1 100644 --- a/Documentation/src/analyzer-rules/analyzer-rules.md +++ b/Documentation/src/analyzer-rules/analyzer-rules.md @@ -35,7 +35,7 @@ contains a rule. | [λ0004](./λ0004.md) | Error | The `default` literal is wrapped by an implicit conversion | | [λ0005](./λ0005.md) | Error | A `null` literal is passed to `Option`, `Result` or `Either` | | [λ1009](./λ1009.md) | Error | Do not use `default` to instantiate this type (moved from `Funcky.Analyzers` in 3.7.0) | -| [λ1010](./λ1010.md) | Error | An option has either zero or one elements (needs Roslyn 4.4, i.e. the .NET 7 SDK or newer) | +| [λ1010](./λ1010.md) | Error | An option has either zero or one elements | ## Funcky.Analyzers diff --git a/Funcky.Analyzers/Funcky.Analyzers.CodeFixes/Funcky.Analyzers.CodeFixes.csproj b/Funcky.Analyzers/Funcky.Analyzers.CodeFixes/Funcky.Analyzers.CodeFixes.csproj index 5e8e0cac3..6dc3d1ed4 100644 --- a/Funcky.Analyzers/Funcky.Analyzers.CodeFixes/Funcky.Analyzers.CodeFixes.csproj +++ b/Funcky.Analyzers/Funcky.Analyzers.CodeFixes/Funcky.Analyzers.CodeFixes.csproj @@ -1,6 +1,6 @@ - 4.4.0 + 4.14.0 diff --git a/Funcky.Analyzers/Funcky.Analyzers.Package/Funcky.Analyzers.Package.csproj b/Funcky.Analyzers/Funcky.Analyzers.Package/Funcky.Analyzers.Package.csproj index f0f4f8007..f6ec27871 100644 --- a/Funcky.Analyzers/Funcky.Analyzers.Package/Funcky.Analyzers.Package.csproj +++ b/Funcky.Analyzers/Funcky.Analyzers.Package/Funcky.Analyzers.Package.csproj @@ -12,7 +12,7 @@ Funcky.Analyzers - 2.1.0 + 3.0.0 Analyzers to guide to the correct usage of Funcky. funcky, analyzers, roslyn true diff --git a/Funcky.Analyzers/Funcky.Analyzers.Package/buildTransitive/Funcky.Analyzers.targets b/Funcky.Analyzers/Funcky.Analyzers.Package/buildTransitive/Funcky.Analyzers.targets index b2fe49519..1503b01ef 100644 --- a/Funcky.Analyzers/Funcky.Analyzers.Package/buildTransitive/Funcky.Analyzers.targets +++ b/Funcky.Analyzers/Funcky.Analyzers.Package/buildTransitive/Funcky.Analyzers.targets @@ -4,7 +4,7 @@ Condition="'$(SupportsRoslynComponentVersioning)' != 'true'" AfterTargets="ResolvePackageDependenciesForBuild;ResolveNuGetPackageAssets"> + Text="Funcky.Analyzers requires at least Roslyn 4.14 i.e. Visual Studio 2022 17.14 / .NET SDK 9.0.300" /> diff --git a/Funcky.Analyzers/Funcky.Analyzers/ExtensionForms/ExtensionMemberSupport.cs b/Funcky.Analyzers/Funcky.Analyzers/ExtensionForms/ExtensionMemberSupport.cs index f22fbb807..e6c398cf8 100644 --- a/Funcky.Analyzers/Funcky.Analyzers/ExtensionForms/ExtensionMemberSupport.cs +++ b/Funcky.Analyzers/Funcky.Analyzers/ExtensionForms/ExtensionMemberSupport.cs @@ -31,7 +31,7 @@ public static bool HasStaticMember(INamedTypeSymbol type, string name) .OfType() .Any(method => method.IsStatic && !method.IsExtensionMethod); - /// The static class an extension member or classic extension method is declared in. Roslyn 4.4 has no notion of + /// The static class an extension member or classic extension method is declared in. Roslyn 4.14 has no notion of /// an extension block, so any type nested in a static class is taken for one. public static INamedTypeSymbol? DeclaringClass(ISymbol? symbol) => symbol is IMethodSymbol method && (method.ReducedFrom ?? method).ContainingType is { } containingType diff --git a/Funcky.Analyzers/Funcky.Analyzers/Funcky.Analyzers.csproj b/Funcky.Analyzers/Funcky.Analyzers/Funcky.Analyzers.csproj index 3e4445f97..6a4f4c324 100644 --- a/Funcky.Analyzers/Funcky.Analyzers/Funcky.Analyzers.csproj +++ b/Funcky.Analyzers/Funcky.Analyzers/Funcky.Analyzers.csproj @@ -1,6 +1,6 @@ - 4.4.0 + 4.14.0 diff --git a/Funcky.Analyzers/Funcky.Analyzers/Funcky.Analyzers.targets b/Funcky.Analyzers/Funcky.Analyzers/Funcky.Analyzers.targets index c1675f8c1..b1bea80be 100644 --- a/Funcky.Analyzers/Funcky.Analyzers/Funcky.Analyzers.targets +++ b/Funcky.Analyzers/Funcky.Analyzers/Funcky.Analyzers.targets @@ -38,15 +38,5 @@ - - - $(NoWarn);RS2008 - - - - - - - diff --git a/Funcky.Analyzers/Funcky.BuiltinAnalyzers.CodeFixes/Funcky.BuiltinAnalyzers.CodeFixes.Roslyn3.7.csproj b/Funcky.Analyzers/Funcky.BuiltinAnalyzers.CodeFixes/Funcky.BuiltinAnalyzers.CodeFixes.Roslyn3.7.csproj deleted file mode 100644 index d8c1b71a3..000000000 --- a/Funcky.Analyzers/Funcky.BuiltinAnalyzers.CodeFixes/Funcky.BuiltinAnalyzers.CodeFixes.Roslyn3.7.csproj +++ /dev/null @@ -1,6 +0,0 @@ - - - 3.7.0 - - - diff --git a/Funcky.Analyzers/Funcky.BuiltinAnalyzers.CodeFixes/Funcky.BuiltinAnalyzers.CodeFixes.csproj b/Funcky.Analyzers/Funcky.BuiltinAnalyzers.CodeFixes/Funcky.BuiltinAnalyzers.CodeFixes.csproj index f209efadd..6f791c9c3 100644 --- a/Funcky.Analyzers/Funcky.BuiltinAnalyzers.CodeFixes/Funcky.BuiltinAnalyzers.CodeFixes.csproj +++ b/Funcky.Analyzers/Funcky.BuiltinAnalyzers.CodeFixes/Funcky.BuiltinAnalyzers.CodeFixes.csproj @@ -1,9 +1,6 @@ - 4.4.0 + 4.14.0 - - - diff --git a/Funcky.Analyzers/Funcky.BuiltinAnalyzers/Funcky.BuiltinAnalyzers.Roslyn3.7.csproj b/Funcky.Analyzers/Funcky.BuiltinAnalyzers/Funcky.BuiltinAnalyzers.Roslyn3.7.csproj deleted file mode 100644 index 18b788990..000000000 --- a/Funcky.Analyzers/Funcky.BuiltinAnalyzers/Funcky.BuiltinAnalyzers.Roslyn3.7.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - 3.7.0 - true - - - diff --git a/Funcky.Analyzers/Funcky.BuiltinAnalyzers/Funcky.BuiltinAnalyzers.csproj b/Funcky.Analyzers/Funcky.BuiltinAnalyzers/Funcky.BuiltinAnalyzers.csproj index a5ccb93f8..d38b853a7 100644 --- a/Funcky.Analyzers/Funcky.BuiltinAnalyzers/Funcky.BuiltinAnalyzers.csproj +++ b/Funcky.Analyzers/Funcky.BuiltinAnalyzers/Funcky.BuiltinAnalyzers.csproj @@ -1,10 +1,6 @@ - 4.4.0 - $(DefineConstants);ROSLYN_4_4_0 + 4.14.0 - - - diff --git a/Funcky.Analyzers/Funcky.BuiltinAnalyzers/Funcky.BuiltinAnalyzers.targets b/Funcky.Analyzers/Funcky.BuiltinAnalyzers/Funcky.BuiltinAnalyzers.targets index 859366e0c..0dd4fb8f6 100644 --- a/Funcky.Analyzers/Funcky.BuiltinAnalyzers/Funcky.BuiltinAnalyzers.targets +++ b/Funcky.Analyzers/Funcky.BuiltinAnalyzers/Funcky.BuiltinAnalyzers.targets @@ -23,15 +23,5 @@ - - - $(NoWarn);RS2008 - - - - - - - diff --git a/Funcky.Analyzers/Funcky.BuiltinAnalyzers/OptionListPatternAnalyzer.cs b/Funcky.Analyzers/Funcky.BuiltinAnalyzers/OptionListPatternAnalyzer.cs index 9fd5ab9a0..b7cf227e6 100644 --- a/Funcky.Analyzers/Funcky.BuiltinAnalyzers/OptionListPatternAnalyzer.cs +++ b/Funcky.Analyzers/Funcky.BuiltinAnalyzers/OptionListPatternAnalyzer.cs @@ -1,4 +1,3 @@ -#if ROSLYN_4_4_0 using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; @@ -51,4 +50,3 @@ private static Action AnalyzeListPattern(INamedTypeSym } }; } -#endif diff --git a/Funcky.Analyzers/readme.md b/Funcky.Analyzers/readme.md index d94f79cc0..86db89b17 100644 --- a/Funcky.Analyzers/readme.md +++ b/Funcky.Analyzers/readme.md @@ -29,11 +29,12 @@ where a rule was born: `λ00xx` built-in, `λ10xx` `Funcky.Analyzers`, `λ11xx` the documentation is the authority on where a rule lives. ### Built-in Analyzers and Roslyn Versions -The built-in analyzers have to load on every SDK that can consume `Funcky`, so their baseline is Roslyn 3.7 -(`Funcky.BuiltinAnalyzers.Roslyn3.7.csproj`). Rules that need newer compiler APIs are guarded with `#if ROSLYN_4_4_0` and -only ship in the `roslyn4.4` asset (`Funcky.BuiltinAnalyzers.csproj`); the `Funcky` package packs both assets with the -same `GetAnalyzerPackFiles` mechanism as `Funcky.Analyzers.Package`, and `Funcky/build/Funcky.targets` removes the -`roslyn4.4` asset on SDKs without analyzer versioning and honours `FunckyDisableBuiltinAnalyzers`. +The built-in analyzers share the Roslyn 4.14 baseline of `Funcky.Analyzers` since Funcky 4.0.0 (up to 3.8.0 they also +shipped a `roslyn3.7` asset for the SDKs before .NET 7, with the newer rules behind `#if ROSLYN_4_4_0`). The `Funcky` +package packs the asset with the same `GetAnalyzerPackFiles` mechanism as `Funcky.Analyzers.Package`, and +`Funcky/build/Funcky.targets` removes the analyzers on SDKs without analyzer versioning (which would otherwise load +them and fail) and honours `FunckyDisableBuiltinAnalyzers`. Unlike `Funcky.Analyzers`, the library package does not +warn about an old SDK: the analyzers are an extra, the library itself keeps working. ## Roslyn Multi-Targeting In order to support newer C# features (which in turn requires an upgrade of the `Microsoft.CodeAnalysis.*` packages) @@ -49,16 +50,18 @@ can be shipped side by side: ``` ╰─ analyzers ╰─ dotnet - ╰─ roslyn4.4 + ╰─ roslyn4.14 ╰─ cs ├─ Funcky.Analyzers.dll ╰─ ... ``` From the different versions, the highest compatible version is picked. Funcky.Analyzers currently ships a -single asset for Roslyn 4.4 (Visual Studio 2022 17.4, .NET SDK 7.0.100), the oldest version the analyzers -need. Up to Funcky.Analyzers 1.4.2 there was a second, untested `roslyn4.0` asset for Visual Studio 2022 -17.0; Funcky.Analyzers 2.0.0 dropped it, as that version is out of support. To add an asset for another Roslyn +single asset for Roslyn 4.14 (Visual Studio 2022 17.14, .NET SDK 9.0.300), the compiler the .NET 10 SDK era +starts from. Funcky.Analyzers 2.x shipped a `roslyn4.4` asset (Visual Studio 2022 17.4, .NET SDK 7.0.100); 3.0.0 +raised the baseline together with Funcky 4.0.0, which no longer supports SDKs before .NET 10. Up to +Funcky.Analyzers 1.4.2 there was a second, untested `roslyn4.0` asset for Visual Studio 2022 17.0; Funcky.Analyzers +2.0.0 dropped it, as that version is out of support. To add an asset for another Roslyn version, add a second project file next to `Funcky.Analyzers.csproj` with a different `AnalyzerRoslynVersion`, reference it from the package project with `PackAsAnalyzer`, and guard the sources that need the newer API with a define. @@ -68,9 +71,9 @@ from the package project with `PackAsAnalyzer`, and guard the sources that need * The `System.Text.Json` package fixes this by shipping a `.targets` file with their packages that catches this case by checking for the `SupportsRoslynComponentVersioning` property and manually removing discovered analyzers that are incompatible. - * Our analyzers require at least Roslyn 4.4; SDKs without multi-targeting support (before Roslyn 4.0 / .NET 6.0) + * Our analyzers require at least Roslyn 4.14; SDKs without multi-targeting support (before Roslyn 4.0 / .NET 6.0) would load them anyway, so we ship a `.targets` file that removes all our analyzers and warns the user. - * An SDK that supports multi-targeting but is older than Roslyn 4.4 finds no compatible directory and loads + * An SDK that supports multi-targeting but is older than Roslyn 4.14 finds no compatible directory and loads nothing, without a warning; that cannot be detected from MSBuild. * SDKs versions that support multi-targeting also load analyzers that are not in a `roslyn*` directory, so to avoid loading analyzers twice diff --git a/Funcky.SourceGenerator/Funcky.SourceGenerator.csproj b/Funcky.SourceGenerator/Funcky.SourceGenerator.csproj index 4615d87a0..3b48587d1 100644 --- a/Funcky.SourceGenerator/Funcky.SourceGenerator.csproj +++ b/Funcky.SourceGenerator/Funcky.SourceGenerator.csproj @@ -11,7 +11,7 @@ - + diff --git a/Funcky.slnx b/Funcky.slnx index 848ddaf36..52d481139 100644 --- a/Funcky.slnx +++ b/Funcky.slnx @@ -6,9 +6,7 @@ - - diff --git a/Funcky/Funcky.csproj b/Funcky/Funcky.csproj index 078db584b..6a98a57a7 100644 --- a/Funcky/Funcky.csproj +++ b/Funcky/Funcky.csproj @@ -61,16 +61,13 @@ - + - - diff --git a/Funcky/build/Funcky.targets b/Funcky/build/Funcky.targets index c18efbe2b..75c4b5521 100644 --- a/Funcky/build/Funcky.targets +++ b/Funcky/build/Funcky.targets @@ -8,23 +8,23 @@ + The Funcky package ships its analyzers in analyzers/dotnet/roslyn4.14/cs. SDKs that support analyzer + versioning (.NET 6 and newer) load the directory only when their compiler is at least Roslyn 4.14 + (Visual Studio 2022 17.14, .NET SDK 9.0.300). Older SDKs load every analyzer they find, so the target + below removes the assets there instead of letting the compiler fail to load them. Adapted from the + targets that System.Text.Json ships. --> <_FunckyBuiltinAnalyzer Include="@(Analyzer)" Condition="'%(Analyzer.NuGetPackageId)' == 'Funcky'" /> - - + diff --git a/SupportPolicy.md b/SupportPolicy.md index 7df9e3dd1..2fb0c6223 100644 --- a/SupportPolicy.md +++ b/SupportPolicy.md @@ -8,6 +8,14 @@ We support the all the actively supported modern Frameworks, .NET Standard 2.1, * We only remove support for target frameworks on major version changes, to avoid breaking changes for the consumers. +## What SDKs do we support? + +The analyzers built into Funcky and the Funcky.Analyzers package are compiled against a fixed Roslyn version. Funcky 4 +targets Roslyn 4.14, the compiler of Visual Studio 2022 17.14 and the .NET SDK 9.0.300, so every .NET 10 SDK and newer +loads them. Older SDKs skip the analyzers; the library itself has no SDK requirement beyond its target frameworks. + +* We only raise the Roslyn baseline on major version changes. + ## Testing Testing with old frameworks which are not supported anymore is getting painful, we therefore only test with frameworks which are still in active support. diff --git a/changelog.md b/changelog.md index e5543cd89..49f675ce3 100644 --- a/changelog.md +++ b/changelog.md @@ -13,6 +13,12 @@ Funcky adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). * The `net11.0` asset also wraps the search overloads .NET 11 adds to `string`: `IndexOfOrNone` and `LastIndexOfOrNone` for a `char` with a `StringComparison` and a start index or count, and both for a `Rune` in every shape the `char` overloads come in. +* Breaking: the built-in analyzers and Funcky.Analyzers 3.0.0 are built against Roslyn 4.14 and ship a single + `roslyn4.14` asset. They load on Visual Studio 2022 17.14 and the .NET SDK 9.0.300 or newer, which covers every + .NET 10 SDK. The `roslyn3.7` asset of the built-in analyzers and the `roslyn4.4` asset of Funcky.Analyzers are gone; + an older SDK that supports analyzer versioning finds no compatible asset and silently skips the analyzers, and the + package targets remove them on SDKs without analyzer versioning (before .NET 6). The library itself keeps working on + those SDKs. `λ1010` no longer needs a separate note, it is part of the one asset. ## Funcky 3.8.0 | Funcky.Async 1.6.0 | Funcky.Xunit 2.3.0 | Funcky.Xunit.v3 1.1.0 | Funcky.Analyzers 2.1.0