Replies: 8 comments
-
Beta Was this translation helpful? Give feedback.
-
And it would not require any CLR changes, as it is already supported by the CLR! by the way: Merry Christmas! |
Beta Was this translation helpful? Give feedback.
-
Duplicate of #709 (which itself was a dupe of dotnet/roslyn#8542) |
Beta Was this translation helpful? Give feedback.
-
There are things called documentation, annotation and comment. have you tried them?
or you can request for additional attributes. maybe there are some attributes already that I'm not aware of. or
@Unknown6656 I don't know much about CLR but I would be surprised if it wasn't supported. I don't see how it is related to CLR anyway. @comfyneet This proposal breaks those rules. don't name methods like that or if you will, then don't expect compiler to worship you! there are better ways, like using annotation, documentation or comment if you will. this article might be helpful for you. https://en.wikipedia.org/wiki/Naming_convention_(programming) |
Beta Was this translation helpful? Give feedback.
-
There are at least two "challenges" with this feature:
Now, I'd be glad to drop Xbehave and use this just for testing but then when I really think about it, it comes down to whether the language allows me to express the things I think about or need to achieve in a natural and readable manner and it does thanks to the tools I use so it comes down to the question of why would I replace the tools I use today with something like this and the answer is as follow:
Finally, regardless to all of these points I really have hard time imagine the C# team approve such a feature but I've been wrong before so go figure. 😄 p.s. Sorry for mentioning Xbehave too many times, looks like I'm doing PR but I thought to share my own experience and how I solve this problem today. |
Beta Was this translation helpful? Give feedback.
-
@MkazemAkhgary I don't understand how this suggestion would confuse the compiler at all, because the identifiers are enclosed in the backtick marks.
@eyalsk It probably doesn't contrast the .Net ecosystem as it also has the F# language, currently we can't call F# ticked functions directly from C# code without using the attribute Also, in my opinion combining this breaking change with source generator feature will help us work with loosely structured data easier. |
Beta Was this translation helpful? Give feedback.
-
@comfyneet I and others have suggested this feature some time ago because I agree and think it would really help the language. #709. I also suggested allowing any character and keywords along with spaces between the tick marks. Then you could have numbers, hyphens, spaces, symbols and more for identifiers. static class `Workout Equipment` static void `Begin Workout`() } static void `Begin-Item-Init`() } `Workout Equipment`.`Cost and Value` = "30%"; |
Beta Was this translation helpful? Give feedback.
-
@comfyneet So show me APIs in the FCL that have spaces in them outside to F#. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I suggest C# should allow spaces in identifier names, to make test names more readable, and easier to interop with F# libraries.
When writing test cases, many people often use self-explaining method names. But long PascalCase names are hard to read (e.g.
When2IsAddedTo2Expect4()
), many tend to work around this issue by using underscores (e.g.When_2_Is_Added_To_2_Expect_4()
), inappropriately they don't follow .NET naming conventions. I suggest we should add single-backtick marks `identifier` syntax, or alternatively F# double-backtick marks ``identifier`` syntax, to have a clearer, straightforward names.Backtick definition copied from F# spec: "Any sequence of characters that is enclosed in double-backtick marks (`` ``), excluding newlines, tab, and backtick themselves, is treated as an identifier". For example:
The backtick syntax makes the test results much easier to read. Here is the output of the test with a standard class name:
vs. the output using the more friendly name:
Beta Was this translation helpful? Give feedback.
All reactions