Open Brannos1970 opened 1 year ago
This repo is not the right place to report issues, suggest improvements or ask questions about .Net.
That being said, if you want to add an attribute to the property generated from a record primary constructor, you can do it by specifying property:
on the attribute, e.g.:
record R([property: Compare("J")] int I, int J);
If you still think CompareAttribute
should be changed, the right place to propose that is the dotnet/runtime repo.
The compare attribute when applied to a record parameter give the error message it is only valid on property or indexers.
Issue: I was using the compare in a record to validate passwords. The error message was display. When I created a custom comparer and added the flag attributes of Parameter and Fields it resolved the issue.
Proposed Solution:
Add the attribute usage flag "AttributeTargets.Parameter". The AttributeTargets.Fields may also need to be added.