Page MenuHomePhabricator

[clang-format] Recognize C# nullable types

Authored by jbcoe on Feb 27 2020, 8:07 AM.



Do not confuse C# nullable types with conditional expressions.

Do not put a space before the ? in [access-modifier] Type? variableName;

Diff Detail

Event Timeline

jbcoe created this revision.Feb 27 2020, 8:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 27 2020, 8:07 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jbcoe marked an inline comment as done.Feb 27 2020, 8:57 AM
jbcoe added inline comments.

This will be formatted as

public Person(string firstName, string lastName, int age = null);

without the Nullable Type.

krasimir accepted this revision.Feb 27 2020, 11:32 AM
krasimir added inline comments.

Could you also try/add a test for an array of nullable type (from language ref docs here) (also an example of using new with a nullable type):

// An array of a nullable type:
int?[] arr = new int?[10];
This revision is now accepted and ready to land.Feb 27 2020, 11:32 AM
MyDeveloperDay accepted this revision.Feb 28 2020, 12:48 AM
jbcoe updated this revision to Diff 247193.Feb 28 2020, 2:24 AM

Add additional test following review discussion

Closed by commit rG5f52a93b698b: [clang-format] Recognize C# nullable types (authored by Jonathan Coe <>). · Explain WhyFeb 28 2020, 3:24 AM
This revision was automatically updated to reflect the committed changes.