diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.IndexerSetups.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.IndexerSetups.cs index 2dbdb99e..84995447 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.IndexerSetups.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.IndexerSetups.cs @@ -27,6 +27,7 @@ namespace Mockolate.Setup namespace Mockolate { [global::System.Diagnostics.DebuggerNonUserCode] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal static class IndexerSetupExtensions { """).AppendLine(); @@ -286,6 +287,7 @@ private static void AppendIndexerSetup(StringBuilder sb, int numberOfParameters) sb.AppendXmlSummary($"Sets up a indexer for {GetTypeParametersDescription(numberOfParameters)}.", "\t"); sb.Append("\t[global::System.Diagnostics.DebuggerNonUserCode]").AppendLine(); + sb.Append("\t[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]").AppendLine(); sb.Append("\tinternal class IndexerSetup(") .Append( string.Join(", ", Enumerable.Range(1, numberOfParameters).Select(i => $"global::Mockolate.Parameters.NamedParameter match{i}"))) diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MethodSetups.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MethodSetups.cs index 2717123d..274669a6 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.MethodSetups.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MethodSetups.cs @@ -32,6 +32,7 @@ namespace Mockolate.Setup namespace Mockolate { [global::System.Diagnostics.DebuggerNonUserCode] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal static class MethodSetupExtensions { """).AppendLine(); @@ -259,6 +260,7 @@ private static void AppendVoidMethodSetup(StringBuilder sb, int numberOfParamete $"Sets up a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .", ""); sb.Append("\t[global::System.Diagnostics.DebuggerNonUserCode]").AppendLine(); + sb.Append("\t[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]").AppendLine(); sb.Append("internal class VoidMethodSetup<").Append(typeParams) .Append("> : global::Mockolate.Setup.MethodSetup,").AppendLine(); sb.Append("\t\tglobal::Mockolate.Setup.IVoidMethodSetupCallbackBuilder<").Append(typeParams).Append(">,").AppendLine(); @@ -832,6 +834,7 @@ private static void AppendReturnMethodSetup(StringBuilder sb, int numberOfParame $"Sets up a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .", "\t"); sb.Append("\t[global::System.Diagnostics.DebuggerNonUserCode]").AppendLine(); + sb.Append("\t[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]").AppendLine(); sb.Append("\tinternal class ReturnMethodSetup : global::Mockolate.Setup.MethodSetup,").AppendLine(); sb.Append("\t\tglobal::Mockolate.Setup.IReturnMethodSetupCallbackBuilder,").AppendLine(); diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.Mock.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.Mock.cs index 2a8b1aea..6144a018 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.Mock.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.Mock.cs @@ -24,6 +24,7 @@ namespace Mockolate; /// If your type is a class without a default constructor, you can provide constructor parameters by passing an object?[]? to the corresponding CreateMock(...) overload. /// [global::System.Diagnostics.DebuggerNonUserCode] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal static partial class Mock { /// diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MockBehaviorExtensions.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MockBehaviorExtensions.cs index c9d1d4c6..0c85369d 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.MockBehaviorExtensions.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MockBehaviorExtensions.cs @@ -58,6 +58,7 @@ public interface IDefaultValueFactory /// parameter . /// [global::System.Diagnostics.DebuggerNonUserCode] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal class TypedDefaultValueFactory(T value) : IDefaultValueFactory { /// @@ -77,6 +78,7 @@ public bool IsMatch(global::System.Type type) /// . /// [global::System.Diagnostics.DebuggerNonUserCode] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] private sealed class HttpResponseMessageFactory(global::System.Net.HttpStatusCode statusCode) : IDefaultValueFactory { /// @@ -96,6 +98,7 @@ public bool IsMatch(global::System.Type type) /// Provides default values for common types used in mocking scenarios. /// [global::System.Diagnostics.DebuggerNonUserCode] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] private class DefaultValueGenerator : IDefaultValueGenerator { private static readonly global::System.Collections.Concurrent.ConcurrentQueue _factories = new([ @@ -168,6 +171,7 @@ private static bool HasCanceledCancellationToken(object?[] parameters, out globa } [global::System.Diagnostics.DebuggerNonUserCode] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] private sealed class CancellableTaskFactory : IDefaultValueFactory { /// @@ -187,6 +191,7 @@ public object Create(global::System.Type type, IDefaultValueGenerator defaultVal } #if NET8_0_OR_GREATER [global::System.Diagnostics.DebuggerNonUserCode] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] private sealed class CancellableValueTaskFactory : IDefaultValueFactory { /// @@ -212,6 +217,7 @@ public object Create(global::System.Type type, IDefaultValueGenerator defaultVal /// Extensions on /// [global::System.Diagnostics.DebuggerNonUserCode] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal static class DefaultValueGeneratorExtensions { /// diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs index d83af1d6..7de6e4bb 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs @@ -40,6 +40,7 @@ public static string MockClass(string name, Class @class, bool hasOverloadResolu sb.AppendXmlSummary($"Mock extensions for .", ""); sb.Append("[global::System.Diagnostics.DebuggerNonUserCode]").AppendLine(); + sb.Append("[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]").AppendLine(); sb.Append("internal static partial class MockExtensionsFor").Append(name).AppendLine(); sb.Append("{").AppendLine(); @@ -360,6 +361,7 @@ static bool TryCastWithDefaultValue(object?[] values, int index, TValue sb.AppendLine(); sb.Append("\t[global::System.Diagnostics.DebuggerNonUserCode]").AppendLine(); + sb.Append("\t[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]").AppendLine(); sb.Append("\tinternal sealed class MockSetup(global::Mockolate.MockRegistry mockRegistry) : global::Mockolate.Mock.IMockSetupFor").Append(name); if (hasProtectedMembers) { @@ -407,6 +409,7 @@ static bool TryCastWithDefaultValue(object?[] values, int index, TValue sb.AppendXmlSummary($"A mock implementation for .", "\t"); sb.Append("\t[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]").AppendLine(); sb.Append("\t[global::System.Diagnostics.DebuggerNonUserCode]").AppendLine(); + sb.Append("\t[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]").AppendLine(); sb.Append("\tinternal class ").Append(name).Append(" :").AppendLine(); sb.Append("\t\t").Append(@class.ClassFullName); sb.Append(", IMockFor").Append(name).Append(", IMockSetupFor").Append(name); @@ -616,6 +619,7 @@ static bool TryCastWithDefaultValue(object?[] values, int index, TValue sb.AppendLine(); sb.Append("\t[global::System.Diagnostics.DebuggerNonUserCode]").AppendLine(); + sb.Append("\t[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]").AppendLine(); sb.Append("\tprivate sealed class VerifyMonitor").Append(name).Append("(global::Mockolate.MockRegistry mockRegistry) : global::Mockolate.Mock.IMockVerifyFor").Append(name).AppendLine(); sb.Append("\t{").AppendLine(); sb.Append("\t\tprivate global::Mockolate.MockRegistry ").Append(mockRegistryName).Append(" { get; } = mockRegistry;").AppendLine(); diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MockCombination.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MockCombination.cs index 34cd0bad..32d61b80 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.MockCombination.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MockCombination.cs @@ -36,6 +36,7 @@ public static string MockCombinationClass( sb.AppendXmlSummary($"Mock extensions for that also implements
\n/// - {string.Join("
\n/// - ", additionalInterfaces.Select(x => $""))}.", ""); sb.Append("[global::System.Diagnostics.DebuggerNonUserCode]").AppendLine(); + sb.Append("[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]").AppendLine(); sb.Append("internal static partial class MockExtensionsFor").Append(fileName).AppendLine(); sb.Append("{").AppendLine(); @@ -253,6 +254,7 @@ static bool TryCastWithDefaultValue(object?[] values, int index, TValue sb.AppendXmlSummary($"A mock implementation for that also implements
\n\t/// - {string.Join("
\n\t/// - ", additionalInterfaces.Select(x => $""))}.", "\t"); sb.Append("\t[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]").AppendLine(); sb.Append("\t[global::System.Diagnostics.DebuggerNonUserCode]").AppendLine(); + sb.Append("\t[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]").AppendLine(); sb.Append("\tinternal class ").Append(fileName).Append(" :").AppendLine(); sb.Append("\t\t").Append(@class.ClassFullName).Append(", ").Append("IMockFor").Append(name).Append(", IMockSetupFor").Append(name); if (hasProtectedMembers) diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MockDelegate.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MockDelegate.cs index 08698360..23e5b674 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.MockDelegate.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MockDelegate.cs @@ -21,6 +21,7 @@ public static string MockDelegate(string name, MockClass @class, Method delegate sb.AppendXmlSummary($"Mock extensions for .", ""); sb.Append("[global::System.Diagnostics.DebuggerNonUserCode]").AppendLine(); + sb.Append("[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]").AppendLine(); sb.Append("internal static partial class MockExtensionsFor").Append(name).AppendLine(); sb.Append("{").AppendLine(); @@ -99,6 +100,7 @@ public static string MockDelegate(string name, MockClass @class, Method delegate sb.Append("\t///
").AppendLine(); sb.Append("\t[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]").AppendLine(); sb.Append("\t[global::System.Diagnostics.DebuggerNonUserCode]").AppendLine(); + sb.Append("\t[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]").AppendLine(); sb.Append("\tinternal class ").Append(name).Append(" :").AppendLine(); sb.Append("\t\tIMockFor").Append(name).Append(',').AppendLine(); sb.Append("\t\tglobal::Mockolate.IMock").AppendLine(); @@ -244,6 +246,7 @@ public static string MockDelegate(string name, MockClass @class, Method delegate sb.AppendLine(); sb.Append("\t[global::System.Diagnostics.DebuggerNonUserCode]").AppendLine(); + sb.Append("\t[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]").AppendLine(); sb.Append("\tprivate sealed class VerifyMonitor").Append(name).Append("(global::Mockolate.MockRegistry mockRegistry) : global::Mockolate.Mock.IMockVerifyFor").Append(name).AppendLine(); sb.Append("\t{").AppendLine(); sb.Append("\t\tprivate global::Mockolate.MockRegistry ").Append(mockRegistryName).Append(" { get; } = mockRegistry;").AppendLine(); diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.ReturnsAsyncExtensions.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.ReturnsAsyncExtensions.cs index 63cb0ff2..94529bc2 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.ReturnsAsyncExtensions.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.ReturnsAsyncExtensions.cs @@ -19,6 +19,7 @@ namespace Mockolate; sb.Append("/// Extensions for setting up return values and throwing exceptions for methods.").AppendLine(); sb.Append("/// ").AppendLine(); sb.Append("[global::System.Diagnostics.DebuggerNonUserCode]").AppendLine(); + sb.Append("[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]").AppendLine(); sb.Append("internal static class ReturnsThrowsAsyncExtensions2").AppendLine(); sb.Append("{").AppendLine(); foreach (int number in numberOfParameters)