Skip to content

Add POWERKIT_INCLUDE_COVERAGE compiler variable#30

Merged
Tyrrrz merged 5 commits intoprimefrom
copilot/add-powerkit-coverage-variable
Apr 14, 2026
Merged

Add POWERKIT_INCLUDE_COVERAGE compiler variable#30
Tyrrrz merged 5 commits intoprimefrom
copilot/add-powerkit-coverage-variable

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

Adds opt-in coverage collection via POWERKIT_INCLUDE_COVERAGE. By default (symbol unset), all PowerKit APIs are annotated with [ExcludeFromCodeCoverage], so consumers don't pollute their coverage reports. Defining the symbol removes the attribute.

Changes

  • All 39 source files: #if !POWERKIT_INCLUDE_COVERAGE / [ExcludeFromCodeCoverage] / #endif guard added before every type declaration (including file-scoped helpers and all classes in multi-type files)
  • PowerKit.Tests/PowerKit.Tests.csproj: Defines POWERKIT_INCLUDE_COVERAGE so tests measure actual coverage of the APIs

Usage

<!-- Opt into coverage collection in a consuming project -->
<DefineConstants>$(DefineConstants);POWERKIT_INCLUDE_COVERAGE</DefineConstants>

@Tyrrrz
Copy link
Copy Markdown
Owner

Tyrrrz commented Apr 14, 2026

@copilot resolve the merge conflicts in this pull request

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 14, 2026

@copilot resolve the merge conflicts in this pull request

Done — resolved in 1f4fc68. The 5 conflicting files all had the same pattern (using System.Diagnostics.CodeAnalysis; vs #nullable enable), resolved by keeping both in the correct order (#nullable enable first, then the using). Build and all 136 tests pass.

Copilot AI requested a review from Tyrrrz April 14, 2026 20:15
@Tyrrrz Tyrrrz marked this pull request as ready for review April 14, 2026 20:19
Copilot AI review requested due to automatic review settings April 14, 2026 20:19
Comment on lines +3 to +4
using System.Diagnostics.CodeAnalysis;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Why the spacing? @copilot

Search and correct this error in other files

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in f7953c6. The using System.Diagnostics.CodeAnalysis; was placed out of order with an extra blank line separator instead of being sorted alphabetically among the other usings. Corrected in all four affected files: AsyncEnumerableExtensions.cs, ZipArchiveEntryExtensions.cs, RegistryExtensions.cs, and Cell.cs (which also had a missing blank line before namespace).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an opt-in mechanism (POWERKIT_INCLUDE_COVERAGE) to control whether PowerKit APIs are included in consumer coverage reports by conditionally applying [ExcludeFromCodeCoverage] to all types by default.

Changes:

  • Added #if !POWERKIT_INCLUDE_COVERAGE guarded [ExcludeFromCodeCoverage] before type declarations across PowerKit source files.
  • Added POWERKIT_INCLUDE_COVERAGE to PowerKit.Tests constants so tests collect coverage for PowerKit APIs.

Reviewed changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
PowerKit/Cell.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Disposable.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/LockFile.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/TempDirectory.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/TempFile.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/AggregateExceptionExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/ArrayPoolExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to types in the file.
PowerKit/Extensions/AssemblyExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/AsyncEnumerableExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/BinaryReaderExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/BinaryWriterExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/BoolExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/CollectionExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/ComparableExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/ConsoleExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/CultureInfoExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/DateTimeExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/DateTimeOffsetExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/DecimalExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/DirectoryExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/DoubleExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/EncodingExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to types in the file.
PowerKit/Extensions/EnumerableExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/EnvironmentExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/ExceptionExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/FileExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/FunctionalExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to types in the file.
PowerKit/Extensions/GuidExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/IntExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/LongExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/PathExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to types in the file.
PowerKit/Extensions/ProcessExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/RegistryExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/StreamExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/StringBuilderExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/StringExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/TextReaderExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/TimeSpanExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit/Extensions/ZipArchiveEntryExtensions.cs Conditionally applies [ExcludeFromCodeCoverage] to the type.
PowerKit.Tests/PowerKit.Tests.csproj Defines POWERKIT_INCLUDE_COVERAGE for test/coverage runs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread PowerKit/TempFile.cs
Comment thread PowerKit.Tests/PowerKit.Tests.csproj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants