Skip to content

Refactor PropertyResolverGenerator to handle nullable properties and update tests for resolver generation#2

Merged
tombiddulph merged 1 commit intomainfrom
add-default-output
Feb 6, 2026
Merged

Refactor PropertyResolverGenerator to handle nullable properties and update tests for resolver generation#2
tombiddulph merged 1 commit intomainfrom
add-default-output

Conversation

@tombiddulph
Copy link
Owner

This pull request enhances the property resolver generator to correctly handle nullable properties and improves the generated code's handling of these cases. It also updates and expands the test suite to ensure that resolvers are always generated (even if empty) and that nullable and non-nullable properties are handled as expected.

Generator improvements:

  • The generator now detects whether a property is nullable (either nullable value type or nullable reference type) and uses the null-conditional operator (?.ToString()) in the generated resolver code for such properties. Non-nullable properties use the standard .ToString() call. [1] [2] [3] [4] [5] [6]

Test updates and additions:

  • Tests are updated to expect that resolvers are always generated, even when there are no matching or only generic types, and to verify that the generated code is empty in those cases. [1] [2] [3] [4]
  • New tests verify that nullable reference and value type properties use the null-conditional operator in the generated code, while non-nullable properties do not.

Code modernization:

  • Uses C# collection expressions for constructing arrays more concisely in resolver config parsing.

@tombiddulph tombiddulph merged commit c17e516 into main Feb 6, 2026
1 check passed
@tombiddulph tombiddulph deleted the add-default-output branch February 6, 2026 11:18
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