You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Formatter removes semicolon after variable initializer at class level (C#) #1333
namespaceUnity{publicclassClass{// doesn't work because ; gets removed butpublicstaticreadonlyClassA=newClass(){name="A",id=1};// works and ; doesn't get removedpublicstaticreadonlyClassB=newClass{name="B",id=2};}}
Expected versus output diff:
diff --git a/Users/mihai/Development/external/uncrustify/tests/output/staging/60016-UNI-11662.cs b/Users/mihai/Development/external/uncrustify/tests/results/staging/60016-UNI-11662.cs
index 9a49fdb..9288ee8 100644
--- a/Users/mihai/Development/external/uncrustify/tests/output/staging/60016-UNI-11662.cs+++ b/Users/mihai/Development/external/uncrustify/tests/results/staging/60016-UNI-11662.cs@@ -1,10 +1,10 @@
namespace Unity
{
public class Class
{
// doesn't work because ; gets removed but
- public static readonly Class A = new Class() { name = "A", id = 1 };+ public static readonly Class A = new Class() { name = "A", id = 1 }
// works and ; doesn't get removed
public static readonly Class B = new Class { name = "B", id = 2 };
}
}
Note: This is a generated issue from our internal issue tracker.
Expect a dry description which could be insufficient to properly understand the issue.
On the other hand, the support files should be sufficient to easily reproduce and debug the issue,
but please comment if it's still unclear and I will get back with clarifications.
See main discussion thread here #1223.
I don't have any compiler for C#. Sorry. I don't have experience about C#.
Is the classification as FUNC_CLASS_DEF correct?
Could you modify the source to a cpp, and complete it to be compilable?
Definitely that's not a class function definition but an initialized static member.
It's kind of hard to try to reproduce the same behavior in C++ but we did saw it in something similar in our C++/CLI code as well but it might be a totally different issue:
IIterable<int>^ Class::Foo(int first, int second)
{
auto array = ref new Platform::Array<int>
{
first,
second
};
return ref new Iterable<int>(array);
}
changed the title [-]Formatter removes semicolon after variable initializer at class level[/-][+]Formatter removes semicolon after variable initializer at class level (C#)[/+]on Oct 3, 2017
Activity
mihaipopescu commentedon Aug 31, 2017
This is high-priority on our side as it's actually breaking the code.
mihaipopescu commentedon Sep 1, 2017
As probably you already may have noticed the responsible option is
mod_remove_extra_semicolon.guy-maurel commentedon Sep 1, 2017
I can reproduce...
guy-maurel commentedon Sep 10, 2017
The remove is caused by the option:
mod_remove_extra_semicolon = true.Using the command option -p, one can see:
I don't have any compiler for C#. Sorry. I don't have experience about C#.
Is the classification as
FUNC_CLASS_DEFcorrect?Could you modify the source to a cpp, and complete it to be compilable?
mihaipopescu commentedon Sep 12, 2017
Definitely that's not a class function definition but an initialized static member.
It's kind of hard to try to reproduce the same behavior in C++ but we did saw it in something similar in our C++/CLI code as well but it might be a totally different issue:
The semicolon after
returnstatement was removed.guy-maurel commentedon Sep 12, 2017
Could you push a more complete source, which could be compiled?
mihaipopescu commentedon Oct 2, 2017
Why do you need it to be compilable ? The snippets are syntactically correct and uncrustify should be able to format them just like that.
guy-maurel commentedon Oct 2, 2017
I don't need!
I wish it!
Using the clang compiler I can see what it does.
[-]Formatter removes semicolon after variable initializer at class level[/-][+]Formatter removes semicolon after variable initializer at class level (C#)[/+]mihaipopescu commentedon Oct 3, 2017
I said.. it's very hard to try to come up with a C++ equivalent as this is a C# bug (the tag you put is wrong).
You can see the correct tokenization if you look at the second line where the semicolon is not removed.
DieHertz commentedon Oct 6, 2017
For C++
return {};transforms intoreturn {}Using a binary distribution from Ubuntu 16.04.
Fixed issue of semicolon removal for variable initializer
gmaurel commentedon Jan 24, 2018
Fixed at e8dd4d0, Dec 31 12:38:29 2017