Skip to content

Commit 9435ff9

Browse files
authored
fix: Added missing ExcludeFromCodeCoverage on nullability objects (#81)
to reduce the code coverage impact, when Polyfill is used.
1 parent f56b507 commit 9435ff9

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Polyfill/Nullability/NullabilityInfo.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@
99
// The .NET Foundation licenses this file to you under the MIT license.
1010

1111
using System.Collections.ObjectModel;
12+
using System.Diagnostics.CodeAnalysis;
1213

1314
namespace System.Reflection
1415
{
1516
/// <summary>
1617
/// A class that represents nullability info
1718
/// </summary>
18-
#if PolyPublic
19+
[ExcludeFromCodeCoverage]
20+
#if PolyPublic
1921
public
2022
#endif
21-
sealed class NullabilityInfo
23+
sealed class NullabilityInfo
2224
{
2325
internal NullabilityInfo(Type type, NullabilityState readState, NullabilityState writeState,
2426
NullabilityInfo? elementType, NullabilityInfo[] typeArguments)

src/Polyfill/Nullability/NullabilityInfoContext.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,19 @@
1111
using System.Collections.Generic;
1212
using System.Collections.ObjectModel;
1313
using System.Diagnostics;
14+
using System.Diagnostics.CodeAnalysis;
1415

1516
namespace System.Reflection
1617
{
1718
/// <summary>
1819
/// Provides APIs for populating nullability information/context from reflection members:
1920
/// <see cref="ParameterInfo"/>, <see cref="FieldInfo"/>, <see cref="PropertyInfo"/> and <see cref="EventInfo"/>.
2021
/// </summary>
21-
#if PolyPublic
22+
[ExcludeFromCodeCoverage]
23+
#if PolyPublic
2224
public
2325
#endif
24-
sealed class NullabilityInfoContext
26+
sealed class NullabilityInfoContext
2527
{
2628
private const string CompilerServicesNameSpace = "System.Runtime.CompilerServices";
2729
private readonly Dictionary<Module, NotAnnotatedStatus> _publicOnlyModules = new();
@@ -632,6 +634,7 @@ private static NullabilityState TranslateByte(byte b) =>
632634
private static bool IsValueTypeOrValueTypeByRef(Type type) =>
633635
type.IsValueType || ((type.IsByRef || type.IsPointer) && type.GetElementType()!.IsValueType);
634636

637+
[ExcludeFromCodeCoverage]
635638
private readonly struct NullableAttributeStateParser
636639
{
637640
private static readonly object UnknownByte = (byte)0;

0 commit comments

Comments
 (0)