-
Notifications
You must be signed in to change notification settings - Fork 468
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
CA2213:Disposable fields should be disposed and support for DisposeCoreAsync
#6976
Conversation
Codecov Report
@@ Coverage Diff @@
## main #6976 +/- ##
========================================
Coverage 96.42% 96.43%
========================================
Files 1410 1412 +2
Lines 335956 336528 +572
Branches 11095 11119 +24
========================================
+ Hits 323956 324527 +571
+ Misses 9207 9200 -7
- Partials 2793 2801 +8 |
@Youssef1313 @mavasani Any feedback please? |
Implementation of the fix looks fine to me, but I am not familiar with the semantics and naming requirements of the API for recommended dispose patterns. I'll let someone from the runtime team comment on it - @buyaa-n @carlossanlop @stephentoub @jeffhandley |
Any feedback @buyaa-n @carlossanlop @stephentoub @jeffhandley please? |
Friendly ping. Any feedback @buyaa-n @carlossanlop @stephentoub @jeffhandley please? |
Sorry for late reply @MartyIX, the latest I have never seen |
Thanks @MartyIX, definitely we need to support both names. Looks we could just adjust the name check in |
Agree with all of @buyaa-n's assessment. |
I have updated the code based on the @buyaa-n's suggestion. I'm struggling with the VB test though. Does anyone know how to fix https://github.com/dotnet/roslyn-analyzers/pull/6976/files#diff-5a72cda0b6e4fe072ec3ad611132009049afb0a1d445e15b2997688a9f82ac4eR3741 please? |
...yzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/DisposableFieldsShouldBeDisposedTests.cs
Outdated
Show resolved
Hide resolved
Please see #6976 (comment). It's commented out. I can't figure out how to rewrite C# code above the commented out VB code. |
It would help if you said what particular line of code is getting that error. Looks like Visual Basic's Asynchronous programming with Async and Await does not support |
Yes, something like this. Btw, not even MSVS did give me a useful suggestion how to fix my VB code. |
I removed the VB test. |
@buyaa-n Please review the PR and merge if it looks good to you. |
Co-authored-by: Buyaa Namnan <buyankhishig.namnan@microsoft.com>
Co-authored-by: Buyaa Namnan <buyankhishig.namnan@microsoft.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you @MartyIX
Attempts to fix #4950 but I don't have any clue if the approach of the PR is correct or not.
However, this seems to be in line with https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/implementing-disposeasync#implement-the-async-dispose-pattern except for naming
DisposeCoreAsync
vsDisposeAsyncCore
:Somewhat unrelated: I created a PR in vs-threading repo where I claimed that
DisposeAsyncCore
seemed to be the correct name for the method but this repo usesDisposeCoreAsync
(AFAIK). It's confusing.