You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A warning should not be produced. The analyzer can see that CustomType has [TypeConverter(typeof(CustomTypeConverter))] even though it can't run it. It's a safe assumption that type converters can convert from string. Even without that assumption (say, with an int test parameter), the warning message is making a claim that it can't prove.
using System;using System.ComponentModel;using System.Globalization;using NUnit.Framework;classC{// NUnit1001 The value of the argument at position '0' of type string cannot be assigned to// the argument 'customType' of type CustomType.// ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓[TestCase("String representation")]publicvoidM(CustomTypecustomType){}}[TypeConverter(typeof(CustomTypeConverter))]structCustomType{publicCustomType(stringvalue){Value=value;}publicstringValue{get;}privatesealedclassCustomTypeConverter:TypeConverter{publicoverrideboolCanConvertFrom(ITypeDescriptorContextcontext,TypesourceType){returnsourceType==typeof(string)||base.CanConvertFrom(context, sourceType);}publicoverrideobjectConvertFrom(ITypeDescriptorContextcontext,CultureInfoculture,objectvalue){return value isstring str
?new CustomType(str):base.ConvertFrom(context, culture, value);}publicoverrideboolCanConvertTo(ITypeDescriptorContextcontext,TypedestinationType){returndestinationType==typeof(string)||base.CanConvertTo(context, destinationType);}publicoverrideobjectConvertTo(ITypeDescriptorContextcontext,CultureInfoculture,objectvalue,TypedestinationType){returndestinationType==typeof(string)? value.ToString():base.ConvertTo(context, culture, value, destinationType);}}}
The text was updated successfully, but these errors were encountered:
A warning should not be produced. The analyzer can see that CustomType has
[TypeConverter(typeof(CustomTypeConverter))]
even though it can't run it. It's a safe assumption that type converters can convert fromstring
. Even without that assumption (say, with anint
test parameter), the warning message is making a claim that it can't prove.The text was updated successfully, but these errors were encountered: