Skip to content

Commit

Permalink
Use "is not null" instead of "is object"
Browse files Browse the repository at this point in the history
  • Loading branch information
warappa committed Dec 26, 2023
1 parent d624e44 commit 5821fa1
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ csharp_style_implicit_object_creation_when_type_is_apparent = false:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:warning
csharp_style_prefer_range_operator = true:suggestion
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_prefer_utf8_string_literals = true:suggestion
Expand All @@ -149,6 +149,9 @@ dotnet_diagnostic.IDE0059.severity = none
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
dotnet_diagnostic.IDE0058.severity = none

# IDE0150: Prefer 'null' check over type check
dotnet_diagnostic.IDE0150.severity = warning

# 'using' directive preferences
csharp_using_directive_placement = outside_namespace:warning

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static IServiceCollection AddBMEcatSharp(this IServiceCollection services
services.AddTransient(sp => sp.GetRequiredService<IOptions<BMEcatOptions>>().Value);
services.AddTransient(sp => sp.GetRequiredService<IOptions<BMEcatOptions>>().Value.Serialization);

if (configureOptions is object)
if (configureOptions is not null)
{
services.Configure(configureOptions);
}
Expand Down
2 changes: 1 addition & 1 deletion src/BMEcatSharp/Types/Catalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public string? VersionForSerializer
public BMEcatDatetime? Date { get; set; }
[EditorBrowsable(EditorBrowsableState.Never)]
#pragma warning disable CS0618 // Type or member is obsolete
public bool DateSpecified => Date is object;
public bool DateSpecified => Date is not null;
#pragma warning restore CS0618 // Type or member is obsolete

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/BMEcatSharp/Types/FeatureContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public FeatureContent(FeatureDataTypeValues dataType)
[BMEXmlElement("FT_UNIT")]
public string? Unit { get; set; }
[EditorBrowsable(EditorBrowsableState.Never)]
public bool UnitSpecified => Unit is string;
public bool UnitSpecified => Unit is not null;
[XmlIgnore]
public Unit? UnitAsStandardUnit
{
Expand Down
4 changes: 2 additions & 2 deletions src/BMEcatSharp/Xml/BMEcatXmlSerializerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public BMEcatXmlSerializerFactory(BMEcatXmlSerializerOptions options)

udxMappings = new Dictionary<string, Type>();

if (options?.IncludeUdxTypes is object)
if (options?.IncludeUdxTypes is not null)
{
foreach (var type in options.IncludeUdxTypes)
{
var tagName = $"UDX.{type.Name.ToUpperInvariant()}";
var root = type.GetCustomAttribute<XmlRootAttribute>();
if (root is object)
if (root is not null)
{
tagName = root.ElementName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static IServiceCollection AddOpenTransSharp(this IServiceCollection servi
services.AddTransient(sp => sp.GetRequiredService<IOptions<OpenTransOptions>>().Value);
services.AddTransient(sp => sp.GetRequiredService<IOptions<OpenTransOptions>>().Value.Serialization);

if (configureOptions is object)
if (configureOptions is not null)
{
services.Configure(configureOptions);
}
Expand Down

0 comments on commit 5821fa1

Please sign in to comment.