@@ -20,6 +20,7 @@ public class AssemblyVersionInfo : Task
20
20
/// See https://github.com/dotnet/Nerdbank.GitVersioning/issues/346
21
21
/// </remarks>
22
22
private const string CompilerDefinesAroundGeneratedCodeAttribute = "NETSTANDARD || NETFRAMEWORK || NETCOREAPP" ;
23
+ private const string CompilerDefinesAroundExcludeFromCodeCoverageAttribute = "NETFRAMEWORK || NETCOREAPP || NETSTANDARD2_0 || NETSTANDARD2_1" ;
23
24
24
25
public static readonly string GeneratorName = ThisAssembly . AssemblyName ;
25
26
public static readonly string GeneratorVersion = ThisAssembly . AssemblyVersion ;
@@ -519,6 +520,8 @@ internal override void StartThisAssemblyClass()
519
520
this . codeBuilder . AppendLine ( "do()" ) ;
520
521
this . codeBuilder . AppendLine ( $ "#if { CompilerDefinesAroundGeneratedCodeAttribute } ") ;
521
522
this . codeBuilder . AppendLine ( $ "[<System.CodeDom.Compiler.GeneratedCode(\" { GeneratorName } \" ,\" { GeneratorVersion } \" )>]") ;
523
+ this . codeBuilder . AppendLine ( "#endif" ) ;
524
+ this . codeBuilder . AppendLine ( $ "#if { CompilerDefinesAroundExcludeFromCodeCoverageAttribute } ") ;
522
525
this . codeBuilder . AppendLine ( "[<System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage>]" ) ;
523
526
this . codeBuilder . AppendLine ( "#endif" ) ;
524
527
this . codeBuilder . AppendLine ( "type internal ThisAssembly() =" ) ;
@@ -541,6 +544,8 @@ internal override void StartThisAssemblyClass()
541
544
{
542
545
this . codeBuilder . AppendLine ( $ "#if { CompilerDefinesAroundGeneratedCodeAttribute } ") ;
543
546
this . codeBuilder . AppendLine ( $ "[System.CodeDom.Compiler.GeneratedCode(\" { GeneratorName } \" ,\" { GeneratorVersion } \" )]") ;
547
+ this . codeBuilder . AppendLine ( "#endif" ) ;
548
+ this . codeBuilder . AppendLine ( $ "#if { CompilerDefinesAroundExcludeFromCodeCoverageAttribute } ") ;
544
549
this . codeBuilder . AppendLine ( "[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]" ) ;
545
550
this . codeBuilder . AppendLine ( "#endif" ) ;
546
551
this . codeBuilder . AppendLine ( "internal static partial class ThisAssembly {" ) ;
@@ -581,10 +586,13 @@ internal override void DeclareAttribute(Type type, string arg)
581
586
582
587
internal override void StartThisAssemblyClass ( )
583
588
{
584
- this . codeBuilder . AppendLine ( $ "#If { CompilerDefinesAroundGeneratedCodeAttribute . Replace ( "||" , " Or " ) } Then") ;
589
+ this . codeBuilder . AppendLine ( $ "#If { CompilerDefinesAroundExcludeFromCodeCoverageAttribute . Replace ( "||" , " Or " ) } Then") ;
585
590
this . codeBuilder . AppendLine ( $ "<System.CodeDom.Compiler.GeneratedCode(\" { GeneratorName } \" ,\" { GeneratorVersion } \" )>") ;
586
591
this . codeBuilder . AppendLine ( "<System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage>" ) ;
587
592
this . codeBuilder . AppendLine ( "Partial Friend NotInheritable Class ThisAssembly" ) ;
593
+ this . codeBuilder . AppendLine ( $ "#ElseIf { CompilerDefinesAroundGeneratedCodeAttribute . Replace ( "||" , " Or " ) } Then") ;
594
+ this . codeBuilder . AppendLine ( $ "<System.CodeDom.Compiler.GeneratedCode(\" { GeneratorName } \" ,\" { GeneratorVersion } \" )>") ;
595
+ this . codeBuilder . AppendLine ( "Partial Friend NotInheritable Class ThisAssembly" ) ;
588
596
this . codeBuilder . AppendLine ( "#Else" ) ;
589
597
this . codeBuilder . AppendLine ( "Partial Friend NotInheritable Class ThisAssembly" ) ;
590
598
this . codeBuilder . AppendLine ( "#End If" ) ;
0 commit comments