Comments (6)
And from language design perspective: this whole idea of allowing more conditional access expressions to compile in context where value is ignored (is it defined by spec?) feels awkward and ad-hoc. What kind of scenarios this solves?
As a tooling developer, I have to disable 'introduce variable' refactoring for such expressions and this may be confusing for developers. Also I have no idea of what semantic model should tell about type of such c?.M()
expression. Is it T
(I think so) or void
?
Maybe (I'm not sure), it's better to allow such calls of methods with non-liftable return types in any context, but simply lift unconstrained T
type (and other non-liftable types) into void
type?
from roslyn.
I think the goal is more to allow it in contexts where the normal '.' dispatching is allowed - for example method calls that return a value are allowed as statement expressions.
The user intention is to find places where a NullReferenceException would normally occur and instead allow for a graceful null-propagation (or at least a lack of throwing) to occur.
from roslyn.
By the way, great catch! I'm thrilled for all of the valuable points that you've been able to help us find as we are trying to land Roslyn v1. 😄
from roslyn.
😉
from roslyn.
It is allowed to have void returning conditional accesses in statement expression scenarios. Scenarios like resource?.Dispose() or event1?.Invoke() seem very useful.
Since we agree on allowing void in such scenarios, it makes sense to remove nullability requirement as well.
from roslyn.
I believe this issue has been addressed already. @VladimirReshetnikov, please verify and close if appropriate.
from roslyn.
Related Issues (20)
- Rename does not work for C# class name in VS 17.9.6 HOT 2
- Serializable exception proposed by visual studio in dotnet 8 HOT 2
- Intellisense hover for suggestions, missing assembly references not working HOT 3
- Visual Studio only detects problems on build
- Include location for required member missing error HOT 1
- [Automated] PRs inserted in VS build main-34920.65
- [Automated] PRs inserted in VS build feature.debugger.main-34920.221
- Taghelpers break build on 8.0.300 with various errors (major impact, Area-Compilers) HOT 3
- IDE0290 code fix is invalid in `ref struct`
- Overlapped icons in inheritance margin HOT 1
- Use same normalization for SectionName, FilePath, and GetOptionsForSourcePath
- [Automated] PRs inserted in VS build feature.debugger.main-34921.105
- [Automated] PRs inserted in VS build main-34921.87
- Respond to obsoletion of ILanguageClientMiddleLayer HOT 1
- intellisense suggestions constructor collection HOT 1
- VerifyRenameLinkedDocumentsAsync is flakey
- RoslynServiceExtensions should be removed in lieu of IAsyncServiceProvider3
- ReplaceMethodWithPropertyCodeRefactoringProvider crash with System.InvalidOperationException : GetCurrentNode returned null
- Outlining Failing for Sub with Optional Parameter
- Unused imports reported during merge conflict resolution HOT 3
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 roslyn.