-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[main] Unlock build failed due to enabling nullable #45411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
marcpopMSFT
merged 2 commits into
main
from
dev/Jason/unlock-build-failure-due-to-nullable
Dec 11, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we know this is non-null in this case:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, we got strong guidance to avoid ! where possible by adding null checks. That being said, this seems like the compiler should know that this isn't null here and adding a null check seems incorrect as well. @JeremyKuhne in case he has advise or if this is the exception to that no ! guidance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case you can add a
Debug.Assert(sw is not null);ahead of it. That will handle the case where someone changes the logic to where this is no longer true. @jaredpar who is the right person to ping about null analysis?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears this project multi-targetsbetween
net472and other TFMS but runs nullable analysis on all of them. That is the setup I advised against when I went by your desk @marcpopMSFT because it leads to situations like this.Debug.Asserthas no impact on nullable analysis when targetingnet472because it doesn't have the new attributes.Strongly recommend disabling nullable warnings on .NET Framework when you mulit-target with other TFMS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this wait? 180 pull requests are waiting for someone to press merge here. there is a syntax error in main branch for past 24 hours. the first impulse has to be to fix it or revert the change ASAP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, I usually would want to get things right and green before merging as main is not our live branch but apparently enough people are targeting main that I'll go ahead and let it in as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaredpar I tried adding your suggestion of disabling nullable warnings for MT netfx builds but that doesn't work: #45420
I can confirm locally that DisableNullableWarnings is true in the netfix CLI.Utils build but I still get this warning:
C:\repos\sdk\src\Cli\Microsoft.DotNet.Cli.Utils\Command.cs(82,21): error CS8602: Dereference of a possibly null reference. [C:\repos\sdk\src\Cli\Microsoft.DotNet.Cli.Utils\Microsoft.DotNet.Cli.Utils.csproj]