-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-IDEConcept-Design DebtEngineering Debt, Design Debt, or poor product code qualityEngineering Debt, Design Debt, or poor product code qualityFeature - CheckedUserDefinedOperatorsFeature - StaticAbstractMembersInInterfacesIDE-CodeStyleBuilt-in analyzers, fixes, and refactoringsBuilt-in analyzers, fixes, and refactorings
Milestone
Description
interface I1<T> where T : I1<T>
{
abstract static T operator checked -(T x);
abstract static T operator -(T x);
abstract static T operator checked +(T x, T y);
abstract static T operator +(T x, T y);
abstract static explicit operator checked string(T x);
abstract static explicit operator string(T x);
}
class C1 : I1<C1>
{
}
Use code fixer to implement the interface.
Observed (note none of the operators have checked
keyword):
class C1 : I1<C1>
{
static C1 I1<C1>.operator +(C1 x, C1 y)
{
throw new System.NotImplementedException();
}
static C1 I1<C1>.operator +(C1 x, C1 y)
{
throw new System.NotImplementedException();
}
static C1 I1<C1>.operator -(C1 x)
{
throw new System.NotImplementedException();
}
static C1 I1<C1>.operator -(C1 x)
{
throw new System.NotImplementedException();
}
}
Expected:
class C1 : I1<C1>
{
static C1 I1<C1>.operator +(C1 x, C1 y)
{
throw new System.NotImplementedException();
}
static C1 I1<C1>.operator checked +(C1 x, C1 y)
{
throw new System.NotImplementedException();
}
static C1 I1<C1>.operator -(C1 x)
{
throw new System.NotImplementedException();
}
static C1 I1<C1>.operator checked -(C1 x)
{
throw new System.NotImplementedException();
}
static explicit I1<C1>.operator string(C1 x)
{
throw new System.NotImplementedException();
}
static explicit I1<C1>.operator checked string(C1 x)
{
throw new System.NotImplementedException();
}
}
Similar behavior for an option to implement the interface implicitly.
The fact that conversion operators are not implemented at all is tracked by #60212.
Metadata
Metadata
Assignees
Labels
Area-IDEConcept-Design DebtEngineering Debt, Design Debt, or poor product code qualityEngineering Debt, Design Debt, or poor product code qualityFeature - CheckedUserDefinedOperatorsFeature - StaticAbstractMembersInInterfacesIDE-CodeStyleBuilt-in analyzers, fixes, and refactoringsBuilt-in analyzers, fixes, and refactorings