Only report missing disposal interfaces if used#60252
Conversation
| } | ||
|
|
||
| [Fact, WorkItem(45111, "https://github.com/dotnet/roslyn/issues/45111")] | ||
| public void IDisposableInterfaceUnnecessaryForPatternDisposal() |
| { | ||
| void M() | ||
| { | ||
| using (null); |
There was a problem hiding this comment.
This is intended to be like test above, just without the declared local
| } | ||
| "; | ||
| var comp = CreateCompilation(source); | ||
| comp.MakeTypeMissing(WellKnownType.System_IAsyncDisposable); |
There was a problem hiding this comment.
If we can test this case with System.IAsyncDisposable actually missing, we should do that, rather than hiding the type from WellKnownTypes. It looks like CreateCompilationWithTasksExtensions(source) will not include IAsyncDisposable.
There was a problem hiding this comment.
Sure. I'm keeping MakeTypeMissing though, as the set of references included in our various TFMs grows over time.
There was a problem hiding this comment.
MakeTypeMissing() changes the compiler behavior though.
To verify the type is missing in the test, could we simply add Assert.Equal(TypeKind.Error, comp.GetWellKnownType(WellKnownType.System_IAsyncDisposable).TypeKind);?
|
@dotnet/roslyn-compiler for second review. Thanks |
|
/azp run |
|
Azure Pipelines successfully started running 4 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 4 pipeline(s). |
Fixes #45111