Browse Source

Merge pull request #9188 from workgroupengineering/features/NetAnalyzers/CA1820

feat: Enable rule CA1820
pull/9243/head
Max Katz 4 years ago
committed by GitHub
parent
commit
6a3a2817cf
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      .editorconfig
  2. 4
      src/Avalonia.Controls.DataGrid/DataGridValueConverter.cs
  3. 4
      src/Avalonia.Controls/AppBuilderBase.cs
  4. 2
      src/Avalonia.Controls/DateTimePickers/TimePicker.cs
  5. 2
      src/Avalonia.Controls/DefinitionBase.cs
  6. 2
      src/Avalonia.DesignerSupport/Remote/HtmlTransport/SimpleWebSocketHttpServer.cs
  7. 2
      src/Avalonia.X11/X11Structs.cs
  8. 2
      tests/Avalonia.Base.UnitTests/Media/TextFormatting/GraphemeBreakTestDataGenerator.cs

6
.editorconfig

@ -139,10 +139,12 @@ dotnet_analyzer_diagnostic.category-Performance.severity = none #error - Uncomme
# CA1802: Use literals where appropriate # CA1802: Use literals where appropriate
dotnet_diagnostic.CA1802.severity = warning dotnet_diagnostic.CA1802.severity = warning
# CA1825: Avoid zero-length array allocations # CA1820: Test for empty strings using string length
dotnet_diagnostic.CA1825.severity = warning dotnet_diagnostic.CA1820.severity = warning
# CA1821: Remove empty finalizers # CA1821: Remove empty finalizers
dotnet_diagnostic.CA1821.severity = warning dotnet_diagnostic.CA1821.severity = warning
# CA1825: Avoid zero-length array allocations
dotnet_diagnostic.CA1825.severity = warning
#CA1847: Use string.Contains(char) instead of string.Contains(string) with single characters #CA1847: Use string.Contains(char) instead of string.Contains(string) with single characters
dotnet_diagnostic.CA1847.severity = warning dotnet_diagnostic.CA1847.severity = warning

4
src/Avalonia.Controls.DataGrid/DataGridValueConverter.cs

@ -28,8 +28,8 @@ namespace Avalonia.Controls
{ {
if (targetType != null && targetType.IsNullableType()) if (targetType != null && targetType.IsNullableType())
{ {
String strValue = value as String; var strValue = value as string;
if (strValue == String.Empty) if (string.IsNullOrEmpty(strValue))
{ {
return null; return null;
} }

4
src/Avalonia.Controls/AppBuilderBase.cs

@ -210,9 +210,9 @@ namespace Avalonia.Controls
{ {
var moduleInitializers = from assembly in AppDomain.CurrentDomain.GetAssemblies() var moduleInitializers = from assembly in AppDomain.CurrentDomain.GetAssemblies()
from attribute in assembly.GetCustomAttributes<ExportAvaloniaModuleAttribute>() from attribute in assembly.GetCustomAttributes<ExportAvaloniaModuleAttribute>()
where attribute.ForWindowingSubsystem == "" where string.IsNullOrEmpty(attribute.ForWindowingSubsystem)
|| attribute.ForWindowingSubsystem == WindowingSubsystemName || attribute.ForWindowingSubsystem == WindowingSubsystemName
where attribute.ForRenderingSubsystem == "" where string.IsNullOrEmpty(attribute.ForRenderingSubsystem)
|| attribute.ForRenderingSubsystem == RenderingSubsystemName || attribute.ForRenderingSubsystem == RenderingSubsystemName
group attribute by attribute.Name into exports group attribute by attribute.Name into exports
select (from export in exports select (from export in exports

2
src/Avalonia.Controls/DateTimePickers/TimePicker.cs

@ -99,7 +99,7 @@ namespace Avalonia.Controls
get => _clockIdentifier; get => _clockIdentifier;
set set
{ {
if (!(string.IsNullOrEmpty(value) || value == "" || value == "12HourClock" || value == "24HourClock")) if (!(string.IsNullOrEmpty(value) || value == "12HourClock" || value == "24HourClock"))
throw new ArgumentException("Invalid ClockIdentifier"); throw new ArgumentException("Invalid ClockIdentifier");
SetAndRaise(ClockIdentifierProperty, ref _clockIdentifier, value); SetAndRaise(ClockIdentifierProperty, ref _clockIdentifier, value);
SetGrid(); SetGrid();

2
src/Avalonia.Controls/DefinitionBase.cs

@ -366,7 +366,7 @@ namespace Avalonia.Controls
string id = (string)value; string id = (string)value;
if (id != string.Empty) if (!string.IsNullOrEmpty(id))
{ {
int i = -1; int i = -1;
while (++i < id.Length) while (++i < id.Length)

2
src/Avalonia.DesignerSupport/Remote/HtmlTransport/SimpleWebSocketHttpServer.cs

@ -72,7 +72,7 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport
while (true) while (true)
{ {
line = await ReadLineAsync(); line = await ReadLineAsync();
if (line == "") if (string.IsNullOrEmpty(line))
break; break;
sp = line.Split(new[] {':'}, 2); sp = line.Split(new[] {':'}, 2);
headers[sp[0]] = sp[1].TrimStart(); headers[sp[0]] = sp[1].TrimStart();

2
src/Avalonia.X11/X11Structs.cs

@ -661,7 +661,7 @@ namespace Avalonia.X11 {
Type type = ev.GetType (); Type type = ev.GetType ();
FieldInfo [] fields = type.GetFields (System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Instance); FieldInfo [] fields = type.GetFields (System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Instance);
for (int i = 0; i < fields.Length; i++) { for (int i = 0; i < fields.Length; i++) {
if (result != string.Empty) { if (!string.IsNullOrEmpty(result)) {
result += ", "; result += ", ";
} }
object value = fields [i].GetValue (ev); object value = fields [i].GetValue (ev);

2
tests/Avalonia.Base.UnitTests/Media/TextFormatting/GraphemeBreakTestDataGenerator.cs

@ -80,7 +80,7 @@ namespace Avalonia.Visuals.UnitTests.Media.TextFormatting
var remaining = remainingChars.Where(x => x != "" && x != "×").Select(x => Convert.ToInt32(x, 16)).ToArray(); var remaining = remainingChars.Where(x => x != "" && x != "×").Select(x => Convert.ToInt32(x, 16)).ToArray();
codepoints.AddRange(remaining); codepoints.AddRange(remaining);
} }
var data = new GraphemeBreakData var data = new GraphemeBreakData
{ {

Loading…
Cancel
Save