Skip to content

Commit

Permalink
Format NSubstitute.csproj layout + remove unusable code
Browse files Browse the repository at this point in the history
  • Loading branch information
Romfos committed Dec 24, 2023
1 parent 02f67a8 commit bde5099
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 54 deletions.
15 changes: 3 additions & 12 deletions src/NSubstitute/Extensions/ExceptionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using NSubstitute.Core;
using System;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using NSubstitute.Core;

// Disable nullability for client API, so it does not affect clients.
#nullable disable annotations
Expand Down Expand Up @@ -247,21 +247,12 @@ private static object FromException(object value, Exception exception)

private static Task TaskFromException(Exception ex)
{
#if NET45
return new Task(() => throw ex);
#else
return Task.FromException(ex);
#endif
}

private static Task<T> TaskFromException<T>(Exception ex)
{
#if NET45
return new Task<T>(() => throw ex);
#else
return Task<T>.FromException<T>(ex);
#endif
return Task.FromException<T>(ex);
}

}
}
65 changes: 29 additions & 36 deletions src/NSubstitute/NSubstitute.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.0;net462</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<AssemblyOriginatorKeyFile>nsubstitute.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<DocumentationFile>..\..\bin\$(Configuration)\NSubstitute\$(TargetFramework)\NSubstitute.xml</DocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>

<PropertyGroup>
<Description>NSubstitute is a friendly substitute for .NET mocking libraries. It has a simple, succinct syntax to help developers write clearer tests. NSubstitute is designed for Arrange-Act-Assert (AAA) testing and with Test Driven Development (TDD) in mind.</Description>
<Version>3.0.0</Version>
<Version>5.0.0</Version>
<Authors>Anthony Egerton;David Tchepak;Alexandr Nikitin;Oleksandr Povar</Authors>
<AssemblyName>NSubstitute</AssemblyName>
<PackageId>NSubstitute</PackageId>
Expand All @@ -14,44 +25,15 @@
<RepositoryType>git</RepositoryType>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\docs\images\nsubstitute-100x100.png" Pack="true" PackagePath="icon.png" Visible="false" />
</ItemGroup>

<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.0;net462</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Castle.Core" Version="5.1.1-*" />
</ItemGroup>

<ItemGroup Condition="'$(TargetIsNet5OrNewer)' != 'true'">
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.3.0-*" />
</ItemGroup>

<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<AssemblyOriginatorKeyFile>nsubstitute.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
</PropertyGroup>

<PropertyGroup>
<DocumentationFile>..\..\bin\$(Configuration)\NSubstitute\$(TargetFramework)\NSubstitute.xml</DocumentationFile>
<NoWarn>$(NoWarn);1701;1702;1705;1591</NoWarn>
<PropertyGroup Condition="'$(TargetIsNet5OrNewer)' == 'true'">
<DefineConstants>$(DefineConstants);SYSTEM_DIAGNOSTICS_CODEANALYSIS_NULLABILITY</DefineConstants>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
<Nullable Condition="'$(TargetIsNet5OrNewer)' == 'true'">enable</Nullable>
<PropertyGroup Condition="'$(TargetIsNet5OrNewer)' != 'true'">
<!-- Nullability does not work nicely for older versions of .NET, so just disable nullability for those versions. -->
<!-- CS8632 - The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. -->
<NoWarn Condition="'$(TargetIsNet5OrNewer)' != 'true'">$(NoWarn);CS8632</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetIsNet5OrNewer)' == 'true'">
<DefineConstants>$(DefineConstants);SYSTEM_DIAGNOSTICS_CODEANALYSIS_NULLABILITY</DefineConstants>
<NoWarn>$(NoWarn);CS8632</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(CI)' == 'True'">
Expand All @@ -61,7 +43,18 @@
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
<None Include="..\..\docs\images\nsubstitute-100x100.png" Pack="true" PackagePath="icon.png" Visible="false" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Castle.Core" Version="5.1.1-*" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Condition="'$(TargetIsNet5OrNewer)' != 'true'">
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.3.0-*" />
</ItemGroup>

</Project>
10 changes: 4 additions & 6 deletions tests/NSubstitute.Acceptance.Specs/ThrowingAsyncExceptions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#if !NET45
using NSubstitute.Acceptance.Specs.Infrastructure;
using NSubstitute.ExceptionExtensions;
using NUnit.Framework;
using System;
using System.Linq;
using System.Threading.Tasks;
using NSubstitute.Acceptance.Specs.Infrastructure;
using NSubstitute.ExceptionExtensions;
using NUnit.Framework;

namespace NSubstitute.Acceptance.Specs
{
Expand Down Expand Up @@ -338,5 +337,4 @@ public static TException AssertFaultedTaskException<TException>(Func<Task> act)
return actual.Exception!.InnerExceptions.First() as TException;
}
}
}
#endif
}

0 comments on commit bde5099

Please sign in to comment.