Reporter | guest (guest2) |
---|---|
Created | Mar 5, 2012 8:54:55 PM |
Updated | Mar 5, 2012 8:59:35 PM |
Priority | Normal |
Type | Bug |
Fix versions | No Fix versions |
State | Submitted |
Assignee | Unassigned |
Subsystem | No subsystem |
Affected versions | No Affected versions |
Fixed in build | No Fixed in build |
Build 6.1.1000.82; Visual Studio 10.0.40219.1
ReSharper converted this:
cvs.View.Filter =
c =>
string.IsNullOrWhiteSpace(filter.Text) ||
(typeof(string) == type && (c as string).StartsWith(filter.Text, StringComparison.InvariantCultureIgnoreCase)) ||
(property != null && property.GetValue(c, null).ToString().StartsWith(filter.Text, StringComparison.InvariantCultureIgnoreCase));
into [BAD]
cvs.View.Filter =
c =>
{
var s = c as string;
return s != null && (string.IsNullOrWhiteSpace(filter.Text) ||
(typeof(string) == type && s.StartsWith(filter.Text, StringComparison.InvariantCultureIgnoreCase)) ||
(property != null && property.GetValue(c, null).ToString().StartsWith(filter.Text, StringComparison.InvariantCultureIgnoreCase)));
};
An improvement that works looks like this:
cvs.View.Filter =
c =>
{
var s = c as string;
||
(s != null &&
(typeof(string) == type && s.StartsWith(filter.Text, StringComparison.InvariantCultureIgnoreCase)) ||
(property != null && property.GetValue(c, null).ToString().StartsWith(filter.Text, StringComparison.InvariantCultureIgnoreCase)));
};
The failure broke a CollectionViewSource in a very visible way.
ReSharper converted this:
cvs.View.Filter =
c =>
string.IsNullOrWhiteSpace(filter.Text) ||
(typeof(string) == type && (c as string).StartsWith(filter.Text, StringComparison.InvariantCultureIgnoreCase)) ||
(property != null && property.GetValue(c, null).ToString().StartsWith(filter.Text, StringComparison.InvariantCultureIgnoreCase));
into [BAD]
cvs.View.Filter =
c =>
{
var s = c as string;
return s != null && (string.IsNullOrWhiteSpace(filter.Text) ||
(typeof(string) == type && s.StartsWith(filter.Text, StringComparison.InvariantCultureIgnoreCase)) ||
(property != null && property.GetValue(c, null).ToString().StartsWith(filter.Text, StringComparison.InvariantCultureIgnoreCase)));
};
An improvement that works looks like this:
cvs.View.Filter =
c =>
{
var s = c as string;
return string.IsNullOrWhiteSpace(filter.Text)
(s != null &&
(typeof(string) == type && s.StartsWith(filter.Text, StringComparison.InvariantCultureIgnoreCase)) ||
(property != null && property.GetValue(c, null).ToString().StartsWith(filter.Text, StringComparison.InvariantCultureIgnoreCase)));
};
The failure broke a CollectionViewSource in a very visible way.