Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS 16.8 Preview 3 breaks Source Generators #47681

Closed
b-straub opened this issue Sep 14, 2020 · 11 comments
Closed

VS 16.8 Preview 3 breaks Source Generators #47681

b-straub opened this issue Sep 14, 2020 · 11 comments

Comments

@b-straub
Copy link

b-straub commented Sep 14, 2020

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
@jmarolf
Copy link
Contributor

jmarolf commented Sep 14, 2020

CC: @chsienki

@chsienki
Copy link
Contributor

@b-straub We've made some breaking changes to generators in preview 3 (see here: https://github.com/dotnet/roslyn/blob/master/docs/features/source-generators.cookbook.md#breaking-changes)

We've yet to update the samples to match. I'll get on that ASAP

@chsienki
Copy link
Contributor

The samples are now updated to the latest syntax

@b-straub
Copy link
Author

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.

@jmarolf
Copy link
Contributor

jmarolf commented Sep 15, 2020

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

@chsienki
Copy link
Contributor

Hmm, we're stuck in a weird middle ground then we're it seems that VS has shipped, but we haven't pushed the packages for it yet. @JoeRobich any idea when the packages will go to the public feed?

@mwpowellhtx
Copy link

With a grain of salt... I am curious. Will be interested to check things out.

TL;DR, I will review in more depth, but on surface, I have in the past cautioned against allowing CG to be driven by too many in the way of concrete examples, i.e. the perenial INotifyPropertyChanged family of examples.

In general, I have a couple of projects that are not driven by any such thing, but rather take their cues, sometimes from third party XML or JSON configuration files. Not dissilimar to T3 or T4 based template driven CG.

Other times driven by external packaging, and an ANTLR (or parser) driven interpretation of a protobuf v2 input file, in another instance.

In any event, could be triggered by an attribute, but does not necessarily need to be. additionally, could occur at an assembly level.

In addition to which, I prefer to generate a sequence of modules, not necessarily one monolithc module. again, re: CG APIs, TL;DR. i.e. based on my experience with my own Code.Generation.Roslyn, in which case I prefer yielding a range of CompilationUnitSyntax, which may vary depending on whether the transformation was assembly or document.

Questions? Thoughts?

@mwpowellhtx
Copy link

@JoeRobich @jmarolf @chsienki What does this mean, exactly? The target 16.8 delivery was made, but the packages were not included? Are the out of band? What's the story there... The Azure dotnet tools feed will work?

@jmarolf
Copy link
Contributor

jmarolf commented Jan 4, 2021

The target 16.8 delivery was made, but the packages were not included?

Unsure of what you are asking. I am responding to this comment here. The version that shipped with visual studio version 16.8 were not yet uploaded to nuget so (unti recently) you needed to use the https://pkgs.dev.azure.com. Nuget.org now has the latest nuget packages and this separate nuget feed is no longer needed. In general there is a few days of lag between when visual studio ships and we upload the final nuget packages.

As of now I expect this bug to not be reproduceable for customers.

@mwpowellhtx
Copy link

@jmarolf I was not clear about that, appreciate the clarification.

@mwpowellhtx
Copy link

@jmarolf Perhaps the poignant question though... what actually ARE the packages, if you please? Package names? Or links even, would be helpful. Thank you...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants