cezarypiatek / MappingGeneratorIssueTracker

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

MappingGeneratorRefactoring error #21

Closed jsodeman closed 1 year ago

jsodeman commented 1 year ago

I'm getting an error trying to generate a method mapping.

VS 2022 v17.5.3 MappingGenerator 2023.3.55 R# 2022.3.3

System.NullReferenceException : Object reference not set to an instance of an object.
   at MappingGenerator.VS2019Features.ReflectionNullabilityResolver.StripNullability(ITypeSymbol type)
   at MappingGenerator.Mappings.MappingContext.GetTypeExpression(String fullyQualifiedMetadataName)
   at MappingGenerator.Mappings.Converters.FromStringConverter.Initializer(MappingContext context)
   at MappingGenerator.Mappings.Converters.FromStringConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping)
   at MappingGenerator.Mappings.Converters.FirstWorkingConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping)
   at MappingGenerator.Mappings.Converters.NullableToNotNullExpressionConverterDecorator.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping)
   at MappingGenerator.Mappings.MappingEngine.MapExpression(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping)
   at MappingGenerator.Mappings.MappingImplementors.SingleParameterPureMappingMethodImplementor.GenerateImplementation(IMethodSymbol methodSymbol,SemanticModel semanticModel,MappingContext mappingContext,MappingSourceHint hint)
   at MappingGenerator.Mappings.MappingImplementorEngine.GenerateMappingStatements(IMethodSymbol methodSymbol,SemanticModel semanticModel,MappingContext mappingContext,IMappingMethodImplementor mappingMethodImplementor)
   at MappingGenerator.Mappings.MappingImplementorEngine.GenerateMappingBlock(IMethodSymbol methodSymbol,SemanticModel semanticModel,MappingContext mappingContext,IMappingMethodImplementor mappingMethodImplementor)
   at async MappingGenerator.Features.Refactorings.Mappings.MappingMethod.MappingGeneratorRefactoring.GenerateMappingMethodBodyCustom(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async MappingGenerator.Features.Refactorings.Mappings.MappingMethod.MappingGeneratorRefactoring.<>c__DisplayClass14_0.<TryToRegisterRefactoring>b__0(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedSolutionAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputeOperationsAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetPreviewOperationsAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.GetPreviewResultAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.PreviewChangesSuggestedAction.CreateAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.GetPreviewChangesFlavorAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.CreateAllFlavorsAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](<Unknown Parameters>)

image

image

jsodeman commented 1 year ago

After selecting Enable I am able to creating the mapping, though it takes hitting Ctr-. twice to get the Generate prompts.

cezarypiatek commented 1 year ago

Thanks for reporting this issue.

Can you share the definition of source and target types? Or at least try to isolate the property causing this issue. I will be grateful for help with narrowing down the source of that problem.

jsodeman commented 1 year ago

    public class ProductionTask
    {
        public int Id { get; set; }
        public string Category { get; set; }
        public string Topic { get; set; }
        public string AgentFileId { get; set; }
        public string FileNumber { get; set; }
        public string FileId { get; set; }
        public string AssignedTo { get; set; }
        public string Status { get; set; }
        public DateTime? StartDateTime { get; set; }
        public DateTime? EndDateTime { get; set; }
        public DateTime? DueDateTime { get; set; }
    }

    public class ProductionTaskAddRequest {
        public string Category { get; set; }
        public string Topic { get; set; }
        public string AgentFileId { get; set; }
        public string FileNumber { get; set; }
        public string FileId { get; set; }
        public string AssignedTo { get; set; }
    }
cezarypiatek commented 1 year ago

One more question: what version of dotnet framework is used in your project?

jsodeman commented 1 year ago

Net 4.8

cezarypiatek commented 1 year ago

Thanks, I think I found the culprit. I will try to release the fix tomorrow.

cezarypiatek commented 1 year ago

Please try to update to v2023.3.56 and let me know it the issue is gone.

jsodeman commented 1 year ago

I updated to the new version and the issue is gone. Thank you for the fast fix.