Skip to content

Commit

Permalink
Make the C# language check a warning instead of an error
Browse files Browse the repository at this point in the history
Instead of reporting an error (both on BeforeCompile and CoreCompile) when we detect the project language isn't C# 9.0+, which breaks design-time builds (in addition to full builds) and causes bad IDE experience right-after install, make it a warning instead.

This gives the user the chance to build, perhaps attempt to type ThisAssembly and see that nothing happens, note the warning, and then cleanly uninstall the package.

Fixes #51
  • Loading branch information
kzu committed Mar 16, 2021
1 parent 1a40e95 commit a2ad738
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
Condition="$([System.Version]::Parse('16.8.0').CompareTo($([System.Version]::Parse($(MSBuildVersion))))) == 1" />

<!-- See https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/langversion-compiler-option -->
<Error Text="ThisAssembly uses Roslyn source generators, which are only supported in C# 9.0 or greater at the moment."
Condition="'$(Language)' != 'C#' OR
('$(LangVersion)' != 'preview' AND
'$(LangVersion)' != 'latest' AND
'$(LangVersion)' != 'latestMajor' AND
'$(LangVersion)' &lt; '9.0')" />
<Warning Code="THIS001"
Text="ThisAssembly uses Roslyn source generators, which are only supported in C# 9.0 or greater at the moment."
Condition="'$(Language)' != 'C#' OR
('$(LangVersion)' != 'preview' AND
'$(LangVersion)' != 'latest' AND
'$(LangVersion)' != 'latestMajor' AND
'$(LangVersion)' &lt; '9.0')" />
</Target>

</Project>

0 comments on commit a2ad738

Please sign in to comment.