New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NullableAttribute not checked for in cache #325
Comments
Interesting find. This may have crept in when I allowed Do you have the attribute on a type or just on members? |
I have only tested it on members. In general, this applies to any attribute that is only handled in refiners, and not attribute handlers. So perhaps there should be a way to indicate that attributes affects type info in some way. Otherwise, adding an empty IAttributeHandler for the offending attribute seems to be a manageable workaround for now. Btw, if anyone tries this workaround: The IAttributeHandler implementation cannot be an internal class, as it will not be discovered via the Assembly (there might be more conditions due to this, I haven't tested several build configurations). |
Okay. I see what's happening now. (You're right, but I had to follow it in the code to see it.) When I process a type, I also consider the attributes. However, I don't want to consider attributes that I don't care about (e.g. This is what causes the contamination across properties and why the workaround fixes it. I'll update |
Thanks! |
Environment
Describe the bug
NullableAttribute by default has no IAttributeHandler (it is instead handled in NullabilityRefiner) and is therefore ignored in WhereHandled filter in SchemaGenerationContextCache.Get() used to calculate hash.
To Reproduce
Have several members of same type but only some with Nullable attribute. The non-nullable members may be "infected" with null.
Expected behavior
Nullable should be included in list of attributes passed to CalculateHash to ensure different hash.
Additional context
Possible fix is adding IAttributeHandler to NullableAttribute with an empty implementation.
The text was updated successfully, but these errors were encountered: