Browse Source
Merge pull request #11288 from workgroupengineering/features/Analyzers/CA1854
feat: Enable Rule CA1854
pull/11304/head
Max Katz
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
13 additions and
8 deletions
-
.editorconfig
-
src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml.cs
-
src/Avalonia.Remote.Protocol/MetsysBson.cs
-
src/Windows/Avalonia.Win32/TrayIconImpl.cs
|
|
|
@ -177,7 +177,9 @@ dotnet_diagnostic.CA1828.severity = warning |
|
|
|
dotnet_diagnostic.CA1829.severity = warning |
|
|
|
#CA1847: Use string.Contains(char) instead of string.Contains(string) with single characters |
|
|
|
dotnet_diagnostic.CA1847.severity = warning |
|
|
|
#CACA2211:Non-constant fields should not be visible |
|
|
|
#CA1854: Prefer the IDictionary.TryGetValue(TKey, out TValue) method |
|
|
|
dotnet_diagnostic.CA1854.severity = warning |
|
|
|
#CA2211:Non-constant fields should not be visible |
|
|
|
dotnet_diagnostic.CA2211.severity = error |
|
|
|
|
|
|
|
# Wrapping preferences |
|
|
|
|
|
|
|
@ -237,9 +237,9 @@ namespace Avalonia.Diagnostics.Views |
|
|
|
else |
|
|
|
{ |
|
|
|
//TODO Use Dictionary.Remove(Key, out Value) in netstandard 2.1
|
|
|
|
if (_frozenPopupStates.ContainsKey(popup)) |
|
|
|
if (_frozenPopupStates.TryGetValue(popup, out var value)) |
|
|
|
{ |
|
|
|
_frozenPopupStates[popup].Dispose(); |
|
|
|
value.Dispose(); |
|
|
|
_frozenPopupStates.Remove(popup); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -715,7 +715,8 @@ namespace Metsys.Bson |
|
|
|
|
|
|
|
public MagicProperty FindProperty(string name) |
|
|
|
{ |
|
|
|
return _properties.ContainsKey(name) ? _properties[name] : null; |
|
|
|
_properties.TryGetValue(name, out var property); |
|
|
|
return property; |
|
|
|
} |
|
|
|
|
|
|
|
public static TypeHelper GetHelperForType(Type type) |
|
|
|
@ -1196,7 +1197,9 @@ namespace Metsys.Bson |
|
|
|
} |
|
|
|
object container = null; |
|
|
|
var property = typeHelper.FindProperty(name); |
|
|
|
var propertyType = property != null ? property.Type : _typeMap.ContainsKey(storageType) ? _typeMap[storageType] : typeof(object); |
|
|
|
var propertyType = property?.Type |
|
|
|
?? (_typeMap.TryGetValue(storageType, out var type1) ? type1 : null) |
|
|
|
?? typeof(object); |
|
|
|
if (property != null && property.Setter == null) |
|
|
|
{ |
|
|
|
container = property.Getter(instance); |
|
|
|
@ -1588,7 +1591,7 @@ namespace Metsys.Bson.Configuration |
|
|
|
{ |
|
|
|
return property; |
|
|
|
} |
|
|
|
return map.ContainsKey(property) ? map[property] : property; |
|
|
|
return map.TryGetValue(property, out var value) ? value : property; |
|
|
|
} |
|
|
|
|
|
|
|
public void AddIgnore<T>(string name) |
|
|
|
|
|
|
|
@ -41,9 +41,9 @@ namespace Avalonia.Win32 |
|
|
|
|
|
|
|
internal static void ProcWnd(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam) |
|
|
|
{ |
|
|
|
if (msg == (int)CustomWindowsMessage.WM_TRAYMOUSE && s_trayIcons.ContainsKey(wParam.ToInt32())) |
|
|
|
if (msg == (int)CustomWindowsMessage.WM_TRAYMOUSE && s_trayIcons.TryGetValue(wParam.ToInt32(), out var value)) |
|
|
|
{ |
|
|
|
s_trayIcons[wParam.ToInt32()].WndProc(hWnd, msg, wParam, lParam); |
|
|
|
value.WndProc(hWnd, msg, wParam, lParam); |
|
|
|
} |
|
|
|
|
|
|
|
if (msg == WM_TASKBARCREATED) |
|
|
|
|