cezarypiatek / MappingGeneratorIssueTracker

This is a issue tracker for MappingGenerator
2 stars 0 forks source link

Error upon invoking extension #3

Closed NoahStahl closed 2 years ago

NoahStahl commented 3 years ago

Hello! I just purchased after using the free version awhile. Thanks for making this.

Unfortunately the extension is failing on one of my projects. It works for a simple console app, but when opening a larger more complex solution, I see the below exception.

Please let me know what information I can provide to get this fixed. Thanks!

image

System.NullReferenceException : Object reference not set to an instance of an object.
   at Microsoft.CodeAnalysis.CSharp.CSharpExtensions.Kind(SyntaxNode node)
   at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetDeclaredSymbolCore(SyntaxNode node,CancellationToken cancellationToken)
   at MappingGenerator.Mappings.MappingLocationContext.FromContextExpression(SyntaxNode contextExpression,SemanticModel semanticModel)
   at MappingGenerator.Mappings.MappingContext..ctor(SyntaxNode contextExpression,SemanticModel semanticModel,MappingOptions options,SyntaxGenerator syntaxGenerator,MappingFeatureAvailability mappingFeatureAvailability)
   at async MappingGenerator.Features.Refactorings.MappingGeneratorRefactoring.GenerateMappingMethodBodyCustom(<Unknown Parameters>)
   at async MappingGenerator.Features.Refactorings.MappingGeneratorRefactoring.<>c__DisplayClass8_0.<TryToRegisterRefactoring>b__0(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedSolutionAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputeOperationsAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetPreviewOperationsAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.GetPreviewResultAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.<>c__DisplayClass11_0.<GetPreviewAsync>b__0(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](<Unknown Parameters>)
cezarypiatek commented 3 years ago

Hi Noah,

Thanks for reporting the issue. Sorry for your inconvenience. I will check it tommorow. In the meantime two questions: Do you load the whole solution or only selected projects? Do you have any compilation errors?

NoahStahl commented 3 years ago

Thanks for the quick reply Cezary.

I'm loading an entire solution of about 9 projects. In the middle of upgrading them from .NetCore 2.2 to .NET 5.

No compilation errors, just some warnings about old versions of core framework.

NoahStahl commented 3 years ago

After all the projects in the solution were upgraded to .NET 5, I no longer am seeing the issue.

cezarypiatek commented 3 years ago

So for I didn't have a chance to test MappingGenerator with .NET 5. Can you show a snippet presenting the method signature where do you try to trigger the code action? Are you using top-level statements? Any other C# 9 features in the codebase? Top-level statements are not handled atm. If this issue is not affecting you after the migration I will provide a fix with the next version (end of September/ beginning of October). However, if this still affects your work, then I will try to prepare a hotfix.

NoahStahl commented 3 years ago

It seems to be working fine now that the solution is migrated to .NET 5.

The trigger point for the previous failure was just within a simple class. This was occurring in a .NET 2.2 project at the time, so nothing bleeding edge there.