New type of expression (compile time constant) to use in attributes #8492
Unanswered
dmitry-bym
asked this question in
Language Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Background and Motivation
Im not actualy sure what type of issue create, because i still don't know better implementation.
I want to have Expression inside attribute to use that in source generators. So due to the fact that we can use only constants in attributes we can't use
Expression
however this is useles what i need just expression itself. It will improve source generators experienceOne example:
Usage
It’s very unpleasant to write like this and I would like a more elegant way. with intelliSence and types. So that you can catch type mismatches while writing the code, and not during the build
Proposed API
Proposal is to create some class which will be evaluated at compiled time end will be just a string.
Just public api, so its possible just to get a string
With implicit cast to strings
Ofc its not posible to convert to Expression or Compile, or create from string, it will cause compilation error,
Usage Examples
after compilation
Alternative Designs
Or it could be just analizer
after compilation same string
Risks
Don't see any risk.
Connected to #343
Beta Was this translation helpful? Give feedback.
All reactions