-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: NameOf to have optional parameters. #3759
Comments
In what situations would this be useful? |
A better solution would be to use pragmas to control the output/options. |
That has been largely discussed on Codeplex. It was even discussed |
@svick this may useful in `Exception`` when the argument is property path, have a look to this aspnet/WebSockets@208fa4a#diff-2f20d3473af8bc60eee727dd88bbb804R595 |
The parameters to argument exceptions are never "property paths" - they are parameter names. Passing in |
What is wrong with |
@Eilon that's exactly what I mean |
@whoisj that's exactly what I recommend people to use. |
@Eilon I know. My comment was towards the original post. 😏 |
I don't think so that will applicable for |
What won't be? Given void 'MyFunc(string value)'
|
@whoisj our intend to display something like |
@hishamco then I go back to my original statement: what is wrong with |
Looks good trick 😄 |
@AdamSpeight2008 So this is just a performance optimization of |
I said the same thing, they're not looking for
They want to see "foo.Bar.Baz" returned by the |
I agree with @svick . Also some syntax sugar for I pondered during last week on Twitter if something like the following would not be useful (also mentioned by @whoisj):
The tiny benefit here is you only need to change the type of |
How? Doesn't the compiler currently do type-checking at compile-time, which suggests to me the the fully qualified name is also available.. |
@AdamSpeight2008 typeof only loads the type token as determined at compile time, fullname would be constant string. Now imagine some AOP process changing something (namespace, type), etc. If something bad happened, peverify will say the type token is now invalid, but with a string, all bets are off. Perhaps this will never happen, but who knows? |
Regardless of whether we would ever provide support for getting a fully qualified name (seems unlikely), we would not do it in the way requested here. |
Proposal: NameOf to have optional parameters.
Currently.
nameof(Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider)
="CodeFixProvider"
(See #3708)
To fix this I propose that we should extend NameOf with optional parameters.
, NameOfOptions:= )
NameOfOption Enum
Api signature
Example
This would then provide the fully-qualified name.
It provides a compile-time solution, to what (I believe) requires the use of reflection, or explicitly stating the full name as a string literal. Hence introducing a potential bug if it changes namespace or name.
Does not break existing usage because the parameter is optional.
The text was updated successfully, but these errors were encountered: