Skip to content

🌍 #343 Enable generating nullable types by reflection#359

Merged
nth-commit merged 1 commit into
mainfrom
terra/generating-nullable-reference-types
Aug 11, 2022
Merged

🌍 #343 Enable generating nullable types by reflection#359
nth-commit merged 1 commit into
mainfrom
terra/generating-nullable-reference-types

Conversation

@nth-commit

Copy link
Copy Markdown
Owner

What a mission nullability reflection in C# is.

We now reflect types augmented with the ? syntax, and pass them through to Gen.Nullable. This includes properties, fields and parameters (including constructor arguments, like when we generate records).

Syntax like Gen.Create<string?> does not capture the nullability context, so it's impossible to generate nulls for these. However, most likely the entrypoint to generation will be a method parameter (when writing properties), so consumers will likely be unaffected. I've added a where T : notnull constraint to these methods now, not that it is strictly required, but will prompt users down the right path if they run into it.

What a mission nullability reflection in C# is.

We now reflect types augmented with the `?` syntax, and pass them through to `Gen.Nullable`. This includes properties, fields and parameters (including constructor arguments, like when we generate records).

Syntax like `Gen.Create<string?>` does not capture the nullability context, so it's impossible to generate nulls for these. However, most likely the entrypoint to generation will be a method parameter (when writing properties), so consumers will likely be unaffected. I've added a `where T : notnull` constraint to these methods now, not that it is strictly required, but will prompt users down the right path if they run into it.
@nth-commit
nth-commit merged commit 88d1187 into main Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant