Skip to content
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

Update .editorconfig from 2.1.0 to 3.0.0 #311

Merged
merged 6 commits into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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
13 changes: 8 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Version: 2.1.0 (Using https://semver.org/)
# Updated: 2021-03-03
# Version: 3.0.0 (Using https://semver.org/)
# Updated: 2021-08-09
# See https://github.com/RehanSaeed/EditorConfig/releases for release notes.
# See https://github.com/RehanSaeed/EditorConfig for updates to this file.
# See http://EditorConfig.org for more information about .editorconfig files.
Expand Down Expand Up @@ -48,7 +48,7 @@ indent_size = 2
trim_trailing_whitespace = false

# Web Files
[*.{htm,html,js,jsm,ts,tsx,css,sass,scss,less,svg,vue}]
[*.{htm,html,js,jsm,ts,tsx,css,sass,scss,less,pcss,svg,vue}]
indent_size = 2

# Batch Files
Expand Down Expand Up @@ -97,7 +97,7 @@ dotnet_style_readonly_field = true:warning
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning
dotnet_style_parentheses_in_other_operators = always_for_clarity:suggestion
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:warning
# Expression-level preferences
dotnet_style_object_initializer = true:warning
dotnet_style_collection_initializer = true:warning
Expand All @@ -121,7 +121,10 @@ dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
# If you use StyleCop, you'll need to disable SA1636: File header copyright text should match.
# dotnet_diagnostic.SA1636.severity = none
# Undocumented
dotnet_style_operator_placement_when_wrapping = end_of_line
dotnet_style_operator_placement_when_wrapping = end_of_line:warning
csharp_style_prefer_null_check_over_type_check = true:warning
dotnet_style_namespace_match_folder = true:suggestion
dotnet_diagnostic.IDE0130.severity = suggestion

# C# Style Rules
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules#c-style-rules
Expand Down
3 changes: 3 additions & 0 deletions Benchmarks/Schema.NET.Benchmarks/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using System;

[assembly: CLSCompliant(true)]
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup Label="Build">
<LangVersion>latest</LangVersion>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<AnalysisLevel>latest</AnalysisLevel>
<NeutralLanguage>en-GB</NeutralLanguage>
<Nullable>enable</Nullable>
Expand Down
7 changes: 7 additions & 0 deletions Source/Common/ContextJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public override JsonLdContext ReadJson(JsonReader reader, Type objectType, JsonL
throw new ArgumentNullException(nameof(objectType));
}

if (hasExistingValue && existingValue is null)
{
throw new ArgumentNullException(nameof(existingValue));
}

if (serializer is null)
{
throw new ArgumentNullException(nameof(serializer));
Expand All @@ -48,8 +53,10 @@ public override JsonLdContext ReadJson(JsonReader reader, Type objectType, JsonL
language = languageProperty?.Value?.ToString();
}

#pragma warning disable CA1062 // Validate arguments of public methods
context.Name = name;
context.Language = language;
#pragma warning restore CA1062 // Validate arguments of public methods
return context;
}

Expand Down
2 changes: 2 additions & 0 deletions Source/Common/EnumHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public static bool TryParse(
result = Enum.Parse(enumType, value);
return true;
}
#pragma warning disable CA1031 // Do not catch general exception types
catch
#pragma warning restore CA1031 // Do not catch general exception types
{
result = null;
return false;
Expand Down
2 changes: 0 additions & 2 deletions Source/Common/HashCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ public override bool Equals(object? obj)
[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode() =>
#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations
#pragma warning disable CA1303 // Do not pass literals as localized parameters
throw new NotSupportedException("Implicitly convert this struct to an int to get the hash code.");
#pragma warning restore CA1303 // Do not pass literals as localized parameters
#pragma warning restore CA1065 // Do not raise exceptions in unexpected locations

private static int CombineHashCodes(int h1, int h2)
Expand Down
12 changes: 10 additions & 2 deletions Source/Common/OneOrMany{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ namespace Schema.NET
/// </summary>
/// <typeparam name="T">The type of the values.</typeparam>
/// <seealso cref="ICollection{T}" />
#pragma warning disable CA1710 // Identifiers should have correct suffix
public readonly struct OneOrMany<T>
: IReadOnlyCollection<T>, IEnumerable<T>, IValues, IEquatable<OneOrMany<T>>
#pragma warning restore CA1710 // Identifiers should have correct suffix
{
private readonly T[]? collection;

Expand All @@ -23,7 +21,9 @@ public readonly struct OneOrMany<T>
/// <param name="item">The single item value.</param>
public OneOrMany(T item)
{
#pragma warning disable CA1508 // TODO: Remove this suppression in .NET 6 where the warning is fixed.
if (item is null || (item is string itemAsString && string.IsNullOrWhiteSpace(itemAsString)))
#pragma warning restore CA1508 // TODO: Remove this suppression in .NET 6 where the warning is fixed.
{
this.collection = null;
this.HasOne = false;
Expand Down Expand Up @@ -51,7 +51,9 @@ public OneOrMany(ReadOnlySpan<T> span)
for (var i = 0; i < span.Length; i++)
{
var item = span[i];
#pragma warning disable CA1508 // TODO: Remove this suppression in .NET 6 where the warning is fixed.
if (!string.IsNullOrWhiteSpace(item as string))
#pragma warning restore CA1508 // TODO: Remove this suppression in .NET 6 where the warning is fixed.
{
items[index] = item;
index++;
Expand All @@ -63,7 +65,9 @@ public OneOrMany(ReadOnlySpan<T> span)
for (var i = 0; i < span.Length; i++)
{
var item = span[i];
#pragma warning disable CA1508 // TODO: Remove this suppression in .NET 6 where the warning is fixed.
if (item is not null)
#pragma warning restore CA1508 // TODO: Remove this suppression in .NET 6 where the warning is fixed.
{
items[index] = item;
index++;
Expand Down Expand Up @@ -160,7 +164,9 @@ public OneOrMany(IEnumerable<object> collection)
/// <param name="list">The list of values.</param>
/// <returns>The result of the conversion.</returns>
#pragma warning disable CA2225 // Operator overloads have named alternates
#pragma warning disable CA1002 // Do not expose generic lists
public static implicit operator OneOrMany<T>(List<T> list) => new(list);
#pragma warning restore CA1002 // Do not expose generic lists
#pragma warning restore CA2225 // Operator overloads have named alternates

/// <summary>
Expand Down Expand Up @@ -193,7 +199,9 @@ public OneOrMany(IEnumerable<object> collection)
/// The result of the conversion.
/// </returns>
#pragma warning disable CA2225 // Operator overloads have named alternates
#pragma warning disable CA1002 // Do not expose generic lists
public static implicit operator List<T>(OneOrMany<T> oneOrMany) => oneOrMany.ToList();
#pragma warning restore CA1002 // Do not expose generic lists
#pragma warning restore CA2225 // Operator overloads have named alternates

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions Source/Common/Thing.Partial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ namespace Schema.NET
/// <summary>
/// The most generic type of item.
/// </summary>
#pragma warning disable CA1040 // Avoid empty interfaces
public partial interface IThing
#pragma warning restore CA1040 // Avoid empty interfaces
{
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Common/ValuesJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ private static bool TryGetConcreteType(
if (localType is not null && ThingInterfaceTypeInfo.IsAssignableFrom(localType.GetTypeInfo()))
{
type = localType;
return type is not null;
return true;
}
else
{
Expand Down
Loading