cezarypiatek / MappingGenerator

:arrows_counterclockwise: "AutoMapper" like, Roslyn based, code fix provider that allows to generate mapping code in design time.
https://marketplace.visualstudio.com/items?itemName=54748ff9-45fc-43c2-8ec5-cf7912bc3b84.mappinggenerator
MIT License
1.03k stars 120 forks source link

NullReferenceException on omitted type parameter #138

Closed NoahStahl closed 4 years ago

NoahStahl commented 4 years ago

I encountered an issue with a particular case that seems to cause an exception. When entering this line, as example:

var test = new HashSet();

The exception below is thrown. It specifically seems to happen when forgetting the angle brackets and type parameter. Occurs in empty console app, no other conditions or dependencies involved as far as I can tell.

Here's a short video of the issue. Version 1.17.442 on VS 2019 16.7.3. Thanks!

System.NullReferenceException: Object reference not set to an instance of an object.at MappingGenerator.MethodHelpers.ConstructorInvocation.GetOverloadParameterSets(SemanticModel semanticModel)at MappingGenerator.Features.Suggestions.MethodParametersSuggestionProvider.GetArgumentListWithLocalVariables(Document document, IInvocation invocation, Boolean generateNamedParameters, SemanticModel semanticModel)at MappingGenerator.Features.Suggestions.MethodParametersSuggestionProvider.SuggestMethodParameters(CompletionContext context, IInvocation invocation, SemanticModel semanticModel)at MappingGenerator.Features.Suggestions.MethodParametersSuggestionProvider.d3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)at Microsoft.CodeAnalysis.Completion.CompletionServiceWithProviders.d35.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)at Microsoft.CodeAnalysis.Completion.CompletionServiceWithProviders.d29.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)at Microsoft.CodeAnalysis.Completion.CompletionServiceWithProviders.d26.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)at Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.AsyncCompletion.CompletionSource.d25.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.d36`1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

cezarypiatek commented 4 years ago

Hi @NoahStahl Thanks for reporting this issue. I will let you know when the fix is ready.

cezarypiatek commented 4 years ago

Should be fixed in 1.18.448. Would you mind to test it and let me know if the problem disappeared?

NoahStahl commented 4 years ago

Thanks! The issue appears resolved once I upgraded to 1.18.448.

cezarypiatek commented 4 years ago

Thanks for verification