Skip to content

Commit

Permalink
Disable NRT warnings for netstandard2.0 (#674)
Browse files Browse the repository at this point in the history
* Disable NRT warnings for netstandard2.0

Reasoning: netstandard2.0 does not support NRT, so these warnings are useless

* Resolve possible null reference in Organizer class
  • Loading branch information
axunonb authored Dec 20, 2024
1 parent 3c5a596 commit 4c1de35
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Ical.Net.Tests/Ical.Net.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<AssemblyOriginatorKeyFile>..\IcalNetStrongnameKey.snk</AssemblyOriginatorKeyFile>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<!-- netstandard2.0 does not support NRT -->
<NoWarn>$(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8618;CS8620;CS8714</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="NUnit" Version="4.2.2" />
Expand Down
5 changes: 3 additions & 2 deletions Ical.Net/DataTypes/Organizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public Organizer(string value) : this()
}

var serializer = new OrganizerSerializer();
CopyFrom(serializer.Deserialize(new StringReader(value)) as ICopyable);
if (serializer.Deserialize(new StringReader(value)) is ICopyable deserialized)
CopyFrom(deserialized);
}

protected bool Equals(Organizer other) => Equals(Value, other.Value);
Expand All @@ -109,7 +110,7 @@ public override bool Equals(object? obj)
public override int GetHashCode() => Value?.GetHashCode() ?? 0;

/// <inheritdoc/>
public override void CopyFrom(ICopyable obj)
public sealed override void CopyFrom(ICopyable obj)
{
base.CopyFrom(obj);

Expand Down
4 changes: 4 additions & 0 deletions Ical.Net/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
<PackageIcon>assets/icon.png</PackageIcon>
<PackageReadmeFile>assets/readme.md</PackageReadmeFile>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<!-- netstandard2.0 does not support NRT -->
<NoWarn>$(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8618;CS8620;CS8714</NoWarn>
</PropertyGroup>
<ItemGroup>
<None Include="..\readme.md">
<Pack>true</Pack>
Expand Down

0 comments on commit 4c1de35

Please sign in to comment.