Skip to content

Fix CodeQL warnings: Replace manual disposal with using declarations#57

Merged
Malcolmnixon merged 2 commits intomainfrom
copilot/fix-missed-using-statements
Feb 8, 2026
Merged

Fix CodeQL warnings: Replace manual disposal with using declarations#57
Malcolmnixon merged 2 commits intomainfrom
copilot/fix-missed-using-statements

Conversation

Copy link
Contributor

Copilot AI commented Feb 8, 2026

Pull Request

Description

Resolves 6 CodeQL cs/missed-using-statement warnings in ValidationTests.cs. Replaced manual StringWriter disposal in finally blocks with using declarations.

Before:

StringWriter? outputWriter = null;
try
{
    outputWriter = new StringWriter();
    // ... use outputWriter
}
finally
{
    outputWriter?.Dispose();
}

After:

using var outputWriter = new StringWriter();
try
{
    // ... use outputWriter
}
finally
{
    // automatic disposal at scope end
}

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code quality improvement

Related Issues

CodeQL analysis warnings in test suite.

Pre-Submission Checklist

Before submitting this pull request, ensure you have completed the following:

Build and Test

  • Code builds successfully: dotnet build --configuration Release
  • All tests pass: dotnet test --configuration Release
  • Code produces zero warnings

Code Quality

  • Code formatting is correct: dotnet format --verify-no-changes
  • New code has appropriate XML documentation comments
  • Static analyzer warnings have been addressed

Quality Checks

Please run the following checks before submitting:

  • Spell checker passes: cspell "**/*.{md,cs}"
  • Markdown linter passes: markdownlint "**/*.md"
  • YAML linter passes: yamllint '**/*.{yml,yaml}'

Testing

  • Added unit tests for new functionality
  • Updated existing tests if behavior changed
  • All tests follow the AAA (Arrange, Act, Assert) pattern
  • Test coverage is maintained or improved

Documentation

  • Updated README.md (if applicable)
  • Updated ARCHITECTURE.md (if applicable)
  • Added code examples for new features (if applicable)
  • Updated requirements.yaml (if applicable)

Additional Notes

Changes affect 4 test methods:

  • Validation_Run_WithTrxResultsFile_WritesTrxFile
  • Validation_Run_WithXmlResultsFile_WritesJUnitFile
  • Validation_Run_WithUnsupportedResultsFileExtension_ShowsError
  • Validation_Run_WithInvalidResultsFilePath_ShowsError

Net reduction: 16 lines removed. CodeQL alerts: 6 → 0.

Original prompt

Please fix the following CodeQL issues:

test/DemaConsulting.BuildMark.Tests/ValidationTests.cs(46): warning [cs/missed-using-statement] This variable is manually [disposed](1) in a [finally block](2) - consider a C# using statement as a preferable resource management technique.  
test/DemaConsulting.BuildMark.Tests/ValidationTests.cs(47): warning [cs/missed-using-statement] This variable is manually [disposed](1) in a [finally block](2) - consider a C# using statement as a preferable resource management technique.  
test/DemaConsulting.BuildMark.Tests/ValidationTests.cs(106): warning [cs/missed-using-statement] This variable is manually [disposed](1) in a [finally block](2) - consider a C# using statement as a preferable resource management technique.  
test/DemaConsulting.BuildMark.Tests/ValidationTests.cs(107): warning [cs/missed-using-statement] This variable is manually [disposed](1) in a [finally block](2) - consider a C# using statement as a preferable resource management technique.  
test/DemaConsulting.BuildMark.Tests/ValidationTests.cs(166): warning [cs/missed-using-statement] This variable is manually [disposed](1) in a [finally block](2) - consider a C# using statement as a preferable resource management technique.  
test/DemaConsulting.BuildMark.Tests/ValidationTests.cs(211): warning [cs/missed-using-statement] This variable is manually [disposed](1) in a [finally block](2) - consider a C# using statement as a preferable resource management technique.  

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…sposal

Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix missed using statements in ValidationTests Fix CodeQL warnings: Replace manual disposal with using declarations Feb 8, 2026
Copilot AI requested a review from Malcolmnixon February 8, 2026 13:46
@Malcolmnixon Malcolmnixon marked this pull request as ready for review February 8, 2026 13:46
@Malcolmnixon Malcolmnixon merged commit 376eaa9 into main Feb 8, 2026
11 checks passed
@Malcolmnixon Malcolmnixon deleted the copilot/fix-missed-using-statements branch February 8, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants