Skip to content

feat: Enable Rule CA2211 #9857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ 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
dotnet_diagnostic.CA2211.severity = error

# Wrapping preferences
csharp_wrap_before_ternary_opsigns = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ public enum FlatColor : uint
};

// See: https://htmlcolorcodes.com/assets/downloads/flat-design-colors/flat-design-color-chart.png
protected static Color[,]? _colorChart = null;
protected static object _colorChartMutex = new object();
private static Color[,]? _colorChart = null;
private static readonly object _colorChartMutex = new();

/// <summary>
/// Initializes all color chart colors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace Avalonia.Controls
/// <inheritdoc cref="FlatColorPalette"/>
public class FlatHalfColorPalette : IColorPalette
{
protected static Color[,]? _colorChart = null;
protected static object _colorChartMutex = new object();
private static Color[,]? _colorChart = null;
private static readonly object _colorChartMutex = new();

/// <summary>
/// Initializes all color chart colors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ public enum MaterialColor : uint

// See: https://material.io/design/color/the-color-system.html#tools-for-picking-colors
// This is a reduced palette for uniformity
protected static Color[,]? _colorChart = null;
protected static object _colorChartMutex = new object();
private static Color[,]? _colorChart = null;
private static readonly object _colorChartMutex = new();

/// <summary>
/// Initializes all color chart colors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace Avalonia.Controls
/// <inheritdoc cref="MaterialColorPalette"/>
public class MaterialHalfColorPalette : IColorPalette
{
protected static Color[,]? _colorChart = null;
protected static object _colorChartMutex = new object();
private static Color[,]? _colorChart = null;
private static readonly object _colorChartMutex = new();

/// <summary>
/// Initializes all color chart colors.
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Controls.DataGrid/DataGridCheckBoxColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public DataGridCheckBoxColumn()
/// <summary>
/// Defines the <see cref="IsThreeState"/> property.
/// </summary>
public static StyledProperty<bool> IsThreeStateProperty =
public static readonly StyledProperty<bool> IsThreeStateProperty =
CheckBox.IsThreeStateProperty.AddOwner<DataGridCheckBoxColumn>();

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Controls.DataGrid/DataGridColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ internal ICellEditBinding CellEditBinding
/// <summary>
/// Defines the <see cref="IsVisible"/> property.
/// </summary>
public static StyledProperty<bool> IsVisibleProperty =
public static readonly StyledProperty<bool> IsVisibleProperty =
Control.IsVisibleProperty.AddOwner<DataGridColumn>();

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Controls/Diagnostics/ToolTipDiagnostics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public static class ToolTipDiagnostics
/// <summary>
/// Provides access to the internal <see cref="ToolTip.ToolTipProperty"/> for use in DevTools.
/// </summary>
public static AvaloniaProperty<ToolTip?> ToolTipProperty = ToolTip.ToolTipProperty;
public static readonly AvaloniaProperty<ToolTip?> ToolTipProperty = ToolTip.ToolTipProperty;
}
}