Skip to content

Commit bb48cba

Browse files
authored
Fix missing code coverage for Steeltoe.Management.Endpoint (#1537)
* Fix missing code coverage for Steeltoe.Management.Endpoint * Tweak runsettings - Hide coverage for RazorPagesTestWebApp - Remove settings that match the defaults * Coverage tweaks, fix Sonar error
1 parent 4e31f14 commit bb48cba

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

coverlet.runsettings

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
<DataCollector friendlyName="XPlat Code Coverage">
66
<Configuration>
77
<Format>opencover</Format>
8-
<Exclude>[*.Test*]*,[*]Microsoft.Diagnostics*</Exclude>
9-
<Include>[Steeltoe.*]*</Include>
10-
<ExcludeByAttribute>Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute</ExcludeByAttribute>
8+
<Exclude>[ConfigurationSchemaGenerator]*</Exclude>
9+
<ExcludeByFile>**/test/**/*.*</ExcludeByFile>
10+
<ExcludeByAttribute>ObsoleteAttribute,GeneratedCodeAttribute,CompilerGeneratedAttribute</ExcludeByAttribute>
1111
<UseSourceLink>true</UseSourceLink>
12-
<IncludeTestAssembly>false</IncludeTestAssembly>
13-
<SkipAutoProps>false</SkipAutoProps>
1412
</Configuration>
1513
</DataCollector>
1614
</DataCollectors>

src/Common/src/Common/ConfigurationSchemaAttributes.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
// Steeltoe: This file was copied from the .NET Aspire Configuration Schema generator
77
// at https://github.com/dotnet/aspire/tree/cb7cc4d78f8dd2b4df1053a229493cdbf88f50df/src/Tools/ConfigurationSchemaGenerator.
88

9+
using System.Diagnostics.CodeAnalysis;
10+
911
namespace Aspire;
1012

1113
/// <summary>
1214
/// Attribute used to automatically generate a JSON schema for a component's configuration.
1315
/// </summary>
1416
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
17+
[ExcludeFromCodeCoverage(Justification = "Used while compiling Steeltoe, does not ship with Steeltoe.")]
1518
internal sealed class ConfigurationSchemaAttribute : Attribute
1619
{
1720
public ConfigurationSchemaAttribute(string path, Type type, string[]? exclusionPaths = null)

src/Management/src/Endpoint/Actuators/Health/Contributors/FileSystem/NetworkShareWrapper.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information.
44

5+
using System.Diagnostics.CodeAnalysis;
56
using System.Runtime.InteropServices;
67

78
namespace Steeltoe.Management.Endpoint.Actuators.Health.Contributors.FileSystem;
@@ -26,6 +27,7 @@ private NetworkShareWrapper(ulong freeBytesAvailable, ulong totalNumberOfBytes)
2627
: null;
2728
}
2829

30+
[ExcludeFromCodeCoverage(Justification = "Workaround for https://github.com/coverlet-coverage/coverlet/issues/1762")]
2931
private static partial class NativeMethods
3032
{
3133
[LibraryImport("kernel32.dll", EntryPoint = "GetDiskFreeSpaceExW", StringMarshalling = StringMarshalling.Utf16, SetLastError = true)]

src/Management/src/Endpoint/Actuators/ThreadDump/EventPipeThreadDumper.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ public async Task<IList<ThreadInfo>> DumpThreadsAsync(CancellationToken cancella
7777
}
7878
finally
7979
{
80+
#pragma warning disable S1215 // "GC.Collect" should not be called
8081
long totalMemory = GC.GetTotalMemory(true);
82+
#pragma warning restore S1215 // "GC.Collect" should not be called
8183
_logger.LogDebug("Total memory: {Memory}.", totalMemory);
8284
}
8385
}, cancellationToken);

0 commit comments

Comments
 (0)