| Issue 70: | C#/Java Syntax issue | |
| 4 people starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem?
1. Test the following lines
class Foo
{
public string Version {get; set;}
public void Bar()
{
//do something
}
}
2. The class name "Foo" and the method name "Bar" are both marked as types
(i.e. css class "typ") so they end up having the same color.
3. Class names (Types) have the same CSS class name "typ" as Method &
Property names
What is the expected output? What do you see instead?
Method & Properpty names should have their own CSS class
Please use labels and text to provide additional information.
|
|
,
May 19, 2009
I don't see the issue in Java. Java style guidelines specify that type names and only type names are upper-camel-case. What is the convention for C#? |
|
,
May 20, 2009
This is not a convention issue. All I'm saying is class "names" and method "names" should not have the same CSS class name (i.e. "typ"). In any IDE (Visual Studio,Eclipse,TextMate etc.) class names have a different "color" from method names. |
|
,
May 20, 2009
This implementation does not fully parse either language so it cannot distinguish between a class and a package name except by convention. |
|
,
May 21, 2009
obviously you don't understand English.
This is what is expected:
<pre>
class <span class="type">Foo</span>
{
public string Version {get; set;}
public void <span class="method">Bar</span>()
{
//do something
}
}
</pre>
|
|
,
Aug 14, 2009
In C#, properties and methods should be UpperCamelCase. |
|
,
Aug 15, 2009
I am not talking about coding style, I am talking about setting different css style classes for type names (e.g. class Boolean => Bolean = class name) and for method names (e.g. void UpdateCustomer(Customer c) => UpdateCustomer = method name). FTW: UpperCamelCase ??? |
|
,
Aug 15, 2009
Type names and method names _are_ highlighted differently. Go to http://google-code-prettify.googlecode.com/svn/trunk/tests/prettify_test.html#java and you can see that. The problem here is that Prettify thinks Version and Bar are type names, because they start with a capital letter. In Java this would make sense, because "Java style guidelines specify that type names and only type names are upper-camel-case". In C# it's just wrong, so this is only an issue for C#. |
|
,
Aug 17, 2009
Does anyone know how to distinguish method names from type names in C# at a purely lexical level? |
|
,
Aug 17, 2009
I looked at http://msdn.microsoft.com/en-us/library/aa664812%28VS.71%29.aspx, and I'm a bit unsure about delegates and such. Is it the case that in C#, ignoring whitespace and comment tokens, a method name is always followed by an open parenthesis, and a typename is never followed by an open parenthesis. There's no special syntax for dereferencing a method to return a delegable value, so Foo(MyClass.MyMethod) contains one type name and two method names, and there's no way to distinguish the two purely at the lexical level? |
|
,
Aug 18, 2009
> Is it the case that in C#, ignoring whitespace and comment tokens, a method name is always followed by an open parenthesis, and a typename is never followed by an open parenthesis. Method names can be used as "method groups" without parentheses, as in your example Foo(MyClass.MyMethod) Type name can be followed by an open parenthesis in constructors, just as in Java. E.g. new Class() Properties (like Version in the original issue) should really be highlighted the same as methods. |
|
,
Aug 18, 2009
Is there a set of symbols that typically precede or follow a type name so that I can assume that all others are not types? In java, a type name can follow the 'new' keyword; precede '.class'; follow '.' if following 'import' or 'package'; follow 'class', 'extends', 'implements', 'throws'; follow '<' or ',' in a parenthetical group at one level of curly bracket nesting greater than an unclosed block preceded by a 'class', 'interface', 'enum' or '@interface' keyword; or precede a '.' if upper-case by convention. In C#, the last rule is giving us trouble. Would some variation on the other rules suffice? |
|
,
Oct 15, 2009
This is going to be hard, because you also have to keep in mind constructors (public Foo()) and that the visibility specifier is optional (instead of private void Something() you can write Something()). Some tips: Class names have lower-case class right before the class name and no parenthesis. These are valid class specifications (may not be complete): public class Something internal static class Somethingelse private class ThisImplementsAnInterface : IInterface public class SubclassAndInterface : Exception, IDropTarget (In the last example, SubclassAndInterface, Exception and IDropTarget should all be highlighted as Class Names) These are invalid: class static InvalidOne class internal InvalidTwo Class InvalidThree (Uppercase Class or words between "class" and the name) Generally in C#, there are no hard rules about casing of identifiers - Someclassname is as legal as someclassname, SomeClassName or SOMeclaSSNAme. There are Guidelines, but no hard rules. |
|
,
Oct 15, 2009
Actually my last comment should be "This should not be too hard" in retrospective. No idea how your parser works and if there are any exceptions to be aware of. One one caveat I know about: In C# it's legal to use keywords as identifiers if you put an @ in front of it, so this would be legal (although discouraged): int @class = 13; Not sure how your lexer works and how much work it would be to take care of the exceptions. |
|
|
|