Skip to content

SmartParamBuilder casting should use target type, not source type. #11

@mawosoft

Description

@mawosoft

in SmartParameter.ToSourceCode():

string cast = Value == null ? string.Empty : $"({Value.GetType().GetCorrectCSharpTypeName()})";

Similar issue was fixed in SmartArgument.ToSourceCode():

string cast = $"({parameterDefinitions[argumentIndex].ParameterType.GetCorrectCSharpTypeName()})"; // it's an object so we need to cast it to the right type

See PR dotnet#1228

-string cast = $"({Value.GetType().GetCorrectCSharpTypeName()})"; // it's an object so we need to cast it to the right type
+string cast = $"({parameterDefinitions[argumentIndex].ParameterType.GetCorrectCSharpTypeName()})"; // it's an object so we need to cast it to the right type

Would probably fix dotnet#2011

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions