Я обнаружил, что если вы добавите свою собственную реализацию ExcludeFromCodeCoverageAttribute
, то инструмент обслуживания VS будет подчиняться ей. Однако вы также должны помещать его в правильное пространство имен. YMMV.
namespace System.Diagnostics.CodeAnalysis
{
/// <summary>
/// Specifies that the attributed code should be excluded from code coverage information.
/// </summary>
/// <remarks>
/// This attribute was added to the assembly because it's not otherwise
/// available to portable class libraries. Marked internal to avoid reuse
/// outside this specific library.
/// </remarks>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event, AllowMultiple = false, Inherited = false)]
internal sealed class ExcludeFromCodeCoverageAttribute : Attribute
{
}
}
Это решение является приятным и чистым и не требует для него скрипки с помощью [DebuggerNonUserCode] для отладки сеанса ... – jackomo