Fix null refs in byte array COM interop#2688
Merged
jtschuster merged 7 commits intodotnet:mainfrom Mar 18, 2022
Merged
Conversation
There may still be holes to be addressed with Roslyn types not being nullable.
vitek-karas
reviewed
Mar 15, 2022
marek-safar
reviewed
Mar 16, 2022
| return false; | ||
|
|
||
| if (typeSymbol.ContainingNamespace.Name == "System" && typeSymbol.Name == "Array") { | ||
| if (typeSymbol.ContainingNamespace?.Name == "System" && typeSymbol.Name == "Array") { |
Contributor
There was a problem hiding this comment.
Don't we have enabled nullable to catch such errors?
Member
Author
|
The issues were fixed by #2692, this now just adds tests. |
tlakollo
approved these changes
Mar 18, 2022
vitek-karas
approved these changes
Mar 18, 2022
Member
|
For my education, how does adding new tests fix the original issue? Where is the source code change that fixed #2686? |
Member
5 tasks
agocke
pushed a commit
to dotnet/runtime
that referenced
this pull request
Nov 16, 2022
16 tasks
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.
Roslyn API doesn't use nullable types and will return null on properties and fields that aren't annotated with the
?. The linker assumes that fields will not be null, and those issues tend to appear most frequently with COM interop when a type doesn't have a namespace.This fixes the null reference in a minimal repro, but there are likely more holes to address #2687.
This should fix #2686.
I wasn't sure where the test case best fits in, so it's in a separate file in the
Interoptest cases folder. Let me know if there's a better place for it.