Skip to content
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

emit #nullable enable pragma in generated C# code #1196

Open
robinei opened this issue Oct 2, 2023 · 0 comments
Open

emit #nullable enable pragma in generated C# code #1196

robinei opened this issue Oct 2, 2023 · 0 comments

Comments

@robinei
Copy link

robinei commented Oct 2, 2023

Right now the bond-generated C# code allows null references for all reference types.

This is because all generated code is excluded from nullability analysis and references are implicitly treated as nullable (<Nullable>enable</Nullable> in the .csproj does not apply to generated code). The reason for this is to not break code generators.

The intention is that code generators should opt in using the #nullable enable pragma at the top of emitted files. The bond compiler should do this, otherwise non-nullability does not apply.

This should be enabled with a command line option to the bond compiler. And possibly picked up from a property in the project settings (for the project that has and compiles the bondfile).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants