Skip to content
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

Address various minor param-nullchecking issues #58321

Merged
merged 5 commits into from
Dec 15, 2021

Conversation

RikkiGibson
Copy link
Contributor

@RikkiGibson RikkiGibson commented Dec 14, 2021

IL_0002: newobj ""C.<GetChars>d__0..ctor(int)""
IL_0007: ldarg.1
IL_0008: ldstr ""s""
IL_000d: call ""ThrowIfNull""
Copy link
Member

Choose a reason for hiding this comment

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

I was a bit surprised to see us create the state machine then do the null check. Given that we do the null check before calling base / this ctor would've expected the null check first here.

Not blocking if everyone else feels that way, can deal with it in a follow up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A few test plan items are marked "address after merge". I think it would be fine to add a similar item to the test plan #36024 to see if we can improve this.

Comment on lines 1816 to 1833
[Fact]
public void Override_NullCheckedDifference()
{
var source =
@"
class Base
{
public virtual void M1(string x!!) { }
public virtual void M2(string x) { }
}

class Derived : Base
{
public override void M1(string x) { }
public override void M2(string x!!) { }
}";
var verifier = CompileAndVerify(source);
verifier.VerifyDiagnostics();
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if it does make sense to also run this test with NRT enabled and still ensure no nullable-related warnings are produced?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. Done.

@@ -7977,7 +7986,7 @@ private void VisitThisOrBaseReference(BoundExpression node)
var parameter = node.ParameterSymbol;
int slot = GetOrCreateSlot(parameter);
var parameterType = GetDeclaredParameterResult(parameter);
var typeWithState = GetParameterState(parameterType, parameter.FlowAnalysisAnnotations);
var typeWithState = GetParameterState(parameterType, parameter.FlowAnalysisAnnotations, parameter.IsNullChecked);
Copy link
Member

Choose a reason for hiding this comment

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

parameter.IsNullChecked

Are we testing a case where this value makes a difference (from passing false for instance)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oop, I might not have addressed this. Looking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there's not an obvious scenario where we can observe a behavior difference so I'm not going to add specific tests for it at this time.

@RikkiGibson RikkiGibson enabled auto-merge (squash) December 14, 2021 22:58
@RikkiGibson RikkiGibson merged commit 81e44e1 into dotnet:features/param-nullchecking Dec 15, 2021
@RikkiGibson RikkiGibson deleted the pnc-misc branch December 15, 2021 00:03
333fred added a commit to 333fred/roslyn that referenced this pull request Dec 16, 2021
…rations

* upstream/main: (87 commits)
  Add support for nullable analysis in interpolated string handler constructors (dotnet#57780)
  Record list-patterns and newlines in interpolations as done (dotnet#58250)
  Swithc to acquiring the component model on a BG thread.
  Fix failure to propagate cancellation token
  [main] Update dependencies from dotnet/arcade (dotnet#58327)
  Change PROTOTYPE to issue reference (dotnet#58336)
  Resolve PROTOTYPE comments in param null checking (dotnet#58324)
  Address various minor param-nullchecking issues (dotnet#58321)
  Nullable enable GetTypeByMetadataName (dotnet#58317)
  Support CodeClass2.Parts returning parts in source generated files
  Allow the FileCodeModel.Parent to be null
  Ensure the CodeModel tests are using VisualStudioWorkspaceImpl
  Fix the bad words in TestDeepAlternation
  Fix regression in Equals/GetHashCode of LambdaSymbol. (dotnet#58247)
  Support "Enable nullable reference types" from disable keyword
  Support "Enable nullable reference types" from restore keyword
  Support "Enable nullable reference types" on the entire directive
  Add comment
  Remove descriptor
  Update src/Workspaces/Remote/ServiceHub/Services/SemanticClassification/RemoteSemanticClassificationService.cs
  ...
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.

4 participants