From 3b10ef5ed53aefa6fadaafe43c069e4d51198a7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tau=20G=C3=A4rtli?= Date: Tue, 4 Feb 2025 14:21:43 +0100 Subject: [PATCH] Document learnings --- Funcky.Analyzers/readme.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Funcky.Analyzers/readme.md b/Funcky.Analyzers/readme.md index 19ff8ad1..92cd8ab1 100644 --- a/Funcky.Analyzers/readme.md +++ b/Funcky.Analyzers/readme.md @@ -22,15 +22,30 @@ This means that we ship multiple copies of the analyzer assembly in the followin ``` ╰─ analyzers ╰─ dotnet - ├─ cs - │ ├─ Funcky.Analyzers.dll - │ ╰─ ... + ├─ roslyn4.0 + │ ╰─ cs + │ ├─ Funcky.Analyzers.dll + │ ╰─ ... ╰─ roslyn4.12 ╰─ cs ├─ Funcky.Analyzers.dll ╰─ ... ``` +From the different versions, the highest compatible version is picked. + +### Remarks +* SDKs that don't support multi-targeting load analyzers recursively, + even inside the "versioned" `roslyn*` directories. + * 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.0 / .NET 6.0 (which is the version that introduced multi-targeting) + so we fix this by shipping a `.targets` file that removes all our analyzers and warns the user. +* SDKs versions that support multi-targeting also load analyzers + that are not in a `roslyn*` directory, so to avoid loading analyzers twice + all analyzers need to be inside a `roslyn*` directory. + ## Roslyn Version Compatibility There are three documents that help figure out what version of Roslyn to target: * [.NET compiler platform package version reference](https://learn.microsoft.com/en-us/visualstudio/extensibility/roslyn-version-support): \