Skip to content

Commit 7bf51f2

Browse files
Merge branch 'main' into bugfix/fix-mstest0040-warnings-and-broken-cslaWindowsTest-project
2 parents bc4bb00 + c0c774e commit 7bf51f2

11 files changed

+22
-46
lines changed

Source/Csla.Web.Mvc.Shared/CslaModelBinder.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,8 @@ protected override void OnModelUpdated(ControllerContext controllerContext, Mode
250250
select r;
251251
foreach (var item in errors)
252252
{
253-
ModelState state;
254253
string mskey = CreateSubPropertyName(bindingContext.ModelName, item.Property ?? string.Empty);
255-
if (bindingContext.ModelState.TryGetValue(mskey, out state))
254+
if (bindingContext.ModelState.TryGetValue(mskey, out var state))
256255
{
257256
if (state.Errors.Any(e => e.ErrorMessage == item.Description))
258257
continue;

Source/Csla.Windows/BindingSourceRefresh.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ public bool CanExtend(object extendee)
100100
[Category("Csla")]
101101
public bool GetReadValuesOnChange(BindingSource source)
102102
{
103-
bool result;
104-
if (_sources.TryGetValue(source, out result))
103+
if (_sources.TryGetValue(source, out var result))
105104
return result;
106105
else
107106
return false;

Source/Csla.Windows/ReadWriteAuthorization.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ public bool CanExtend(object extendee)
6565
[Category("Csla")]
6666
public bool GetApplyAuthorization(Control source)
6767
{
68-
ControlStatus result;
69-
if (_sources.TryGetValue(source, out result))
68+
if (_sources.TryGetValue(source, out var result))
7069
return result.ApplyAuthorization;
7170
else
7271
return false;
@@ -81,8 +80,7 @@ public bool GetApplyAuthorization(Control source)
8180
[Category("Csla")]
8281
public void SetApplyAuthorization(Control source, bool value)
8382
{
84-
ControlStatus status;
85-
if (_sources.TryGetValue(source, out status))
83+
if (_sources.TryGetValue(source, out var status))
8684
status.ApplyAuthorization = value;
8785
else
8886
_sources.Add(

Source/Csla/Core/BusinessBase.cs

+3-9
Original file line numberDiff line numberDiff line change
@@ -499,11 +499,9 @@ public virtual bool CanReadProperty(IPropertyInfo property)
499499
if (property is null)
500500
throw new ArgumentNullException(nameof(property));
501501

502-
var result = true;
503-
504502
VerifyAuthorizationCache();
505503

506-
if (!_readResultCache!.TryGetValue(property.Name, out result))
504+
if (!_readResultCache!.TryGetValue(property.Name, out var result))
507505
{
508506
result = BusinessRules.HasPermission(ApplicationContext, AuthorizationActions.ReadProperty, property);
509507
if (BusinessRules.CachePermissionResult(AuthorizationActions.ReadProperty, property))
@@ -579,11 +577,9 @@ public virtual bool CanWriteProperty(IPropertyInfo property)
579577
if (property is null)
580578
throw new ArgumentNullException(nameof(property));
581579

582-
bool result = true;
583-
584580
VerifyAuthorizationCache();
585581

586-
if (!_writeResultCache!.TryGetValue(property.Name, out result))
582+
if (!_writeResultCache!.TryGetValue(property.Name, out var result))
587583
{
588584
result = BusinessRules.HasPermission(ApplicationContext, AuthorizationActions.WriteProperty, property);
589585
if (BusinessRules.CachePermissionResult(AuthorizationActions.WriteProperty, property))
@@ -683,11 +679,9 @@ public virtual bool CanExecuteMethod(IMemberInfo method)
683679
if (method is null)
684680
throw new ArgumentNullException(nameof(method));
685681

686-
bool result = true;
687-
688682
VerifyAuthorizationCache();
689683

690-
if (!_executeResultCache!.TryGetValue(method.Name, out result))
684+
if (!_executeResultCache!.TryGetValue(method.Name, out var result))
691685
{
692686
result = BusinessRules.HasPermission(ApplicationContext, AuthorizationActions.ExecuteMethod, method);
693687
if (BusinessRules.CachePermissionResult(AuthorizationActions.ExecuteMethod, method))

Source/Csla/Core/FieldManager/FieldDataList.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ public bool TryGetValue(string key, [NotNullWhen(true)] out IFieldData? result)
3434
if (key is null)
3535
throw new ArgumentNullException(nameof(key));
3636

37-
int index;
38-
if (_fieldIndex.TryGetValue(key, out index))
37+
if (_fieldIndex.TryGetValue(key, out var index))
3938
{
4039
result = _fields[index];
4140
return true;

Source/Csla/Core/UndoableHandler.cs

+3-5
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ internal static class UndoableHandler
2727

2828
public static List<DynamicMemberHandle> GetCachedFieldHandlers(Type type)
2929
{
30-
List<DynamicMemberHandle>? handlers;
31-
3230
#if NET8_0_OR_GREATER
3331

3432
if (!_undoableFieldCache.TryGetValue(type, out var handlersInfo))
@@ -46,9 +44,9 @@ public static List<DynamicMemberHandle> GetCachedFieldHandlers(Type type)
4644
}
4745
}
4846

49-
handlers = handlersInfo.Item2;
47+
return handlersInfo.Item2;
5048
#else
51-
if (!_undoableFieldCache.TryGetValue(type, out handlers))
49+
if (!_undoableFieldCache.TryGetValue(type, out var handlers))
5250
{
5351
var newHandlers = BuildHandlers(type);
5452

@@ -62,9 +60,9 @@ public static List<DynamicMemberHandle> GetCachedFieldHandlers(Type type)
6260
}
6361
}
6462
}
65-
#endif
6663

6764
return handlers;
65+
#endif
6866
}
6967

7068
private static List<DynamicMemberHandle> BuildHandlers(Type type)

Source/Csla/ReadOnlyBase.cs

+2-6
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,9 @@ public virtual bool CanReadProperty(IPropertyInfo property)
226226
if (property is null)
227227
throw new ArgumentNullException(nameof(property));
228228

229-
bool result = true;
230-
231229
VerifyAuthorizationCache();
232230

233-
if (!_readResultCache!.TryGetValue(property.Name, out result))
231+
if (!_readResultCache!.TryGetValue(property.Name, out var result))
234232
{
235233
result = BusinessRules.HasPermission(ApplicationContext, AuthorizationActions.ReadProperty, property);
236234
// store value in cache
@@ -337,11 +335,9 @@ public virtual bool CanExecuteMethod(IMemberInfo method)
337335
if (method is null)
338336
throw new ArgumentNullException(nameof(method));
339337

340-
bool result = true;
341-
342338
VerifyAuthorizationCache();
343339

344-
if (!_executeResultCache!.TryGetValue(method.Name, out result))
340+
if (!_executeResultCache!.TryGetValue(method.Name, out var result))
345341
{
346342
result = BusinessRules.HasPermission(ApplicationContext, AuthorizationActions.ExecuteMethod, method);
347343
_executeResultCache.AddOrUpdate(method.Name, result, (_, _) => { return result; });

Source/Csla/Serialization/Mobile/CslaLegacyBinaryWriter.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ private void WriteSystemString(string systemString, BinaryWriter writer)
7575
private DictionaryCheckResult GetKey(string value)
7676
{
7777
DictionaryCheckResult returnValue;
78-
int key;
79-
if (keywordsDictionary.TryGetValue(value, out key))
78+
if (keywordsDictionary.TryGetValue(value, out var key))
8079
{
8180
returnValue = new DictionaryCheckResult(false, key);
8281
}

Source/Csla/Serialization/Mobile/MobileFormatter.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ public SerializationInfo SerializeObject(object? obj)
164164

165165
private Type GetTypeFromCache(string typeName)
166166
{
167-
Type? result;
168-
if (!_typeCache.TryGetValue(typeName, out result))
167+
if (!_typeCache.TryGetValue(typeName, out var result))
169168
{
170169
result = MethodCaller.GetType(typeName);
171170

Source/Csla/Server/DataPortalMethodCache.cs

+6-8
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ public static DataPortalMethodInfo GetMethodInfo([DynamicallyAccessedMembers(Dyn
2828
{
2929
var key = new MethodCacheKey(objectType.FullName!, methodName, MethodCaller.GetParameterTypes(parameters));
3030

31-
DataPortalMethodInfo result;
32-
3331
#if NET8_0_OR_GREATER
3432
if (_cache.TryGetValue(key, out var methodInfo))
3533
{
@@ -44,14 +42,14 @@ public static DataPortalMethodInfo GetMethodInfo([DynamicallyAccessedMembers(Dyn
4442
}
4543

4644
var method = GetMethodOfCaller(objectType, methodName, parameters);
47-
48-
result = new DataPortalMethodInfo(method);
45+
46+
var result = new DataPortalMethodInfo(method);
4947
var cacheInstance = AssemblyLoadContextManager.CreateCacheInstance(objectType, result, OnAssemblyLoadContextUnload);
5048
_cache.Add(key, cacheInstance);
49+
return result;
5150
}
52-
5351
#else
54-
if (_cache.TryGetValue(key, out result))
52+
if (_cache.TryGetValue(key, out var result))
5553
return result;
5654

5755
lock (_cache)
@@ -63,10 +61,10 @@ public static DataPortalMethodInfo GetMethodInfo([DynamicallyAccessedMembers(Dyn
6361

6462
_cache.Add(key, result);
6563
}
66-
}
67-
#endif
64+
}
6865

6966
return result;
67+
#endif
7068
}
7169

7270
private static System.Reflection.MethodInfo GetMethodOfCaller([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)] Type objectType, string methodName, object[] parameters)

Source/Csla/SmartDate.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -712,9 +712,6 @@ public static DateTime StringToDate(string? value, EmptyValue emptyValue)
712712

713713
private static bool TryStringToDate(string? value, EmptyValue emptyValue, ref DateTime result)
714714
{
715-
716-
DateTime tmp;
717-
718715
// call custom parser if set...
719716
var tmpValue = _customParser?.Invoke(value);
720717
// i f custom parser returned a value then parsing succeeded
@@ -729,7 +726,7 @@ private static bool TryStringToDate(string? value, EmptyValue emptyValue, ref Da
729726
result = emptyValue == EmptyValue.MinDate ? DateTime.MinValue : DateTime.MaxValue;
730727
return true;
731728
}
732-
if (DateTime.TryParse(value, out tmp))
729+
if (DateTime.TryParse(value, out var tmp))
733730
{
734731
result = tmp;
735732
return true;

0 commit comments

Comments
 (0)