Skip to content

ci: move from dotnet-format tool to .NET SDK command#4918

Merged
jamescrosswell merged 14 commits intomainfrom
ci/replace-nuget-dotnet-format
Mar 5, 2026
Merged

ci: move from dotnet-format tool to .NET SDK command#4918
jamescrosswell merged 14 commits intomainfrom
ci/replace-nuget-dotnet-format

Conversation

@Flash0ver
Copy link
Member

@Flash0ver Flash0ver commented Feb 12, 2026

Summary

  • Remove dotnet-format global tool as it is now included in the .NET SDK
  • Additionally, upload a --report, similar to build logs and test results
  • Merge all three --exclude Options into a single space-separated list

Remarks

dotnet-format has been marked deprecated on NuGet.org.
It is included as a CLI command since the the .NET 6.0 SDK.

dotnet format supports a --report option, that this changeset is uploading as a non-zipped artifact (see #4966).

Unfortunately, this does not fix the automatic removal of an Assertion (see #4911).
--exclude ./test/Sentry.Tests/AttributeReaderTests.cs is still required ... this may be a bug in a Diagnostic-Analyzer if xUnit.net and it's associated Code-Fix-Provider.

This PR also merges all three --exclude options in to a single space-separated list ... see dotnet format.

@Flash0ver Flash0ver self-assigned this Feb 12, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Features ✨

  • feat: Network calls for Session Replay on Android by jamescrosswell in #4860

Fixes 🐛

  • fix: Log Warning instead of Error when ratelimited by bitsandfoxes in #4927

Dependencies ⬆️

Deps

  • chore(deps): update Native SDK to v0.13.1 by github-actions in #4964
  • chore(deps): update Cocoa SDK to v9.5.0 by github-actions in #4944
  • chore(deps): update Native SDK to v0.13.0 by github-actions in #4941
  • chore(deps): update CLI to v3.2.2 by github-actions in #4943
  • chore(deps): update Java SDK to v8.33.0 by github-actions in #4933
  • chore(deps): update CLI to v3.2.0 by github-actions in #4805
    • NOTE: Sentry CLI v3 removed support for the legacy API key authentication method. Sentry CLI now only supports authenticating with Auth Tokens. If you are using API key authentication via SentryApiKey, you need to generate an Auth Token and use SentryAuthToken, instead.
  • chore(deps): update Cocoa SDK to v9.4.1 by github-actions in #4928
  • chore(deps): update Native SDK to v0.12.8 by github-actions in #4929
  • Apps built using the Sentry SDK for .NET must now target iOS version 15 or higher. Previously only version 13 or higher was required. (#4781) by github-actions in #4781
  • Bump Cocoa SDK from v8.57.3 to v9.2.0 (#4781) by github-actions in #4781
  • chore(deps): update Native SDK to v0.12.7 by github-actions in #4920

Other

  • ci: move from dotnet-format tool to .NET SDK command by Flash0ver in #4918
  • test(blazor): Add Playwright E2E tests for navigation breadcrumbs by bruno-garcia in #4908
  • test(android): Use volatile to produce SIGSEGV in native crash test by jpnurmi in #4919

🤖 This preview updates automatically when you update the PR.

@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.90%. Comparing base (2079493) to head (bd6cf08).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4918      +/-   ##
==========================================
+ Coverage   73.86%   73.90%   +0.03%     
==========================================
  Files         496      496              
  Lines       17951    17951              
  Branches     3516     3516              
==========================================
+ Hits        13259    13266       +7     
+ Misses       3833     3824       -9     
- Partials      859      861       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Flash0ver and others added 13 commits February 13, 2026 12:02
The exclusion was added as a workaround because dotnet-format was
incorrectly deleting assertions in that file. This issue has since
been resolved so the exclusion is no longer necessary.

Co-Authored-By: Claude <noreply@anthropic.com>
This reverts commit bba983f.
Generate a dotnet format report via --report and upload it as a CI
artifact so formatting issues can be inspected without re-running the
job locally.

Refs #4918
Co-Authored-By: Claude <noreply@anthropic.com>
Refs #4918
Co-Authored-By: Claude <noreply@anthropic.com>
Refs #4918
Co-Authored-By: Claude <noreply@anthropic.com>
Write a .gitignore into the report directory after uploading the
artifact so the generated JSON report is not picked up as a git
change by the subsequent commit step.

Refs #4918
Co-Authored-By: Claude <noreply@anthropic.com>
Avoid unconditionally creating the report directory — only write the
.gitignore when dotnet format actually produced the directory.

Refs #4918
Co-Authored-By: Claude <noreply@anthropic.com>
Comment on lines +40 to +47
- name: Upload Format Report
if: ${{ always() }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
archive: false
path: ./dotnet-format-report/
if-no-files-found: ignore

Copy link
Member Author

@Flash0ver Flash0ver Mar 4, 2026

Choose a reason for hiding this comment

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

note: see e.g. https://github.com/getsentry/sentry-dotnet/actions/runs/22679547094?pr=4918

I do like the unzipped upload for single files, so that in this case I can view the .json file directly in the browser.

Comment on lines +48 to 53
- name: Exclude Format Report from Git
run: |
if [ -d ./dotnet-format-report ]; then
echo '*' > ./dotnet-format-report/.gitignore
fi

Copy link
Member Author

Choose a reason for hiding this comment

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

note: so that the Commit Formatted Code step does not consider the generated report as a change

@Flash0ver Flash0ver marked this pull request as ready for review March 4, 2026 20:54
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Upload failure blocks formatted code commit step
    • Added continue-on-error: true to the Upload Format Report step so artifact upload failures no longer block subsequent git exclusion and commit steps.

Create PR

Or push these changes by commenting:

@cursor push ba42615ad8
Preview (ba42615ad8)
diff --git a/.github/workflows/format-code.yml b/.github/workflows/format-code.yml
--- a/.github/workflows/format-code.yml
+++ b/.github/workflows/format-code.yml
@@ -39,6 +39,7 @@
 
       - name: Upload Format Report
         if: ${{ always() }}
+        continue-on-error: true
         uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
         with:
           archive: false
This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

with:
archive: false
path: ./dotnet-format-report/
if-no-files-found: ignore
Copy link

Choose a reason for hiding this comment

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

Upload failure blocks formatted code commit step

Medium Severity

The Upload Format Report step uses if: always() but lacks continue-on-error: true. If this step fails (e.g., network issue, or archive: false rejecting multiple files from the report directory), the GitHub Actions success() check becomes false, preventing both Exclude Format Report from Git and Commit Formatted Code from running. This silently discards any formatting changes that dotnet format applied. Adding continue-on-error: true to the upload step would prevent an informational artifact upload from blocking the core commit functionality.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

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

my intention was that CI should fail if anything goes unexpected ... starting out more aggressive ... we can always loosen strictness later

Copy link
Collaborator

@jamescrosswell jamescrosswell left a comment

Choose a reason for hiding this comment

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

lgtm

@jamescrosswell jamescrosswell merged commit 6cda3b5 into main Mar 5, 2026
34 checks passed
@jamescrosswell jamescrosswell deleted the ci/replace-nuget-dotnet-format branch March 5, 2026 02:13
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.

3 participants