Draft
Add RP0001 Roslyn analyzer for nullable reference type support#563
Conversation
6 tasks
Copilot
AI
changed the title
[WIP] Support for nullable reference types
Add RP0001 Roslyn analyzer for nullable reference type support
Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nullable reference types are enabled, but the compiler cannot flag the one case that produces a silent
null: aReactiveProperty-family value created for a non-nullable reference type without an initial value initializesValuetodefault(T)(i.e.null). Removing the historical default constructors would be a breaking change, so this is addressed with an analyzer — the approach converged on in the issue discussion.Analyzer (
RP0001, categoryUsage, Warning)Source/ReactiveProperty.Analyzerproject (netstandard2.0) withReactivePropertyNullableAnalyzer.new ReactiveProperty<T>(),new ReactivePropertySlim<T>(),new ReadOnlyReactivePropertySlim<T>(source)source.ToReadOnlyReactivePropertySlim(),source.ToReadOnlyReactiveProperty()T?, open type parameters, and code with the nullable context disabled.ToReadOnly*extension methods,Tis taken from the sourceIObservable<T>element type — the compiler infers those methods' return type asT?because of theirinitialValue = defaultparameter, so the return type can't be used.Packaging
ReactiveProperty.CoreandReactivePropertypackages underanalyzers/dotnet/cs(referenced withReferenceOutputAssembly="false", so it adds no runtime dependency).Tests & docs
Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.MSTest.0006.Out of scope
The
ReactiveProperty(NETStandard) assembly has 91 pre-existing internal nullable warnings unrelated to this change; resolving them would touch public API nullability annotations (potentially breaking) and is left as separate follow-up work.