-
Notifications
You must be signed in to change notification settings - Fork 183
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
Add flag to emit #nullable enable
#344
Comments
#nullable enable
#nullable enable
Sorry this took so long 😳
Can you give an example? Where should we put the |
No Problem. Actually i don't have an example, where adding
The microsoft documentation is not really specific about it. I tested sucessfully with putting it between the leading comment and the first |
@mganss sorry to revive a "dead" thread, but I feel like I'm very close to what I want the generated code to look like with a couple changes. This is my schema: https://docs.oasis-open.org/emergency/cap/v1.2/CAP-v1.2-os.html (point 3.4 has the actual definition) and my current arguments (remove the slash after list if you don't need it):
I apologize if any of this is covered elsewhere, I've spent a lot of time trying different things to try and get it exactly how I'd prefer the output to be. |
Like the Also, currently the output is not fully compatible with nullable reference, e.g. this results in a warning: [RequiredAttribute(AllowEmptyStrings=true)]
[XmlElementAttribute("event")]
public string Event { get; set; } Not sure what the best course of action would be for these cases. This? public string Event { get; set; } = null!; Or perhaps the |
When the
--nullableReferenceAttributes
is set some members are annotated with nullable attributes. At least in my usecases most of the members won't receive any attribute, but should be treates as non nullable. Because the compiler does not emit nullable attributes for tool generated source code. There is currently no easy way to get non oblivious nullability annotations. The only way to enable nullable annotions from the compiler is to explicitly enable#nullable
in the generated source file.Therefore i suggest to add a new flag, that will emit a
#nullable
at the start of the generated file.From a pure "does it compile" standing point, it should be save the emit
#nullable enable
whenever--nullableReferenceAttributes
and--netCore
is set. But there might be xsd schemas, that would lead to property falsely annotated as non nullable.The text was updated successfully, but these errors were encountered: