Menu ▾ ▴

#477 C#: && sometimes mistaken for reference

open
nobody
2018-01-29
2018-01-25
No

When indenting C# code, "&&" is sometimes mistaken for a refernce so

if (depX is int && depY is int && depW is int && depH is int)

with "--align-reference=type" will generate

if (depX is int&& depY is int &&depW is int &&depH is int)

Discussion

  • w-peuker

    w-peuker - 2018-01-26

    Is it a version 3.1 issue? Can this be prevented with parentheses? Remember, that && can as well be a (sort of) reference in C++ used for the move semantics feature.

     
  • Soren Pingel Dalsgaard

    This is version 3.1 and I tried parentheses and it fixes the reported "if", so this works:
    if ((depX is int) && (depY is int) && (depW is int) && (depH is int))
    But on this line:
    public bool available => (ProjectDir != null) && (JsonFile != null) && (ProjectFile != null) && (Model != null);
    it is still changed to
    public bool available => (ProjectDir != null)&& (JsonFile != null)&& (ProjectFile != null)&& (Model != null);
    even with parentheses around the entire expression:
    public bool available => ((ProjectDir != null)&& (JsonFile != null)&& (ProjectFile != null)&& (Model != null));

     

Log in to post a comment.