Skip to content

fix: detect MaybeNull/AllowNull on properties from referenced assemblies#2333

Merged
latonz merged 1 commit into
riok:mainfrom
latonz:fix/2192-maybenull-cross-assembly
Jun 22, 2026
Merged

fix: detect MaybeNull/AllowNull on properties from referenced assemblies#2333
latonz merged 1 commit into
riok:mainfrom
latonz:fix/2192-maybenull-cross-assembly

Conversation

@latonz

@latonz latonz commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

For symbols loaded from metadata, Roslyn exposes the MaybeNull/AllowNull flow attributes on the getter return value / setter value parameter instead of the property itself. SymbolAccessor only checked the property symbol, so cross-assembly source properties were treated as non-nullable, omitting the null guard and producing CS8601.

Add TryHasGetAttribute/TryHasSetAttribute helpers that also inspect the accessors and use them in IsReadNullable/IsWriteNullable.

Fixes #2192

Checklist

  • I did not use AI tools to generate this PR, or I have manually verified that the code is correct, optimal, and follows the project guidelines and architecture
  • I understand that low-quality, AI-generated PRs will be closed immediately without further explanation
  • The existing code style is followed
  • The commit message follows our guidelines
  • Performed a self-review of my code
  • Hard-to-understand areas of my code are commented
  • The documentation is updated (as applicable)
  • Unit tests are added/updated
  • Integration tests are added/updated (as applicable, especially if feature/bug depends on roslyn or framework version in use)

@latonz latonz self-assigned this Jun 22, 2026
For symbols loaded from metadata, Roslyn exposes the MaybeNull/AllowNull
flow attributes on the getter return value / setter value parameter instead
of the property itself. SymbolAccessor only checked the property symbol, so
cross-assembly source properties were treated as non-nullable, omitting the
null guard and producing CS8601.

Add TryHasGetAttribute/TryHasSetAttribute helpers that also inspect the
accessors and use them in IsReadNullable/IsWriteNullable.

Fixes riok#2192
@latonz
latonz force-pushed the fix/2192-maybenull-cross-assembly branch from a3eacde to b326c23 Compare June 22, 2026 15:23
@latonz latonz added the bug Something isn't working label Jun 22, 2026
@latonz
latonz merged commit bd200e5 into riok:main Jun 22, 2026
17 of 18 checks passed
@latonz
latonz deleted the fix/2192-maybenull-cross-assembly branch June 22, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CS8601 while mapping properties annotated with MaybeNullAttribute

1 participant