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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with
13 additions and
11 deletions
-
.editorconfig
-
src/Avalonia.Controls.DataGrid/DataGridValueConverter.cs
-
src/Avalonia.Controls/AppBuilderBase.cs
-
src/Avalonia.Controls/DateTimePickers/TimePicker.cs
-
src/Avalonia.Controls/DefinitionBase.cs
-
src/Avalonia.DesignerSupport/Remote/HtmlTransport/SimpleWebSocketHttpServer.cs
-
src/Avalonia.X11/X11Structs.cs
-
tests/Avalonia.Base.UnitTests/Media/TextFormatting/GraphemeBreakTestDataGenerator.cs
|
|
|
@ -139,10 +139,12 @@ dotnet_analyzer_diagnostic.category-Performance.severity = none #error - Uncomme |
|
|
|
|
|
|
|
# CA1802: Use literals where appropriate |
|
|
|
dotnet_diagnostic.CA1802.severity = warning |
|
|
|
# CA1825: Avoid zero-length array allocations |
|
|
|
dotnet_diagnostic.CA1825.severity = warning |
|
|
|
# CA1820: Test for empty strings using string length |
|
|
|
dotnet_diagnostic.CA1820.severity = warning |
|
|
|
# CA1821: Remove empty finalizers |
|
|
|
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 |
|
|
|
dotnet_diagnostic.CA1847.severity = warning |
|
|
|
|
|
|
|
|
|
|
|
@ -28,8 +28,8 @@ namespace Avalonia.Controls |
|
|
|
{ |
|
|
|
if (targetType != null && targetType.IsNullableType()) |
|
|
|
{ |
|
|
|
String strValue = value as String; |
|
|
|
if (strValue == String.Empty) |
|
|
|
var strValue = value as string; |
|
|
|
if (string.IsNullOrEmpty(strValue)) |
|
|
|
{ |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@ -210,9 +210,9 @@ namespace Avalonia.Controls |
|
|
|
{ |
|
|
|
var moduleInitializers = from assembly in AppDomain.CurrentDomain.GetAssemblies() |
|
|
|
from attribute in assembly.GetCustomAttributes<ExportAvaloniaModuleAttribute>() |
|
|
|
where attribute.ForWindowingSubsystem == "" |
|
|
|
where string.IsNullOrEmpty(attribute.ForWindowingSubsystem) |
|
|
|
|| attribute.ForWindowingSubsystem == WindowingSubsystemName |
|
|
|
where attribute.ForRenderingSubsystem == "" |
|
|
|
where string.IsNullOrEmpty(attribute.ForRenderingSubsystem) |
|
|
|
|| attribute.ForRenderingSubsystem == RenderingSubsystemName |
|
|
|
group attribute by attribute.Name into exports |
|
|
|
select (from export in exports |
|
|
|
|
|
|
|
@ -99,7 +99,7 @@ namespace Avalonia.Controls |
|
|
|
get => _clockIdentifier; |
|
|
|
set |
|
|
|
{ |
|
|
|
if (!(string.IsNullOrEmpty(value) || value == "" || value == "12HourClock" || value == "24HourClock")) |
|
|
|
if (!(string.IsNullOrEmpty(value) || value == "12HourClock" || value == "24HourClock")) |
|
|
|
throw new ArgumentException("Invalid ClockIdentifier"); |
|
|
|
SetAndRaise(ClockIdentifierProperty, ref _clockIdentifier, value); |
|
|
|
SetGrid(); |
|
|
|
|
|
|
|
@ -366,7 +366,7 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
string id = (string)value; |
|
|
|
|
|
|
|
if (id != string.Empty) |
|
|
|
if (!string.IsNullOrEmpty(id)) |
|
|
|
{ |
|
|
|
int i = -1; |
|
|
|
while (++i < id.Length) |
|
|
|
|
|
|
|
@ -72,7 +72,7 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport |
|
|
|
while (true) |
|
|
|
{ |
|
|
|
line = await ReadLineAsync(); |
|
|
|
if (line == "") |
|
|
|
if (string.IsNullOrEmpty(line)) |
|
|
|
break; |
|
|
|
sp = line.Split(new[] {':'}, 2); |
|
|
|
headers[sp[0]] = sp[1].TrimStart(); |
|
|
|
|
|
|
|
@ -661,7 +661,7 @@ namespace Avalonia.X11 { |
|
|
|
Type type = ev.GetType (); |
|
|
|
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++) { |
|
|
|
if (result != string.Empty) { |
|
|
|
if (!string.IsNullOrEmpty(result)) { |
|
|
|
result += ", "; |
|
|
|
} |
|
|
|
object value = fields [i].GetValue (ev); |
|
|
|
|
|
|
|
@ -80,7 +80,7 @@ namespace Avalonia.Visuals.UnitTests.Media.TextFormatting |
|
|
|
var remaining = remainingChars.Where(x => x != "" && x != "×").Select(x => Convert.ToInt32(x, 16)).ToArray(); |
|
|
|
|
|
|
|
codepoints.AddRange(remaining); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var data = new GraphemeBreakData |
|
|
|
{ |
|
|
|
|