Replies: 318 comments
-
Spec: https://github.com/dotnet/roslyn/blob/master/docs/features/generators.md |
Beta Was this translation helpful? Give feedback.
-
@mattwar Are you guys still actively working on this feature or has it been tabled for now due to the implementation complexity? |
Beta Was this translation helpful? Give feedback.
-
No news on this? |
Beta Was this translation helpful? Give feedback.
-
I just read @MadsTorgersen 's design notes that said this feature is blocked from somewhere else not on the language end. Could you guys please elaborate? Is the VS tooling the roadblock here now? In my view, this feature is far and away the most useful one out of the entire backlog for C#. I know the brass likes to dedicate resources to issues that community puts a lot of votes on, so I've made a UserVoice issue as well. Please vote for this feature here and on UserVoice! |
Beta Was this translation helpful? Give feedback.
-
Yes. VS tooling is the roadblock. This work will require substantial resources to get through the tooling side in any sort of sensible and efficient manner. It requires coordination between many different teams as well. As such, while still super great and valuable, it's unclear what the right timeline/delivery avenue would be for it. |
Beta Was this translation helpful? Give feedback.
-
Sorry if this is a dumb question but what exactly does tooling mean here? Sounds like there's nothing the community can do, or is there? |
Beta Was this translation helpful? Give feedback.
-
Everything about the experience in a product like VS. That includes, but is not limited to:
etc. etc. |
Beta Was this translation helpful? Give feedback.
-
@CyrusNajmabadi Just for clarification it won't be strictly specific to Visual Studio, right? |
Beta Was this translation helpful? Give feedback.
-
I'm not sure i understand your question @eyalsk . Can you clarify? |
Beta Was this translation helpful? Give feedback.
-
@CyrusNajmabadi I'm asking whether these features you mentioned like IntelliSense, Navigation, Debugging are going to be available in say Visual Studio Code or any other editor? as opposed to being available in Visual Studio only. |
Beta Was this translation helpful? Give feedback.
-
The owners of those respective products would have to make a decision on that. :) |
Beta Was this translation helpful? Give feedback.
-
@CyrusNajmabadi Got'cha, thanks. 😉 |
Beta Was this translation helpful? Give feedback.
-
Why couldn't you guys just add the feature to the compiler and the IDE support will come whenever it comes? This is certainly the strategy TypeScript takes, where language/compiler features sometimes don't get VS support for months/years after they're introduced. |
Beta Was this translation helpful? Give feedback.
-
Because the IDE experience won't meet the user experience bar we've set for language changes. Plus, it will just be a terrible experience. Think about it this way, if there's no IDE support, and you have a code generator that generates symbols that you try to reference, then you'll get tons of error squiggles that never go away as you're trying to use the IDE. |
Beta Was this translation helpful? Give feedback.
-
What doesn't make sense is the arbitrarily different bar for different MS products:
Basically, my point is C# language evolution shouldn't be constantly hamstrung by Microsoft's internal politics. The language team should be able to add features and let IDE support catch up (as it should be). That's how nearly every other open source language works. Put the feature behind an opt-in flag until you're comfortable the VS support is up to snuff. In the meantime, JetBrains will probably have R# and Rider fully supporting within 3 months. If the feature is forced to wait for the stars to align inside Microsoft, it'll likely be a minimum 5-10 years before it actually ships. |
Beta Was this translation helpful? Give feedback.
-
I'm stoked about the C# 9 built-in feature. I'd love to try a prototype. |
Beta Was this translation helpful? Give feedback.
-
About the source generator proposal, Can it brings https://doc.rust-lang.org/rust-by-example/macros.html Example: Implementing Ruby’s HashMap syntax in Rust (Procedural) Macros in Rust is so powerful, We can generate source codes with custom DSLs, syntax and much more. |
Beta Was this translation helpful? Give feedback.
-
Custom DSLs are very intentionally not in scope for this. |
Beta Was this translation helpful? Give feedback.
-
@HamedFathi rust macros are known for poor IDE integration, especially procedural ones. I don't think it worth taking them as they are even if LDM was interested in it, which they aren't. |
Beta Was this translation helpful? Give feedback.
-
I really like how macros work in Rust. So things like Serde (mapping to struct directly ) are possible without using reflection. This would change completely the way you can create your serializer and it would improve performance a lot. You could generate your mapping/serialization methods. Now the workarounds are - reflection caching, expression trees(but that requires compiling during runtime) or using some external tool for generation. Or using some kind of AOP like Fody , PostSharp... but it adds a dependency. @Pzixel there is always room for improvement and plugins are constantly evolving. |
Beta Was this translation helpful? Give feedback.
-
@bugproof rust macros are bad for two reasons
I'd like to have macro system in C#, but LDM don't think so. This is why I probably will switch to scala when next major version comes. Partial evaluation, HKT, functional paradigm - all the nice stuff. MS has different priorities for C#, sadly. |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
@Pzixel @bugproof please move this discussion somewhere else. It is offtopic for this issue. |
Beta Was this translation helpful? Give feedback.
-
It's great that this is being worked on, but I wonder what is C#-specific about this? Isn't there a way of making this language-independent, in the sense that:
|
Beta Was this translation helpful? Give feedback.
-
Isn't this just a description of IL... ? If you want a non-C#-specific, language-independent, way to pass information into a compilation... isn't that just a dll?
Isn't that IL? Basically, why would we need a special feature for this since it's already the fully supported scenario? |
Beta Was this translation helpful? Give feedback.
-
@charlesroddie to be clear, this proposal is not being worked on. This proposal is |
Beta Was this translation helpful? Give feedback.
-
I think #45648 is a good middle-way proposal between this proposal (original/replace) and the Source Generators proposal being implemented for C# 9.(https://github.com/dotnet/roslyn/issues/45648) |
Beta Was this translation helpful? Give feedback.
-
I like source generators, but I'm not used to insert code over strings, that's ugly. Maybe some limited form of dlang templates + String to macro expansion: static foreach(String type in ["class","struct"])
static foreach(String fieldName in ["a","b"])
static foreach(String fieldType in ["Int,","Float"])
$type {
public $FieldType $fieldName;
} Generating 2^3 types. In contrast to Source generators, we only put those code fragments in strings which are changing and expand them by static foreach(BlockKwString type in ["class","struct","unknown"])
static foreach(IdentifierString fieldName in ["a","b"])
static foreach(TypeString fieldType in ["Int,","Float"])
$type {
public $FieldType $fieldName;
} Also, mixins for code insertion would also be beneficial. |
Beta Was this translation helpful? Give feedback.
-
We are maintaining a private fork of Roslyn that allow for code rewriting. It is used in our product Metalama. We are considering making this fork open source, but given the additional work it requires, we would like to probe the level of interest first. Please vote and contribute to this GitHub discussion and detail the use cases you have in mind. The principal interface is the ISourceTransformer interface and it allows for a complete replacement of the |
Beta Was this translation helpful? Give feedback.
-
See also
Beta Was this translation helpful? Give feedback.
All reactions