dasMulli / data-builder-generator

Code generator to easily create data builder patterns for your model classes
MIT License
116 stars 11 forks source link

An instance of analyzer DataBuilderGenerator cannot be created #1

Closed eluchsinger closed 3 years ago

eluchsinger commented 3 years ago

I would like to try out your Source Generator. I got the following warning in Visual Studio 16.8 on a project running .NET 5. The generation of a Builder does not seem to work.

Warning CS8032  An instance of analyzer DasMulli.DataBuilderGenerator.DataBuilderGenerator cannot be created from <path>/DasMulli.DataBuilderGenerator.dll: Method 'Initialize' in type 'DasMulli.DataBuilderGenerator.DataBuilderGenerator' from assembly 'DasMulli.DataBuilderGenerator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.. My.UnitTests        1   Active  System.TypeLoadException: Method 'Initialize' in type 'DasMulli.DataBuilderGenerator.DataBuilderGenerator' from assembly 'DasMulli.DataBuilderGenerator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
   at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type)
   at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.Extensions`1.GetAnalyzersForTypeNames(Assembly analyzerAssembly, IEnumerable`1 analyzerTypeNames, Boolean& reportedError)

My Package Reference is added in the same way you described in the Readme.

<PackageReference Include="DasMulli.DataBuilderGenerator" Version="*" PrivateAssets="All" />
dasMulli commented 3 years ago

Hi! Yes there has been a breaking change between the preview tooling shipped in 16.7 and 16.8. There is already a 2.0.0-preview package available that adapted to that API change. (AFAIK NuGet now supports *-* as version b/c * won‘t give you this version...).