if (item is IDefinedOutput) { return (item as IDefinedOutput).GetCsvHeaders(); }
identifies 'item as IDefinedOutput' as possible NRE.
This should result in an QuickFix for.
if (item is IDefinedOutput) { return (IDefinedOutput)item).GetCsvHeaders(); }
Cause a "soft cast" with as is doing a check before casting and the fill a null in item if the type is not correct, but an "hard cast" does (maybe i'm wrong) don't do that check and maybe "crashed" on .GetCsvHeaders() if the type is wrong.
>> if (item is IDefinedOutput) >> { >> return (item as IDefinedOutput).GetCsvHeaders(); >> } >> identifies 'item as IDefinedOutput' as possible NRE. >>
This should result in an QuickFix for.
if (item is IDefinedOutput) { return (IDefinedOutput)item).GetCsvHeaders(); } Cause a "soft cast" with as is doing a check before casting and the fill a null in item if the type is not correct, but an "hard cast" does (maybe i'm wrong) don't do that check and maybe "crashed" on .GetCsvHeaders() if the type is wrong.
Regards Albert
Sure - I guess that it doesn't really matter after the type check, but I always use the soft cast wherever possible as I find the code more readable, so I'd like R# to support both styles, please :)
Thanks Eugene.
This is fixed in buld 301
--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Sean Kearon" <no@spam.org> wrote in message
news:adc66bd29d68c8cfbb427833c4@news.jetbrains.com...
>
>
>
Sean Kearon schrieb:
This should result in an QuickFix for.
if (item is IDefinedOutput)
{
return (IDefinedOutput)item).GetCsvHeaders();
}
Cause a "soft cast" with as is doing a check before casting and the fill
a null in item if the type is not correct, but an "hard cast" does
(maybe i'm wrong) don't do that check and maybe "crashed" on
.GetCsvHeaders() if the type is wrong.
Regards
Albert
>> if (item is IDefinedOutput)
>> {
>> return (item as IDefinedOutput).GetCsvHeaders();
>> }
>> identifies 'item as IDefinedOutput' as possible NRE.
>>
Sure - I guess that it doesn't really matter after the type check, but I
always use the soft cast wherever possible as I find the code more readable,
so I'd like R# to support both styles, please :)
Cheers
Sean