Skip to content

Commit

Permalink
Explicitly support netstandard2.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
hennadiilu committed Oct 7, 2022
1 parent 374ed1d commit 7b67bf7
Show file tree
Hide file tree
Showing 11 changed files with 128 additions and 114 deletions.
2 changes: 1 addition & 1 deletion Heleonix.Guard.Tests/ExceptionRaiserTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <copyright file="ExceptionRaiserTests.cs" company="Heleonix - Hennadii Lutsyshyn">
// Copyright (c) 2017-present Heleonix - Hennadii Lutsyshyn. All rights reserved.
// Copyright (c) Heleonix - Hennadii Lutsyshyn. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the repository root for full license information.
// </copyright>

Expand Down
51 changes: 30 additions & 21 deletions Heleonix.Guard.Tests/Heleonix.Guard.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,48 +1,57 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../SharedProjectInfo.props" />

<PropertyGroup>
<TargetFramework>net472</TargetFramework>

<IsPackable>false</IsPackable>
<TargetFramework>net6.0</TargetFramework>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
<DocumentationFile>bin\Debug\netcoreapp2.0\Heleonix.Utilities.Tests.xml</DocumentationFile>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
<DocumentationFile>bin\Release\netcoreapp2.0\Heleonix.Utilities.Tests.xml</DocumentationFile>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<AdditionalFiles Include="..\stylecop.json" Link="stylecop.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Heleonix.Testing.NUnit" Version="1.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.0" />
<PackageReference Include="moq" Version="4.8.2" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
<PackageReference Include="codecracker.CSharp" Version="1.1.0" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.4" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="7.16.0.8981" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
<PackageReference Include="SecurityCodeScan" Version="3.2.0" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
<PackageReference Include="codecracker.CSharp" Version="1.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Heleonix.Testing.NUnit" Version="2.0.1" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="Moq" Version="4.18.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="SecurityCodeScan.VS2019" Version="5.6.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.46.0.54807">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Heleonix.Guard\Heleonix.Guard.csproj" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Heleonix.Guard.Tests/HostTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <copyright file="HostTests.cs" company="Heleonix - Hennadii Lutsyshyn">
// Copyright (c) 2017-present Heleonix - Hennadii Lutsyshyn. All rights reserved.
// Copyright (c) Heleonix - Hennadii Lutsyshyn. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the repository root for full license information.
// </copyright>

Expand Down
6 changes: 3 additions & 3 deletions Heleonix.Guard.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2005
# Visual Studio Version 17
VisualStudioVersion = 17.3.32901.215
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Heleonix.Guard", "Heleonix.Guard\Heleonix.Guard.csproj", "{B744C864-3D66-4CCA-82DD-E9BD2B92036F}"
EndProject
Expand All @@ -10,8 +10,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
LICENSE = LICENSE
README.md = README.md
SharedProjectInfo.props = SharedProjectInfo.props
stylecop.json = stylecop.json
SharedPackageInfo.props = SharedPackageInfo.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Heleonix.Guard.Tests", "Heleonix.Guard.Tests\Heleonix.Guard.Tests.csproj", "{B35408E2-D592-4157-997A-21611F54D54D}"
Expand Down
86 changes: 42 additions & 44 deletions Heleonix.Guard/ExceptionRaiser.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <copyright file="ExceptionRaiser.cs" company="Heleonix - Hennadii Lutsyshyn">
// Copyright (c) 2017-present Heleonix - Hennadii Lutsyshyn. All rights reserved.
// Copyright (c) Heleonix - Hennadii Lutsyshyn. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the repository root for full license information.
// </copyright>

Expand Down Expand Up @@ -152,20 +152,6 @@ public void AggregateException(bool when, string message = null, params Exceptio
}
}

/// <summary>
/// Raises the <see cref="System.MissingMemberException"/>.
/// </summary>
/// <param name="when">A condition to throw the exception.</param>
/// <param name="message">The message.</param>
/// <param name="innerException">The inner exception.</param>
public void MissingMemberException(bool when, string message, Exception innerException)
{
if (when)
{
throw new MissingMemberException(message, innerException);
}
}

/// <summary>
/// Raises the <see cref="FileNotFoundException"/>.
/// </summary>
Expand Down Expand Up @@ -450,92 +436,91 @@ public void DirectoryNotFoundException(bool when, string message = null, Excepti
}

/// <summary>
/// Raises the <see cref="System.MissingFieldException"/>.
/// Raises the <see cref="PathTooLongException"/>.
/// </summary>
/// <param name="when">A condition to throw the exception.</param>
/// <param name="message">The message.</param>
/// <param name="innerException">The inner exception.</param>
public void MissingFieldException(bool when, string message = null, Exception innerException = null)
public void PathTooLongException(bool when, string message = null, Exception innerException = null)
{
if (when)
{
throw new MissingFieldException(message, innerException);
throw new PathTooLongException(message, innerException);
}
}

/// <summary>
/// Raises the <see cref="System.MissingMethodException"/>.
/// Raises the <see cref="FileLoadException"/>.
/// </summary>
/// <param name="when">A condition to throw the exception.</param>
/// <param name="message">The message.</param>
/// <param name="fileName">The file name.</param>
/// <param name="innerException">The inner exception.</param>
public void MissingMethodException(bool when, string message = null, Exception innerException = null)
public void FileLoadException(
bool when,
string message = null,
string fileName = null,
Exception innerException = null)
{
if (when)
{
throw new MissingMethodException(message, innerException);
throw new FileLoadException(message, fileName, innerException);
}
}

