Skip to content

Commit

Permalink
Exclude ZString wrappers from code coverage (#384)
Browse files Browse the repository at this point in the history
* Flag `ZStringBuilder` and `ZStringWriter`with `[ExcludeFromCodeCoverage]`
* Add AltCoverAttributeFilter="ExcludeFromCodeCoverage" in CI tests
  • Loading branch information
axunonb authored May 11, 2024
1 parent 693243b commit b438ccd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ for:
}
test_script:
- cmd: nuget install Appveyor.TestLogger
- cmd: dotnet test --framework net6.0 --test-adapter-path:. --logger:Appveyor SmartFormat.sln /p:configuration=release /p:AltCover=true /p:AltCoverXmlReport="coverage.xml" /p:AltCover=true /p:AltCoverStrongNameKey="..\SmartFormat\SmartFormat.snk" /p:AltCoverAssemblyExcludeFilter="SmartFormat.Tests|SmartFormat.ZString|NUnit3.TestAdapter" /p:AltCoverLineCover="true"
- cmd: dotnet test --framework net6.0 SmartFormat.sln /p:configuration=release /p:AltCover=true /p:AltCoverXmlReport="coverage.xml" /p:AltCoverStrongNameKey="..\SmartFormat\SmartFormat.snk" /p:AltCoverAssemblyExcludeFilter="SmartFormat.Tests|NUnit3.TestAdapter" /p:AltCoverAttributeFilter="ExcludeFromCodeCoverage" /p:AltCoverLineCover="true"
- cmd: nuget install codecov -excludeversion
- cmd: .\Codecov\Tools\win7-x86\codecov.exe -f ".\SmartFormat.Tests\coverage.net6.0.xml" -n net6.0win
artifacts:
Expand All @@ -64,5 +64,5 @@ for:
- dotnet add ./SmartFormat.Tests/SmartFormat.Tests.csproj package AltCover
- dotnet build SmartFormat.sln /verbosity:minimal /t:rebuild /p:configuration=release /nowarn:CS1591,CS0618
test_script:
- dotnet test --no-build --framework net6.0 SmartFormat.sln /p:configuration=release /p:AltCover=true /p:AltCoverXmlReport="coverage.xml" /p:AltCover=true /p:AltCoverStrongNameKey="..\SmartFormat\SmartFormat.snk" /p:AltCoverAssemblyExcludeFilter="SmartFormat.Tests|SmartFormat.ZString|NUnit3.TestAdapter" /p:AltCoverLineCover="true"
- dotnet test --no-build --framework net6.0 SmartFormat.sln /p:configuration=release /p:AltCover=true /p:AltCoverXmlReport="coverage.xml" /p:AltCoverStrongNameKey="..\SmartFormat\SmartFormat.snk" /p:AltCoverAssemblyExcludeFilter="SmartFormat.Tests|NUnit3.TestAdapter" /p:AltCoverAttributeFilter="ExcludeFromCodeCoverage" /p:AltCoverLineCover="true"
- bash <(curl -s https://codecov.io/bash) -f ./SmartFormat.Tests/coverage.net6.0.xml -n net6.0linux
3 changes: 3 additions & 0 deletions src/SmartFormat/ZString/ZStringBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices.ComTypes;
using Cysharp.Text;

namespace SmartFormat.ZString;
Expand All @@ -18,6 +20,7 @@ namespace SmartFormat.ZString;
/// We cannot add/get <see cref="ZStringBuilder"/> into/from a list or stack,
/// because it contains a value type <see langword="struct"/> <see cref="Utf16ValueStringBuilder"/>.
/// </remarks>
[ExcludeFromCodeCoverage]
public class ZStringBuilder : IDisposable
{
/**********************************
Expand Down
2 changes: 2 additions & 0 deletions src/SmartFormat/ZString/ZStringWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Licensed under the MIT license.

using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Text;
Expand All @@ -21,6 +22,7 @@ namespace SmartFormat.ZString;
/// <remarks>
/// It's important to make sure the writer is always properly disposed.
/// </remarks>
[ExcludeFromCodeCoverage]
public sealed class ZStringWriter : TextWriter
{
private readonly Cysharp.Text.ZStringWriter _zw;
Expand Down

0 comments on commit b438ccd

Please sign in to comment.