question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Emit a warning when insufficient compiler version is used with the SDK

See original GitHub issue

Is your feature request related to a problem? Please describe.

Recently we were debugging a failing issue which a scenario using Microsoft extensions logging source generator which requires C# compiler 4.4. The user was using 2022 VS v17.3.6 which using C# compiler 4.3.0-3.22470.13 (80a8ce8d). The source generation in the project will fail to work and will end up with a compiler error like: C:\scratch\webApp\Program.cs(35,32): error CS8795: Partial method 'Log.Hello(ILogger, string)' must have an implementation part because it has accessibility modifiers. [C:\scratch\webApp\webApp.csproj] which gives a hint there is a source generation problem but not clear what exactly the problem is especially compiling the same project on another machine happens to use compiler version 4.4 make it succeed.

Note, the project we were debugging was disabling the warning CS9057 which was hiding more information about the failure. Had they not disabled this warning they would have seen numerous warnings:

  CSC : warning CS9057: The analyzer assembly 'C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\7.0.2\analyzers\dotnet\cs\Microsoft.Interop.JavaScript.JSImportGenerator.dll' references version '4.4.0.0' of the compiler, which is newer than the currently running version '4.3.0.0'. 
  CSC : warning CS9057: The analyzer assembly 'C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\7.0.2\analyzers\dotnet\cs\Microsoft.Interop.LibraryImportGenerator.dll' references version '4.4.0.0' of the compiler, which is newer than the currently running version '4.3.0.0'. 
  CSC : warning CS9057: The analyzer assembly 'C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\7.0.2\analyzers\dotnet\cs\System.Text.Json.SourceGeneration.dll' references version '4.4.0.0' of the compiler, which is newer than the currently running version '4.3.0.0'. 
  CSC : warning CS9057: The analyzer assembly 'C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\7.0.2\analyzers\dotnet\cs\System.Text.RegularExpressions.Generator.dll' references version '4.4.0.0' of the compiler, which is newer than the currently running version '4.3.0.0'. 
  CSC : warning CS9057: The analyzer assembly 'C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\7.0.2\analyzers\dotnet\cs\Microsoft.AspNetCore.App.Analyzers.dll' references version '4.4.0.0' of the compiler, which is newer than the currently running version '4.3.0.0'. 
  CSC : warning CS9057: The analyzer assembly 'C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\7.0.2\analyzers\dotnet\roslyn4.4\cs\Microsoft.Extensions.Logging.Generators.dll' references version '4.4.0.0' of the compiler, which is newer than the currently running version '4.3.0.0'. 

Describe the solution you’d like

When using SDK version (which allows source generation) with insufficient compiler version, should produce more logging to warn about the issue.

Additional context

This is easily can reproduce by creating a project and use the compiler version 4.3 and have some source generation code.

Issue Analytics

  • State:open
  • Created 8 months ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
tarekghcommented, Feb 2, 2023

@ericstj feel free to add/edit the issue if I didn’t capture anything.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The current .NET SDK does not support targeting . ...
0 , but after trying to build I get this error: The current .NET SDK does not support targeting .NET Standard 2.0. Either...
Read more >
Improvements to Warnings in the C++ Compiler
The compiler will emit: warning C4317: 'printf' : not enough arguments passed for format string warning C4422: 'printf' : too many arguments ...
Read more >
PEP 387: backwards compatibilty policy
In case of C API, is runtime deprecation (e.g. raising DeprecationWarning) required, or is compiler warning enough? For example, ...
Read more >
Compiling CUDA with clang
If clang detects a newer CUDA version, it will issue a warning and will attempt to use detected CUDA SDK it as if...
Read more >
Visual C++ 2013 can't detect buffer overruns or emit C4789 ...
Fixes an issue in which Visual C++ 2013 can't detect some buffer overrun scenarios and doesn't emit the Compiler Warning C4789.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found