/// <summary>
/// Raises the <see cref="PathTooLongException"/>.
/// Raises the <see cref="System.MissingMemberException"/>.
/// </summary>
/// <param name="when">A condition to throw the exception.</param>
/// <param name="message">The message.</param>
/// <param name="innerException">The inner exception.</param>
public void PathTooLongException(bool when, string message = null, Exception innerException = null)
/// <param name="className">The class name.</param>
/// <param name="memberName">The member name.</param>
public void MissingMemberException(bool when, string className = null, string memberName = null)
{
if (when)
{
throw new PathTooLongException(message, innerException);
throw new MissingMemberException(className, memberName);
}
}

/// <summary>
/// Raises the <see cref="FileLoadException"/>.
/// Raises the <see cref="System.MissingMemberException"/>.
/// </summary>
/// <param name="when">A condition to throw the exception.</param>
/// <param name="message">The message.</param>
/// <param name="fileName">The file name.</param>
/// <param name="innerException">The inner exception.</param>
public void FileLoadException(
bool when,
string message = null,
string fileName = null,
Exception innerException = null)
public void MissingMemberException(bool when, string message, Exception innerException)
{
if (when)
{
throw new FileLoadException(message, fileName, innerException);
throw new MissingMemberException(message, innerException);
}
}

#if !NETSTANDARD1_6
/// <summary>
/// Raises the <see cref="System.MissingMemberException"/>.
/// Raises the <see cref="System.MissingFieldException"/>.
/// </summary>
/// <param name="when">A condition to throw the exception.</param>
/// <param name="className">The class name.</param>
/// <param name="memberName">The member name.</param>
public void MissingMemberException(bool when, string className = null, string memberName = null)
/// <param name="fieldName">The field name.</param>
public void MissingFieldException(bool when, string className = null, string fieldName = null)
{
if (when)
{
throw new MissingMemberException(className, memberName);
throw new MissingFieldException(className, fieldName);
}
}

/// <summary>
/// Raises the <see cref="System.MissingFieldException"/>.
/// </summary>
/// <param name="when">A condition to throw the exception.</param>
/// <param name="className">The class name.</param>
/// <param name="fieldName">The field name.</param>
public void MissingFieldException(bool when, string className = null, string fieldName = null)
/// <param name="message">The message.</param>
/// <param name="innerException">The inner exception.</param>
public void MissingFieldException(bool when, string message = null, Exception innerException = null)
{
if (when)
{
throw new MissingFieldException(className, fieldName);
throw new MissingFieldException(message, innerException);
}
}

Expand All @@ -553,6 +538,20 @@ public void MissingMethodException(bool when, string className = null, string me
}
}

/// <summary>
/// Raises the <see cref="System.MissingMethodException"/>.
/// </summary>
/// <param name="when">A condition to throw the exception.</param>
/// <param name="message">The message.</param>
/// <param name="innerException">The inner exception.</param>
public void MissingMethodException(bool when, string message = null, Exception innerException = null)
{
if (when)
{
throw new MissingMethodException(message, innerException);
}
}

/// <summary>
/// Raises the <see cref="InvalidCredentialException"/>.
/// </summary>
Expand Down Expand Up @@ -608,7 +607,6 @@ public void SerializationException(bool when, string message = null, Exception i
throw new SerializationException(message, innerException);
}
}
#endif
#pragma warning restore CA1822 // Mark members as static
#pragma warning restore CC0091 // Use static method
}
Expand Down
58 changes: 29 additions & 29 deletions Heleonix.Guard/Heleonix.Guard.csproj
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../SharedProjectInfo.props" />
<Import Project="../SharedPackageInfo.props" />

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard1.6;net45;net451;net452;net46;net461;net462</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<SignAssembly>false</SignAssembly>
<DelaySign>false</DelaySign>
<AssemblyOriginatorKeyFile>Heleonix-pair.snk</AssemblyOriginatorKeyFile>
<Description>Provides performant guard functionality for methods to throw exceptions</Description>
<PackageTags>Heleonix guard throw codecontract</PackageTags>
<PackageReleaseNotes>Explicit support of netstandard2.0 only.</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
<DocumentationFile>bin\Debug\netstandard2.0\Heleonix.Guard.xml</DocumentationFile>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
<DocumentationFile>bin\Release\netstandard2.0\Heleonix.Guard.xml</DocumentationFile>
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<LangVersion>latest</LangVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<AdditionalFiles Include="..\stylecop.json" Link="stylecop.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Heleonix.Extensions" Version="1.0.0" />
<PackageReference Include="codecracker.CSharp" Version="1.1.0" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.4" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="7.16.0.8981" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
<PackageReference Include="SecurityCodeScan" Version="3.2.0" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
</ItemGroup>

<ItemGroup>
<Folder Include="Properties\" />
<PackageReference Include="codecracker.CSharp" Version="1.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SecurityCodeScan.VS2019" Version="5.6.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.46.0.54807">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Heleonix.Guard/Host.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <copyright file="Host.cs" company="Heleonix - Hennadii Lutsyshyn">
// Copyright (c) 2017-present Heleonix - Hennadii Lutsyshyn. All rights reserved.
// Copyright (c) Heleonix - Hennadii Lutsyshyn. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the repository root for full license information.
// </copyright>

Expand Down
2 changes: 1 addition & 1 deletion Heleonix.Guard/Properties/AssemblyProperties.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <copyright file="AssemblyProperties.cs" company="Heleonix - Hennadii Lutsyshyn">
// Copyright (c) 2017-present Heleonix - Hennadii Lutsyshyn. All rights reserved.
// Copyright (c) Heleonix - Hennadii Lutsyshyn. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the repository root for full license information.
// </copyright>

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2017-present Heleonix - Hennadii Lutsyshyn
Copyright (c) Heleonix - Hennadii Lutsyshyn

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit 7b67bf7

Please sign in to comment.