Skip to content

#if'ed the definition of ExcludeFromCodeCoverageAttribute depending o… #2332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2020
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 @@ -8,6 +8,22 @@
// </auto-generated>
//------------------------------------------------------------------------------

#if NET20 || NET35 || NETCOREAPP1_0 || NETCOREAPP1_1 || NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2 || NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5 || NETSTANDARD1_6
namespace System.Diagnostics.CodeAnalysis
{
[global::System.AttributeUsage(
global::System.AttributeTargets.Assembly |
global::System.AttributeTargets.Class |
global::System.AttributeTargets.Struct |
global::System.AttributeTargets.Constructor |
global::System.AttributeTargets.Method |
global::System.AttributeTargets.Property |
global::System.AttributeTargets.Event,
Inherited = false, AllowMultiple = false)]
internal sealed class ExcludeFromCodeCoverageAttribute : global::System.Attribute { }
}
#endif

[global::System.Runtime.CompilerServices.CompilerGenerated]
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
static class GitVersionInformation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
// </auto-generated>
//------------------------------------------------------------------------------

#if NET20 || NET35 || NETCOREAPP1_0 || NETCOREAPP1_1 || NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2 || NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5 || NETSTANDARD1_6
namespace System.Diagnostics.CodeAnalysis

[<Sealed>]
[<global.System.AttributeUsage(
global.System.AttributeTargets.Assembly |||
global.System.AttributeTargets.Class |||
global.System.AttributeTargets.Struct |||
global.System.AttributeTargets.Constructor |||
global.System.AttributeTargets.Method |||
global.System.AttributeTargets.Property |||
global.System.AttributeTargets.Event,
Inherited = false, AllowMultiple = false)>]
type ExcludeFromCodeCoverageAttribute() = inherit global.System.Attribute()
#endif

namespace global

[<AbstractClass; Sealed>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
' </auto-generated>
'------------------------------------------------------------------------------

#If NET20 OrElse NET35 OrElse NETCOREAPP1_0 OrElse NETCOREAPP1_1 OrElse NETSTANDARD1_0 OrElse NETSTANDARD1_1 OrElse NETSTANDARD1_2 OrElse NETSTANDARD1_3 OrElse NETSTANDARD1_4 OrElse NETSTANDARD1_5 OrElse NETSTANDARD1_6 Then
Namespace Global.System.Diagnostics.CodeAnalysis
<Global.System.AttributeUsage(
Global.System.AttributeTargets.Assembly Or
Global.System.AttributeTargets.Class Or
Global.System.AttributeTargets.Struct Or
Global.System.AttributeTargets.Constructor Or
Global.System.AttributeTargets.Method Or
Global.System.AttributeTargets.Property Or
Global.System.AttributeTargets.Event, Inherited:=False, AllowMultiple:=False)>
Friend NotInheritable Class ExcludeFromCodeCoverageAttribute
Inherits Global.System.Attribute
End Class
End Namespace
#End If

Namespace Global

<Global.System.Runtime.CompilerServices.CompilerGenerated()>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
// </auto-generated>
//------------------------------------------------------------------------------

#if NET20 || NET35 || NETCOREAPP1_0 || NETCOREAPP1_1 || NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2 || NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5 || NETSTANDARD1_6
namespace System.Diagnostics.CodeAnalysis
{{
[global::System.AttributeUsage(
global::System.AttributeTargets.Assembly |
global::System.AttributeTargets.Class |
global::System.AttributeTargets.Struct |
global::System.AttributeTargets.Constructor |
global::System.AttributeTargets.Method |
global::System.AttributeTargets.Property |
global::System.AttributeTargets.Event,
Inherited = false, AllowMultiple = false)]
internal sealed class ExcludeFromCodeCoverageAttribute : global::System.Attribute {{ }}
}}
#endif

[global::System.Runtime.CompilerServices.CompilerGenerated]
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
static class GitVersionInformation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
// </auto-generated>
//------------------------------------------------------------------------------

#if NET20 || NET35 || NETCOREAPP1_0 || NETCOREAPP1_1 || NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2 || NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5 || NETSTANDARD1_6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't SHOULD_DEFINE_EXCLUDE_FROM_CODE_COVERAGE be defined in F# as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no preprocessor instruction in F# that allows defining a constant (when you need one you have to pass it to the compiler with a -d argument). And the SHOULD_DEFINE_EXCLUDE_FROM_CODE_COVERAGE constant has no special meaning, it's just used to split the #if as I said above.

I agree this is not consistant. If you prefer, I can have everything look more like the F# version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer consistency. Hopefully, we can replace these #if statements with a check before the files are generated in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully, we can replace these #if statements with a check before the files are generated in the first place.

I suppose you are referring to a solution similar to what was suggested in the issue: having the support of the attribute detected by MSBuild? That would probably work but:

  • I'm not that familiar (yet) with how MSBuild code works in GitVersion,
  • Will you ever want to support generation of GitVersionInformation class from the command-line utility? If so, I think we can't rely on constants defined in a MSBuild file that would not exist in this case.

Anyway, I don't have clear ideas to how we can reliably get rid of this ugly #if, but in the meantime and if you're ok with this. I'll simply have everything look more like the F# version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose you are referring to a solution similar to what was suggested in the issue: having the support of the attribute detected by MSBuild?

Correct. I agree that the solution is difficult, though, which is why I think we should go ahead with this #if-based solution first.

Anyway, I don't have clear ideas to how we can reliably get rid of this ugly #if, but in the meantime and if you're ok with this. I'll simply have everything look more like the F# version.

👍

namespace System.Diagnostics.CodeAnalysis

[<Sealed>]
[<global.System.AttributeUsage(
global.System.AttributeTargets.Assembly |||
global.System.AttributeTargets.Class |||
global.System.AttributeTargets.Struct |||
global.System.AttributeTargets.Constructor |||
global.System.AttributeTargets.Method |||
global.System.AttributeTargets.Property |||
global.System.AttributeTargets.Event,
Inherited = false, AllowMultiple = false)>]
type ExcludeFromCodeCoverageAttribute() = inherit global.System.Attribute()
#endif

namespace global

[<AbstractClass; Sealed>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
' </auto-generated>
'------------------------------------------------------------------------------

#If NET20 OrElse NET35 OrElse NETCOREAPP1_0 OrElse NETCOREAPP1_1 OrElse NETSTANDARD1_0 OrElse NETSTANDARD1_1 OrElse NETSTANDARD1_2 OrElse NETSTANDARD1_3 OrElse NETSTANDARD1_4 OrElse NETSTANDARD1_5 OrElse NETSTANDARD1_6 Then
Namespace Global.System.Diagnostics.CodeAnalysis
<Global.System.AttributeUsage(
Global.System.AttributeTargets.Assembly Or
Global.System.AttributeTargets.Class Or
Global.System.AttributeTargets.Struct Or
Global.System.AttributeTargets.Constructor Or
Global.System.AttributeTargets.Method Or
Global.System.AttributeTargets.Property Or
Global.System.AttributeTargets.Event, Inherited:=False, AllowMultiple:=False)>
Friend NotInheritable Class ExcludeFromCodeCoverageAttribute
Inherits Global.System.Attribute
End Class
End Namespace
#End If

Namespace Global

<Global.System.Runtime.CompilerServices.CompilerGenerated()>
Expand Down