You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The AttributeWriter only detects the explicit named arguments and ignores the other argument's default values.
The generated attribute looks like this:
new global::Vogen.VogenDefaultsAttribute(global::Vogen.StaticAbstractsGeneration.ValueObjectsDeriveFromTheInterface)
This results in compilation errors as it omits the positional name so the arguments are out of order
Copilot suggests the following to fetch the default values when arguments are not explicitly provided:
var constructorArguments = attributeData.ConstructorArguments.Select((arg, index) =>
{
var parameter = attributeData.AttributeConstructor.Parameters[index];
if (arg.IsNull && parameter.HasExplicitDefaultValue)
{
return TypedConstantParser.GetTypedConstantValue(context.SemanticModel, parameter.ExplicitDefaultValue, arg.Type);
}
return TypedConstantParser.GetTypedConstantValue(context.SemanticModel, attributeSyntax.DescendantNodes().OfType<AttributeArgumentSyntax>().ElementAt(index).Expression, arg.Type);
});
The text was updated successfully, but these errors were encountered:
I have an issue with attributes with positional arguments.
some attributes like https://github.com/SteveDunn/Vogen/blob/main/src/Vogen.SharedTypes/VogenDefaultsAttribute.cs do not contain named arguments.
when using the attribute and providing just one argument as a positional one like
The AttributeWriter only detects the explicit named arguments and ignores the other argument's default values.
The generated attribute looks like this:
This results in compilation errors as it omits the positional name so the arguments are out of order
Copilot suggests the following to fetch the default values when arguments are not explicitly provided:
The text was updated successfully, but these errors were encountered: