Skip to content

Commit

Permalink
(test) Introduce NUnit.Analyzers
Browse files Browse the repository at this point in the history
This will help aid in the transition to NUnit 4, where there have been
some breaking changes.
  • Loading branch information
gep13 committed Jul 10, 2024
1 parent 191eefc commit 52ed083
Show file tree
Hide file tree
Showing 12 changed files with 302 additions and 279 deletions.
66 changes: 33 additions & 33 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
<Project>
<PropertyGroup>
<DebugType>pdbonly</DebugType>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>CS1591</NoWarn>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
</PropertyGroup>

<ItemGroup>
<CodeAnalysisDictionary Include="$(MSBuildThisFileDirectory)\CustomDictionary.xml">
<Link>CustomDictionary.xml</Link>
</CodeAnalysisDictionary>
<AdditionalFiles Include="$(MSBuildThisFileDirectory)\stylecop.json" Link="stylecop.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Serilog" Version="4.0.0" />
<PackageReference Include="IDisposableAnalyzers" Version="4.0.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Roslynator.Analyzers" Version="4.12.4">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>
<Project>
<PropertyGroup>
<DebugType>pdbonly</DebugType>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>CS1591</NoWarn>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
</PropertyGroup>

<ItemGroup>
<CodeAnalysisDictionary Include="$(MSBuildThisFileDirectory)\CustomDictionary.xml">
<Link>CustomDictionary.xml</Link>
</CodeAnalysisDictionary>
<AdditionalFiles Include="$(MSBuildThisFileDirectory)\stylecop.json" Link="stylecop.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Serilog" Version="4.0.0" />
<PackageReference Include="IDisposableAnalyzers" Version="4.0.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Roslynator.Analyzers" Version="4.12.4">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
62 changes: 31 additions & 31 deletions src/GitReleaseManager.Cli/GitReleaseManager.Cli.csproj
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<LangVersion>8.0</LangVersion>
<OutputType>Exe</OutputType>
<AssemblyName>GitReleaseManager</AssemblyName>
<TargetFrameworks>net6.0</TargetFrameworks>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<Title>GitReleaseManager.Cli</Title>
<Description>Create release notes in markdown given a milestone</Description>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);CA1707;</NoWarn>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\GitReleaseManager.Core\GitReleaseManager.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Destructurama.Attributed" Version="4.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Octokit" Version="12.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="seriloganalyzer" Version="0.15.0" />
</ItemGroup>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<LangVersion>8.0</LangVersion>
<OutputType>Exe</OutputType>
<AssemblyName>GitReleaseManager</AssemblyName>
<TargetFrameworks>net6.0</TargetFrameworks>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<Title>GitReleaseManager.Cli</Title>
<Description>Create release notes in markdown given a milestone</Description>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);CA1707;</NoWarn>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\GitReleaseManager.Core\GitReleaseManager.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Destructurama.Attributed" Version="4.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Octokit" Version="12.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="seriloganalyzer" Version="0.15.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<LangVersion>8.0</LangVersion>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<Title>GitReleaseManager.Core.Tests</Title>
<Description>Test Project for GitReleaseManager.Core</Description>
<NoWarn>$(NoWarn);CA1707;Serilog004;</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\GlobalSuppressions.cs" Link="GlobalSuppressions.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GitReleaseManager.Core\GitReleaseManager.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="ApprovalTests" Version="6.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Octokit" Version="12.0.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
</ItemGroup>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<LangVersion>8.0</LangVersion>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<Title>GitReleaseManager.Core.Tests</Title>
<Description>Test Project for GitReleaseManager.Core</Description>
<NoWarn>$(NoWarn);CA1707;Serilog004;</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\GlobalSuppressions.cs" Link="GlobalSuppressions.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GitReleaseManager.Core\GitReleaseManager.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="ApprovalTests" Version="6.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Octokit" Version="12.0.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
</ItemGroup>
</Project>
98 changes: 49 additions & 49 deletions src/GitReleaseManager.Core/GitReleaseManager.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
<Project Sdk="Microsoft.NET.Sdk">
<!-- This two imports allow visual studio to transform text templates during building (1 for VS2019, and 1 for VS2017) -->
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v16.0\TextTemplating\Microsoft.TextTemplating.targets" Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v16.0\TextTemplating\Microsoft.TextTemplating.targets')" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v15.0\TextTemplating\Microsoft.TextTemplating.targets" Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v15.0\TextTemplating\Microsoft.TextTemplating.targets')" />
<PropertyGroup>
<LangVersion>8.0</LangVersion>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<Title>GitReleaseManager.Core</Title>
<Description>Create release notes in markdown given a milestone</Description>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);CA1707;</NoWarn>
<TransformOnBuild>true</TransformOnBuild>
</PropertyGroup>

<ItemGroup>
<T4ReferencePath Include="$(VsIdePath)PublicAssemblies\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Destructurama.Attributed" Version="4.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NGitLab" Version="6.51.1" />
<PackageReference Include="Octokit" Version="12.0.0" />
<PackageReference Include="Scriban" Version="5.10.0" />
<PackageReference Include="seriloganalyzer" Version="0.15.0" />
<PackageReference Include="YamlDotNet" Version="13.7.1" />
<PackageReference Include="AutoMapper" Version="12.0.1" />
</ItemGroup>
<ItemGroup>
<Compile Update="Templates\ReleaseTemplates.g.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>ReleaseTemplates.tt</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="Templates\ReleaseTemplates.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>ReleaseTemplates.g.cs</LastGenOutput>
</None>
<None Include="Templates/**/*.sbn" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<Project Sdk="Microsoft.NET.Sdk">
<!-- This two imports allow visual studio to transform text templates during building (1 for VS2019, and 1 for VS2017) -->
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v16.0\TextTemplating\Microsoft.TextTemplating.targets" Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v16.0\TextTemplating\Microsoft.TextTemplating.targets')" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v15.0\TextTemplating\Microsoft.TextTemplating.targets" Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v15.0\TextTemplating\Microsoft.TextTemplating.targets')" />
<PropertyGroup>
<LangVersion>8.0</LangVersion>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<Title>GitReleaseManager.Core</Title>
<Description>Create release notes in markdown given a milestone</Description>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);CA1707;</NoWarn>
<TransformOnBuild>true</TransformOnBuild>
</PropertyGroup>

<ItemGroup>
<T4ReferencePath Include="$(VsIdePath)PublicAssemblies\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Destructurama.Attributed" Version="4.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NGitLab" Version="6.51.1" />
<PackageReference Include="Octokit" Version="12.0.0" />
<PackageReference Include="Scriban" Version="5.10.0" />
<PackageReference Include="seriloganalyzer" Version="0.15.0" />
<PackageReference Include="YamlDotNet" Version="13.7.1" />
<PackageReference Include="AutoMapper" Version="12.0.1" />
</ItemGroup>
<ItemGroup>
<Compile Update="Templates\ReleaseTemplates.g.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>ReleaseTemplates.tt</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="Templates\ReleaseTemplates.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>ReleaseTemplates.g.cs</LastGenOutput>
</None>
<None Include="Templates/**/*.sbn" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public class GitLabProviderIntegrationTests
private GitLabProvider _gitLabProvider;
private IGitLabClient _gitLabClient;
private IMapper _mapper;
#pragma warning disable NUnit1032 // An IDisposable field/property should be Disposed in a TearDown method
private ILogger _logger;
#pragma warning restore NUnit1032 // An IDisposable field/property should be Disposed in a TearDown method

private string _token;
private string _releaseBaseTag;
Expand All @@ -48,6 +50,12 @@ public void OneTimeSetUp()
_gitLabProvider = new GitLabProvider(_gitLabClient, _mapper, _logger);
}

[OneTimeTearDown]
public void OneTimeTearDown()
{
(_logger as IDisposable)?.Dispose();
}

[Test]
[Order(1)]
public async Task Should_Get_Milestones()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<LangVersion>8.0</LangVersion>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<Title>GitReleaseManager.IntegrationTests</Title>
<Description>Integration Test Project for GitReleaseManager</Description>
<NoWarn>$(NoWarn);CA1707;Serilog004;</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\GlobalSuppressions.cs" Link="GlobalSuppressions.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GitReleaseManager.Core\GitReleaseManager.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nunit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="TextCopy" Version="6.2.1" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<LangVersion>8.0</LangVersion>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<Title>GitReleaseManager.IntegrationTests</Title>
<Description>Integration Test Project for GitReleaseManager</Description>
<NoWarn>$(NoWarn);CA1707;Serilog004;</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\GlobalSuppressions.cs" Link="GlobalSuppressions.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GitReleaseManager.Core\GitReleaseManager.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="TextCopy" Version="6.2.1" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>
</Project>
Loading

0 comments on commit 52ed083

Please sign in to comment.