Skip to content

Enable nullable reference types solution-wide (but #nullable disabled marked for existing code)#207

Merged
FlorianRappl merged 1 commit intoAngleSharp:develfrom
jafin:chore/enable-nullable
Mar 28, 2026
Merged

Enable nullable reference types solution-wide (but #nullable disabled marked for existing code)#207
FlorianRappl merged 1 commit intoAngleSharp:develfrom
jafin:chore/enable-nullable

Conversation

@jafin
Copy link
Copy Markdown
Contributor

@jafin jafin commented Mar 28, 2026

Types of Changes

Prerequisites

Please make sure you can check the following two boxes:

  • I have read the CONTRIBUTING document
  • My code follows the code style of this project

Contribution Type

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue, please reference the issue id)
  • New feature (non-breaking change which adds functionality, make sure to open an associated issue first)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Description

Files with non-trivial nullable warnings get #nullable disable to preserve current behavior.
Relates to #157 (comment)

Aligns to approach seen in parent project to enable globally. and mark disable.

Files with non-trivial nullable warnings get #nullable disable to preserve current
behavior.
@FlorianRappl
Copy link
Copy Markdown
Contributor

Hm just disabling it would not be so efficient (i.e., it would not close the comment). Sure it's a first step - but why not use the feature/nullable branch as a basis.

We can also apply the PR (but call it "Migration to nullable types - Step 0: Enabling"). To me the title sounded (but that might be just me) like it brings also nullable types to the project, which it does not. It actually turns it on to explicitly turn it off in almost all interesting scenarios / files.

What's your opinion? Merge it in - but then slowly migrate the rest of the files where applicable? (There are some scenarios where AngleSharp already makes a mistake and puts out some field as non-nullable, while it's not only nullable from a logical POV, but already used/initialized with null)

@FlorianRappl FlorianRappl added this to the v1.0 milestone Mar 28, 2026
@jafin
Copy link
Copy Markdown
Contributor Author

jafin commented Mar 28, 2026

My primary motivation was to reduce the build warning CS8632.The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Turning on <Nullable>enable</Nullable> resolves those warnings.

I understand there is a zero value beyond that.

I likely won't have capacity to look at all nullable fixes, plus it is so far reaching I'd be concerned of not fully getting things right, so its a up for grabs. I thought this was an ok first step.

@jafin jafin changed the title Enable nullable reference types solution-wide Enable nullable reference types solution-wide (but #nullable disabled marked for existing code) Mar 28, 2026
Copy link
Copy Markdown
Contributor

@FlorianRappl FlorianRappl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get this rolling. Thanks!

@FlorianRappl FlorianRappl merged commit 9fe99fa into AngleSharp:devel Mar 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants