Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.ComponentModel;

namespace Microsoft.VisualStudio.TestPlatform;

/// <summary>
/// Only to be used to Test platform, to exclude auto generated code from CodeCoverage
/// Only to be used by the Test platform, to exclude auto generated code from code coverage.
/// New code should use <see cref="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute"/> instead;
/// this attribute is retained only so that test assemblies built against older Microsoft.NET.Test.Sdk
/// versions (which emit this attribute on the generated Main) continue to be excluded from code coverage.
/// </summary>
[AttributeUsage(AttributeTargets.All)]
[EditorBrowsable(EditorBrowsableState.Never)]
public class TestSDKAutoGeneratedCode : Attribute
{
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// <auto-generated> This file has been auto generated. </auto-generated>
using System;
[Microsoft.VisualStudio.TestPlatform.TestSDKAutoGeneratedCode]
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
class AutoGeneratedProgram {static void Main(string[] args){}}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <auto-generated> This file has been auto generated. </auto-generated>
module AutoGeneratedProgram
[<EntryPoint>]
[<Microsoft.VisualStudio.TestPlatform.TestSDKAutoGeneratedCode>]
[<System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage>]
let main _ = 0
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
' <auto-generated> This file has been auto generated. </auto-generated>
Imports System
Namespace Global
Module __MicrosoftTestPlatformAutoGeneratedProgram
<Microsoft.VisualStudio.TestPlatform.TestSDKAutoGeneratedCode>
<System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage>
Sub Main(args As String())
End Sub
End Module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ internal class EnableCodeCoverageArgumentExecutor : IArgumentExecutor
@" <Attribute>^System\.Diagnostics\.DebuggerHiddenAttribute$</Attribute>" + Environment.NewLine +
@" <Attribute>^System\.Diagnostics\.DebuggerNonUserCodeAttribute$</Attribute>" + Environment.NewLine +
@" <Attribute>^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$</Attribute>" + Environment.NewLine +
// Kept for back-compat: test assemblies built against older Microsoft.NET.Test.Sdk versions
// carry [TestSDKAutoGeneratedCode] on the auto-generated Main; newer SDK versions emit
// [ExcludeFromCodeCoverage] instead. Do not remove until those older assemblies are out of support.
@" <Attribute>^Microsoft\.VisualStudio\.TestPlatform\.TestSDKAutoGeneratedCode$</Attribute>" + Environment.NewLine +
@" </Exclude>" + Environment.NewLine +
@" </Attributes>" + Environment.NewLine +
Expand Down
Loading