Apply Boolean to Enum refactoring on the following code:
C#class MyAttribute : Attribute {
public MyAttribute(bool isSet) {
IsSet = isSet;
}
public bool IsSet { get; }
}
[My(true)]
class Program {
static void Main(string[] args) {
bool value = true;
MyAttribute attr = new MyAttribute(false);
attr = new MyAttribute(value);
}
}
Result:
C#class MyAttribute : Attribute {
public MyAttribute(MyAttributeParam isSet) {
IsSet = isSet == MyAttributeParam.Success;
}
public bool IsSet { get; }
}
public enum MyAttributeParam {
Success,
Failure
}
[My(true)]
class Program {
static void Main(string[] args) {
bool value = true;
MyAttribute attr = new MyAttribute(MyAttributeParam.Failure);
attr = new MyAttribute(value ? MyAttributeParam.Success : MyAttributeParam.Failure);
}
}
Expected Result:
C#class MyAttribute : Attribute {
public MyAttribute(MyAttributeParam isSet) {
IsSet = isSet == MyAttributeParam.Success;
}
public bool IsSet { get; }
}
public enum MyAttributeParam {
Success,
Failure
}
[My(MyAttributeParam.Success)]
class Program {
static void Main(string[] args) {
bool value = true;
MyAttribute attr = new MyAttribute(MyAttributeParam.Failure);
attr = new MyAttribute(value ? MyAttributeParam.Success : MyAttributeParam.Failure);
}
}
I have reproduced this issue and passed it to our developers. We will notify you of our results.