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.

VS 16.8 Preview 3 breaks Source Generators

See original GitHub issue

Version Used:

Version 16.8.0 Preview 3.0, updated from Preview 2.0 via VS installer.

Steps to Reproduce:

  1. Use SG Sample from roslyn-sdk
  2. Update all packages
  3. Build

Expected Behavior:

No error

Actual Behavior:

CSC : warning CS8032: An instance of analyzer SourceGeneratorSamples.HelloWorldGenerator cannot be created from ...\roslyn-sdk\artifacts\bin\SourceGeneratorSamples\Debug\netstandard2.0\SourceGeneratorSamples.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.

-> Same error for all SG

Reverting Microsoft.CodeAnalysis 3.8.0-2.final to 3.7.0 solves the problem somehow.

Updates:

Microsoft.CodeAnalysis.Common.3.8.0-2.final -> Microsoft.CodeAnalysis.Common.3.7.0 Microsoft.CodeAnalysis.CSharp.3.8.0-2.final -> Microsoft.CodeAnalysis.CSharp.3.7.0 System.Collections.Immutable.5.0.0-preview.8.20371.14 -> System.Collections.Immutable.1.5.0 System.Reflection.Metadata.5.0.0-preview.8.20371.14 -> System.Reflection.Metadata.1.6.0


Tried the same for the Blazor problem demo project: blazor-with-source-generators-poc

But no luck here when reverting Microsoft.CodeAnalysis 3.8.0-2.final to 3.7.0. Even the Console App build fails already:

CSC : warning CS8032: An instance of analyzer SourceGeneratorSamples.HelloWorldGenerator cannot be created from ...\blazor-with-source-generators-poc\src\SourceGen\bin\Debug\netstandard2.0\SourceGen.dll : Method 'Initialize' in type 'SourceGeneratorSamples.HelloWorldGenerator' from assembly 'SourceGen, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation..

CS0103	The name 'HelloWorldGenerated' does not exist in the current context	ConsoleApp1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
jmarolfcommented, Sep 15, 2020

@chsienki I assume we are going to publish the preview 3 nuget packages?

2reactions
b-straubcommented, Sep 15, 2020

Sure this works now, but not without adding an additional preview source! Microsoft.CodeAnalysis.CSharp needs to be version 3.8.0-4.20464.1 from:

<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />

and not the shipped one from VS 16.8 p3 with dotnet-sdk-5.0.100-rc.1.20452.10.

Read more comments on GitHub >

github_iconTop Results From Across the Web

asp net core 5.0 RC1 - Developer Community
The project uses both asp net core and entity framework core. When debugging using Visual Studio 2019 16.8 preview 3, it will sporadically...
Read more >
Code using generated code builds successfully but shows ...
The console application referencing a project using a source generator in the same solution builds, but will start showing errors for references to ......
Read more >
Visual Studio 2019 version 16.8 Release Notes
Get the latest features, bug fixes, and support for Visual Studio 2019 v16.8.
Read more >
c# - Roslyn Source Generator not generating any source in ...
Update: As of Roslyn 3.8 / Visual Studio 16.8 source generators are no longer behind a preview flag, and should work for any...
Read more >
Source Generators an Exercise in futility - Dan Siegel
As I got to learn more about Source Generators I quickly learned just how powerful they are.. because I'm lazy and dislike manually...
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