Nullable enable GetTypeByMetadataName#58317
Merged
333fred merged 2 commits intodotnet:mainfrom Dec 14, 2021
Merged
Conversation
Member
Author
|
@dotnet/roslyn-compiler for a fairly mechanical review. No code semantics should be changed by this PR. |
acbff46 to
dcd5abb
Compare
RikkiGibson
approved these changes
Dec 14, 2021
Member
Author
|
@dotnet/roslyn-compiler for a second review. |
Member
|
Looks like some usages might need updating? |
Member
Author
|
@dotnet/roslyn-compiler for a second review. |
cston
approved these changes
Dec 14, 2021
AlekseyTs
reviewed
Dec 14, 2021
| { | ||
| var result = Assembly.GetTypeByReflectionType(type, includeReferences: true); | ||
| if ((object)result == null) | ||
| if (result is null) |
Contributor
Member
There was a problem hiding this comment.
A change of some sort is necessary to (object?) or use is. Personally, I'm happy with the latter.
Member
Author
There was a problem hiding this comment.
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.
AlekseyTs
reviewed
Dec 14, 2021
| TypeSymbol? symbol = Assembly.GetTypeByReflectionType(HostObjectType, includeReferences: true); | ||
|
|
||
| if ((object)symbol == null) | ||
| if (symbol is null) |
Contributor
AlekseyTs
reviewed
Dec 14, 2021
| 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++) |
Contributor
AlekseyTs
reviewed
Dec 14, 2021
| } | ||
|
|
||
| return ((object)type == null || type.IsErrorType()) ? null : type; | ||
| return (type is null || type.IsErrorType()) ? null : type; |
Contributor
Contributor
|
@333fred Please revert style-only changes. |
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 ...
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.
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.