StyleCop / StyleCop.ReSharper

Official ReSharper extension for StyleCop

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SA0102 syntax error when nullable value or enum type value inside tuple type

PlusoneWang opened this issue · comments

Please forgive me for being bad in English. It's not my native language.
A Nullable value like int? inside tuple type will cause syntax error.

(int? val, string str) DoSomething() // this line cause SA0102 error
{
    // Do something...
    return (null, null);
}

Another

(bool isTrue, MyClass.MyEnum enumValue) DoSomething() // this line cause SA0102 error
{
    // Do something...
    return (true, MyClass.MyEnum.AType);
}

I use using static MyClass to resolve the enum type error temply.
Something like this:

// the top of file
using static MyNamespace.MyClass;

// some code...

(bool isTrue, MyEnum enumValue) DoSomething() // this line now NOT cause SA0102 error
{
    // Do something...
    return (true, MyEnum.AType);
}
commented

I can confirm this behavior:

(string typeKey, int? storeID, int? vendorID, int? ilID, int? destID, bool nothingToShip) targetGroupingKey

throws the SA0102, but when I tried

(int typeKey, int storeID, int vendorID, int ilID, int destID, bool nothingToShip) targetGroupingKey

Where nothing is nullable the error goes away.

I can confirm this behavior:

(string typeKey, int? storeID, int? vendorID, int? ilID, int? destID, bool nothingToShip) targetGroupingKey

throws the SA0102, but when I tried

(int typeKey, int storeID, int vendorID, int ilID, int destID, bool nothingToShip) targetGroupingKey

Where nothing is nullable the error goes away.

In fact, for databases that have existed for more than 6 years and have been used in several different technology systems, it is difficult to change the nullable numeric type to not allow null.

I can't transfer the issue, but it belongs to https://github.com/StyleCop/StyleCop most certainly.