Browse Source

feat: Address rule CA1854

pull/11288/head
Giuseppe Lippolis 3 years ago
parent
commit
e439b706a5
  1. 4
      src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml.cs
  2. 9
      src/Avalonia.Remote.Protocol/MetsysBson.cs
  3. 4
      src/Windows/Avalonia.Win32/TrayIconImpl.cs

4
src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml.cs

@ -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);
}
}

9
src/Avalonia.Remote.Protocol/MetsysBson.cs

@ -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)

4
src/Windows/Avalonia.Win32/TrayIconImpl.cs

@ -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)

Loading…
Cancel
Save