beakona / AutoInterface

C# interface-to-member source generator
MIT License
73 stars 9 forks source link

NotSupportedException (BK-AG09) trying to implement interfaces of separate library #7

Closed Dblm0 closed 2 years ago

Dblm0 commented 2 years ago

If the desired interface definition is located in different dll then in GetSourceIdentifier method symbol.DeclaringSyntaxReferences is empty, so NotSupportedException is thrown.

Exception stacktrace:

   at BeaKona.AutoInterfaceGenerator.CSharpCodeTextWriter.GetSourceIdentifier(ISymbol symbol) in C:\Users\Dmitriev\Desktop\C#Projects\sourceGenerators\AutoInterface\BeaKona.AutoInterfaceGenerator\CSharpCodeTextWriter.cs:line 954
   at BeaKona.AutoInterfaceGenerator.CSharpCodeTextWriter.WriteIdentifier(SourceBuilder builder, ISymbol symbol) in C:\Users\Dmitriev\Desktop\C#Projects\sourceGenerators\AutoInterface\BeaKona.AutoInterfaceGenerator\CSharpCodeTextWriter.cs:line 846
   at BeaKona.AutoInterfaceGenerator.CSharpCodeTextWriter.WriteTypeReference(SourceBuilder builder, ITypeSymbol type, ScopeInfo scope) in C:\Users\Dmitriev\Desktop\C#Projects\sourceGenerators\AutoInterface\BeaKona.AutoInterfaceGenerator\CSharpCodeTextWriter.cs:line 126
   at BeaKona.AutoInterfaceGenerator.AutoInterfaceSourceGenerator.ProcessClass(GeneratorExecutionContext context, Compilation compilation, INamedTypeSymbol type, IEnumerable`1 infos) in C:\Users\Dmitriev\Desktop\C#Projects\sourceGenerators\AutoInterface\BeaKona.AutoInterfaceGenerator\AutoInterfaceSourceGenerator.cs:line 542
   at BeaKona.AutoInterfaceGenerator.AutoInterfaceSourceGenerator.Execute(GeneratorExecutionContext context) in C:\Users\Dmitriev\Desktop\C#Projects\sourceGenerators\AutoInterface\BeaKona.AutoInterfaceGenerator\AutoInterfaceSourceGenerator.cs:line 115
beakona commented 2 years ago

That is same place where issue #3 was resided in.. Actually it was obvious and I am sending you an apology to make such mistake. If referred type resides in different compilation unit then way I generated identifier (drilling through AST) will be empty. Once again, sorry. Release v1.0.16 is published right now..