This is fixed as well.

The conversion rule now supports a special case of converting empty
and blank strings into null references, when the target type is
nullable (issue 680)

On Jun 30, 9:59 pm, mark Kharitonov <[email protected]> wrote:
> I will.
>
> There is another issue of assigning empty values to non string reference
> types. For instance, if a CSV file is missing a value, then it is treated as
> an empty string, which is fine if the target method parameter is of type
> string. However, it precludes using nullable types, like int?.
>
> Is it by design?
>
> Thanks.
>
>
>
>
>
> On Wed, Jun 30, 2010 at 10:51 PM, Yann Trevin <[email protected]> wrote:
> > I have extended the conversion service with a new rule that handles with
> > String to Enum conversions (it just uses Enum.Parse under the hood). It
> > should be available in the next daily build.
>
> > Let me know if it's OK.
>
> > Regards,
> > Yann
>
> > 2010/6/30 Yann Trevin <[email protected]>
>
> > Hi Mark,
>
> >> There is probably some limitation in how the rule based converter is
> >> working with enums. This is something I will have a
> >> look at.
>
> >> Thank you for having reported that issue,
> >> Yann.
>
> >> 2010/6/29 Mark Kharitonov <[email protected]>
>
> >> Hi.
> >>> I have a CSV file where value are instances of an enum type, like
> >>> this:
> >>> public enum Color { Red, Green, Blue }.
>
> >>> My test method expects a Color instance, like this:
> >>> public void AMethod(Color color)
> >>> {
> >>> }
>
> >>> However, this does not work. I know the binding is correct, because
> >>> when I replace Color values with the respective integers and replace
> >>> the type of the color parameter from Color to int - everything works
> >>> just fine.
>
> >>> With the enum type I get the following error stack trace:
>
> >>> System.InvalidCastException: Invalid cast from 'System.String' to
> >>> 'NetworkCatcher.Protocol.Metadata.Contract.StandardResultItemAttributes'.
> >>>   at System.Convert.DefaultToType(IConvertible value, Type
> >>> targetType, IFormatProvider provider)
> >>>   at System.String.System.IConvertible.ToType(Type type,
> >>> IFormatProvider provider)
> >>>   at System.Convert.ChangeType(Object value, Type conversionType,
> >>> IFormatProvider provider)
> >>>   at System.Convert.ChangeType(Object value, Type conversionType)
> >>>   at
>
> >>> Gallio.Runtime.Conversions.ConvertibleToConvertibleConversionRule.Convert(O
> >>>  bject
> >>> sourceValue, Type targetType, IConverter elementConverter) in d:
> >>> \Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Runtime\Conversions
> >>> \ConvertibleToConvertibleConversionRule.cs:line 38
> >>>   at Gallio.Runtime.Conversions.RuleBasedConverter.ConvertImpl(Object
> >>> sourceValue, Type targetType) in d:\Projects\MbUnit v3.1\Work\src
> >>> \Gallio\Gallio\Runtime\Conversions\RuleBasedConverter.cs:line 80
> >>>   at Gallio.Runtime.Conversions.BaseConverter.Convert(Object
> >>> sourceValue, Type targetType) in d:\Projects\MbUnit v3.1\Work\src
> >>> \Gallio\Gallio\Runtime\Conversions\BaseConverter.cs:line 55
> >>>   at Gallio.Framework.Data.MethodInvocationSpec.ResolveArguments() in
> >>> d:\Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Framework\Data
> >>> \MethodInvocationSpec.cs:line 174
> >>>   at Gallio.Framework.Data.MethodInvocationSpec..ctor(Type
> >>> resolvedType, IMethodInfo method, IEnumerable`1 slotValues, IConverter
> >>> converter) in d:\Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Framework
> >>> \Data\MethodInvocationSpec.cs:line 69
> >>>   at
>
> >>> Gallio.Framework.Pattern.PatternTestInstanceState.GetTestMethodInvocationSp
> >>>  ec(IMethodInfo
> >>> method) in d:\Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Framework
> >>> \Pattern\PatternTestInstanceState.cs:line 407
> >>>   at System.Action`1.Invoke(T obj)
>
> >>> What am I doing wrong?
> >>> Thanks.
>
> >>> P.S.
> >>> On the same note, how do I pass null value to a reference type
> >>> parameter? Omitting the value in CSV file passes an empty string, not
> >>> null.
>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups
> >>> "MbUnit.User" group.
> >>> To post to this group, send email to [email protected].
> >>> To unsubscribe from this group, send email to
> >>> [email protected]<mbunituser%2bunsubscr...@googlegrou
> >>>  ps.com>
> >>> .
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/mbunituser?hl=en.
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "MbUnit.User" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<mbunituser%2bunsubscr...@googlegrou 
> > ps.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/mbunituser?hl=en.
>
> --
> Be well and prosper.
> ==============================
> "There are two kinds of people.Those whose guns are loaded and those who
> dig."
>   ("The good, the bad and the ugly")
> So let us drink for our guns always be loaded.

-- 
You received this message because you are subscribed to the Google Groups 
"MbUnit.User" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/mbunituser?hl=en.

Reply via email to