Comments (3)
The issue you're encountering where VSTHRD103 doesn't trigger when accessed using the null-conditional operator (?.) might be a limitation of the current version of the Microsoft.VisualStudio.Threading.Analyzers library. To work around this issue, you can follow these steps:
-
Manually Check for Null:
Instead of relying solely on the null-conditional operator, manually check if the result of
SomethingAsync()
is null before accessing theResult
property. This way, you can ensure that VSTHRD103 is triggered:public async Task DoAsync() { var a = SomethingAsync().Result; // Triggers VSTHRD103 var result = SomethingAsync(); if (result != null) { var b = result.Result; // Triggers VSTHRD103 } }
By manually checking for null, you make sure that the analyzer recognizes the potential issue with accessing
Result
in a non-async context. -
Check for Updates:
Keep an eye on updates to the
Microsoft.VisualStudio.Threading.Analyzers
library. The behavior you described might be a bug that is fixed in a later version of the library. Check for updates and upgrade to a newer version if it becomes available. -
Report the Issue:
If you believe this is a genuine bug in the analyzer and it's not fixed in the latest version, consider reporting the issue to the Visual Studio team on their GitHub repository. Provide a clear description of the problem and any relevant code examples to help them understand and address the issue.
Here is the link to the GitHub repository where you can report issues: https://github.com/microsoft/vs-threading
Reporting the issue directly to the maintainers can help ensure that it gets the necessary attention and is addressed in a future release of the library.
from vs-threading.
Thanks for the report @bjornhellander.
@sujitmahapatra I can't fault what you say. I'm guessing though that it's AI-generated text (and as I guessed, that's an interest of yours from your github profile). The text seems both customized yet boilerplate like AI would have generated. Advising that the issue be reported as a github issue when that is exactly what you're responding to feels... a bit AI like.
Am I right?
from vs-threading.
from vs-threading.
Related Issues (20)
- VSTHRD004 fires for SwitchToMainThreadAsync().NoThrowAwaitable()
- No release notes after v17.6.40 HOT 2
- Is VSTHRD011 (Use AsyncLazy<T>) missing from AppWithoutMainThread.editorconfig ? HOT 1
- VSTHRD004 is misreported on call sites that update the awaitable returned from SwitchToMainThreadAsync HOT 1
- VSTHRD200 should not fire for API Methods HOT 4
- Dispatcher-based JoinableTaskFactory should post messages more conservatively
- New API consideration: JoinableTaskContext.OnMainThreadBlocked HOT 6
- Call JoinableTaskFactory(new JoinableTaskContext()).RunAsync() in InitializeComponent caused designer error HOT 2
- VSTHRD010 warning despite call to JoinableTaskFactory.SwitchToMainThreadAsync HOT 1
- Is the Analyzer library included implicity in the dotnet or should be downloaded separatedly? HOT 1
- Struggling to enforce "always need await" HOT 1
- RequestIds in PostExecutionStart/Stop events are not unique for different call stacks HOT 3
- System.Memory is not referenced in the built nuspec despite being referenced in the Assembled dll HOT 1
- Documentation for AsyncQueue.IsCompleted is incorrect; should indicate it depends on whether the queue is emptp
- Generic overloads of ReentrantSemaphore.ExecuteAsync that work with Task<T> HOT 3
- Analyzers for lock primitives that need thread affinity
- Disable VSTHRD103 if CA1849 exists HOT 1
- Disable VSTHRD200 for test methods
- VSTHRD200 should be able to have method type configured HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vs-threading.