Skip to content

Commit

Permalink
Mitigate violation CA1854 (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpreyskurantov authored Sep 9, 2024
1 parent ca94b13 commit b2e3b9b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
7 changes: 4 additions & 3 deletions net/DevExtreme.AspNet.Data/Aggregation/SumFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ object GetDefaultValue(string selector) {
if(_defaultValues == null)
_defaultValues = new Dictionary<string, object>();

if(!_defaultValues.ContainsKey(selector)) {
object value;
if(!_defaultValues.TryGetValue(selector, out value)) {
var expr = CompileAccessorExpression(CreateItemParam(), selector);
var acc = AccumulatorFactory.Create(Utils.StripNullableType(expr.Type));
_defaultValues[selector] = acc.GetValue();
_defaultValues.Add(selector, value = acc.GetValue());
}

return _defaultValues[selector];
return value;
}
}

Expand Down
6 changes: 3 additions & 3 deletions net/DevExtreme.AspNet.Data/GroupHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ List<Group> Group(IEnumerable<T> data, GroupingInfo groupInfo) {
var groupKey = GetKey(item, groupInfo);
var groupIndexKey = groupKey ?? NULL_KEY;

if(!groupsIndex.ContainsKey(groupIndexKey)) {
Group group;
if(!groupsIndex.TryGetValue(groupIndexKey, out group)) {
var newGroup = new Group { key = groupKey };
groupsIndex[groupIndexKey] = newGroup;
groupsIndex.Add(groupIndexKey, group = newGroup);
groups.Add(newGroup);
}

var group = groupsIndex[groupIndexKey];
if(group.items == null)
group.items = new List<T>();
group.items.Add(item);
Expand Down
10 changes: 5 additions & 5 deletions net/DevExtreme.AspNet.Data/Helpers/DefaultAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ public object Read(T obj, string selector) {
if(_accessors == null)
_accessors = new Dictionary<string, Func<T, object>>();

if(!_accessors.ContainsKey(selector)) {
Func<T, object> func;
if(!_accessors.TryGetValue(selector, out func)) {
var param = CreateItemParam();

_accessors[selector] = Expression.Lambda<Func<T, object>>(
_accessors.Add(selector, func = Expression.Lambda<Func<T, object>>(
Expression.Convert(CompileAccessorExpression(param, selector), typeof(Object)),
param
).Compile();
).Compile());
}

return _accessors[selector](obj);
return func(obj);
}
}

Expand Down

0 comments on commit b2e3b9b

Please sign in to comment.