Skip to content

Add ToMarkdown method to SarifResults for markdown export#5

Merged
Malcolmnixon merged 2 commits intomainfrom
copilot/export-sarifreports-to-markdown
Jan 23, 2026
Merged

Add ToMarkdown method to SarifResults for markdown export#5
Malcolmnixon merged 2 commits intomainfrom
copilot/export-sarifreports-to-markdown

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 23, 2026

Pull Request

Description

Adds ToMarkdown(int depth) method to SarifResults record for exporting SARIF analysis results as formatted markdown. Implementation follows SonarMark report format adapted for SARIF data structures.

Key additions:

  • ToMarkdown(int depth) - converts results to markdown with configurable heading depth (1-6)
  • Helper methods for formatting location info and pluralization
  • Handles missing location data gracefully (shows "(no location)" when URI is null)

Usage:

var results = SarifResults.Read("analysis.sarif");
var markdown = results.ToMarkdown(1);  // depth 1 = top-level heading (#)
Console.WriteLine(markdown);

Output format:

# ToolName Version Analysis

## Results

Found 3 results

src/Class.cs(42): warning [CA1001] Message text
src/File.cs(15): error [CA2000] Another message
(no location): note [RULE001] Message without location

Type of Change

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

Related Issues

Issue linking handled by system

Pre-Submission Checklist

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

  • 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

Added 9 comprehensive unit tests covering depth variations, edge cases (no results, single result), error handling for invalid depth values, and location formatting scenarios. All 36 tests pass with zero warnings. CodeQL security scan passed with no alerts.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature]: Export SarifReports to Markdown</issue_title>
<issue_description>### Problem Statement

A SarifReports record needs a method to export a report as Markdown.

Proposed Solution

Review the Report Format of https://github.com/demaconsulting/SonarMark and write a string SarifReports.ToMarkdown(int depth) method following the format, but modified to account for the available SARIF data.

Alternatives Considered

No response

Usage Examples

Benefits

Required to implement the tool.

Priority

High - Blocking my use case

Willingness to Contribute

Yes, I can submit a pull request

Additional Context

No response

Checklist

  • I have searched existing issues to ensure this is not a duplicate
  • I have provided a clear description of the feature
  • I have explained why this feature would be useful</issue_description>

Comments on the Issue (you are @copilot in this section)

Custom agent used: Documentation Writer
Expert agent for creating, updating, and maintaining project documentation including README, guides, and API documentation


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
@Malcolmnixon Malcolmnixon marked this pull request as ready for review January 23, 2026 12:55
Copilot AI changed the title [WIP] Add method to export SarifReports as Markdown Add ToMarkdown method to SarifResults for markdown export Jan 23, 2026
Copilot AI requested a review from Malcolmnixon January 23, 2026 12:57
@Malcolmnixon Malcolmnixon merged commit e2db7d1 into main Jan 23, 2026
3 checks passed
@Malcolmnixon Malcolmnixon deleted the copilot/export-sarifreports-to-markdown branch January 23, 2026 12:57
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.

[Feature]: Export SarifReports to Markdown

2 participants