Comments (4)
I'm still a bit surprised that this runs at all. Part of the reason that we banned ref struct
in expression trees is because, at the time at least, they would not actually be able to compile and execute. It seems like at least in some cases there is no issue executing the code.
@VSadov, @agocke can you all help clarify when an expression tree can and cannot call a method that has a ref struct
parameter?
from roslyn.
I think most expression trees would compile and run fine. A problematic one was for example with default(RefStruct)
constant because that would be passed into Expression.Constant
as an object
parameter and hence boxed - as explained in #30776 (comment).
(A related issue: #31957)
from roslyn.
Bringing up part of the conversation from that issue
However the Expression.Constant(object, Type) requires the default(Struct1) to be boxed into object, which ref structs don't support.
In this case though default
isn't a constant, it's a value. Is it just a terminology issue and we typically represent using the Expression.Constant
API?
@RikkiGibson as he wrote the statement I'm questioniing 😄
from roslyn.
I think most expression trees would compile and run fine.
I'm not sure about most. I think the problematic cases are where ref structs are used as literals (the constant case) or captured. My recollection here was rather than try to enumerate all the problematic cases, we just banned them entirely.
from roslyn.
Related Issues (20)
- [Automated] PRs inserted in VS build main-35123.88
- ForAttributeWithMetadataName from CompilerVisibleItemMetadata HOT 5
- CSharpSemanticModel.GetSymbolInfo returns SymbolInfo with Symbol equal to null HOT 4
- String interpolation of only strings should light-up with string.Concat(params ReadOnlySpan<string>) HOT 10
- Collection expressions apply to types implementing IEnumerable<T> and containing an Add(X) method but no implicit conversion between X and T HOT 2
- Copilot Rename Suggestions: No suggestions for identifiers referenced in methods that touch the end of file
- [Automated] PRs inserted in VS build feature.debugger.main-35124.136
- Roslyn Scripting APIs for Blazor WebAssembly
- new() with Nullable<DateTime> type HOT 3
- LibraryImport causes CS8795 HOT 7
- [Automated] PRs inserted in VS build main-35125.79
- MS.CA.LanguageServer depends on MS.VS.Telemetry via Microsoft.CodeAnalysis.Remote.Workspaces
- Inellisense popup for XML documentation should honor Whitespace in ALL elements HOT 2
- Nuget Package Microsoft.CodeAnalysis.CSharp.Workspaces 4.5.0 is broken.
- lang=sql support HOT 1
- [Automated] PRs inserted in VS build feature.debugger.main-35125.232
- Strange Exceptions During Binding HOT 3
- c# - Renaming a field can cause it to rename the same word in the comments in other files in the same project that are completely unrelated HOT 1
- Raw string literals should be reindented like any code
- SPAM
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.