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

Nullable enable GetTypeByMetadataName #58317

Merged
merged 2 commits into from
Dec 14, 2021

Conversation

333fred
Copy link
Member

@333fred 333fred commented Dec 14, 2021

In preparation for working on #57802, I nullable-enabled the implementation of GetTypeByMetadataName in C# as I was reading through it to understand how it currently works.

@333fred 333fred requested a review from a team as a code owner December 14, 2021 01:27
@333fred
Copy link
Member Author

333fred commented Dec 14, 2021

@dotnet/roslyn-compiler for a fairly mechanical review. No code semantics should be changed by this PR.

@333fred 333fred force-pushed the nullable-enable-gettypebymetadataname branch from acbff46 to dcd5abb Compare December 14, 2021 01:28
@333fred
Copy link
Member Author

333fred commented Dec 14, 2021

@dotnet/roslyn-compiler for a second review.

@RikkiGibson
Copy link
Contributor

Looks like some usages might need updating?

@333fred
Copy link
Member Author

333fred commented Dec 14, 2021

@dotnet/roslyn-compiler for a second review.

@@ -1562,7 +1562,7 @@ internal override ISymbolInternal CommonGetSpecialTypeMember(SpecialMember speci
internal TypeSymbol GetTypeByReflectionType(Type type, BindingDiagnosticBag diagnostics)
{
var result = Assembly.GetTypeByReflectionType(type, includeReferences: true);
if ((object)result == null)
if (result is null)
Copy link
Contributor

@AlekseyTs AlekseyTs Dec 14, 2021

Choose a reason for hiding this comment

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

if (result is null)

Is this a "style-only" change? Please revert if so. #WontFix

Copy link
Member

Choose a reason for hiding this comment

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

A change of some sort is necessary to (object?) or use is. Personally, I'm happy with the latter.

Copy link
Member Author

Choose a reason for hiding this comment

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

As Julien said, these lines need to change in some way to avoid the nullable warning for casting to object. Given that, I used the style of null check I prefer.


if ((object)symbol == null)
if (symbol is null)
Copy link
Contributor

@AlekseyTs AlekseyTs Dec 14, 2021

Choose a reason for hiding this comment

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

symbol is null

Is this a "style-only" change? #WontFix

@@ -626,7 +628,7 @@ public NamedTypeSymbol GetTypeByMetadataName(string fullyQualifiedMetadataName)
type = GetTopLevelTypeByMetadataName(ref mdName, assemblyOpt: null, includeReferences: includeReferences, isWellKnownType: isWellKnownType,
conflicts: out conflicts, warnings: warnings, ignoreCorLibraryDuplicatedTypes: ignoreCorLibraryDuplicatedTypes);

for (int i = 1; (object)type != null && !type.IsErrorType() && i < parts.Length; i++)
for (int i = 1; type is object && !type.IsErrorType() && i < parts.Length; i++)
Copy link
Contributor

@AlekseyTs AlekseyTs Dec 14, 2021

Choose a reason for hiding this comment

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

type is object

Is this a "style-only" change? #WontFix

@@ -640,7 +642,7 @@ public NamedTypeSymbol GetTypeByMetadataName(string fullyQualifiedMetadataName)
conflicts: out conflicts, warnings: warnings, ignoreCorLibraryDuplicatedTypes: ignoreCorLibraryDuplicatedTypes);
}

return ((object)type == null || type.IsErrorType()) ? null : type;
return (type is null || type.IsErrorType()) ? null : type;
Copy link
Contributor

@AlekseyTs AlekseyTs Dec 14, 2021

Choose a reason for hiding this comment

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

type is null

Is this a "style-only" change? #WontFix

@AlekseyTs
Copy link
Contributor

@333fred Please revert style-only changes.

@333fred 333fred enabled auto-merge (squash) December 14, 2021 21:55
@333fred 333fred merged commit 3e32282 into dotnet:main Dec 14, 2021
@ghost ghost added this to the Next milestone Dec 14, 2021
@333fred 333fred deleted the nullable-enable-gettypebymetadataname branch December 14, 2021 23:49
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
  ...
@Cosifne Cosifne modified the milestones: Next, 17.1.P3 Jan 5, 2022
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.

6 participants