Skip to content

allow checking formatting with cache#1830

Merged
belav merged 2 commits into
belav:mainfrom
sd-st:faster-check
Mar 22, 2026
Merged

allow checking formatting with cache#1830
belav merged 2 commits into
belav:mainfrom
sd-st:faster-check

Conversation

@sd-st

@sd-st sd-st commented Mar 10, 2026

Copy link
Copy Markdown

Description

I run csharpier check as part of my lint flow, which means I run it a lot. On one of my repositories it takes 200ms to run format and 8000ms to run check. This PR allows for check to use the cache (although it can be disabled, just like for format)

Related Issue

Checklist

  • My code follows the project's code style
    • always var
    • follow existing naming conventions
    • always this.
    • no pointless comments
  • I will not force push after a code review of my PR has started
  • I have added tests that cover my changes

@sd-st

sd-st commented Mar 10, 2026

Copy link
Copy Markdown
Author

I think there's probably nothing to test here; it doesn't look like there were tests for the previous behaviour (and no tests for the CLI arguments in general as far as I can tell)

belav added a commit that referenced this pull request Mar 14, 2026

@belav belav left a comment

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.

My worry with this change is that I had a commit to specifically disable the cache when running check, but I don't recall why I would have made that change and neglected to leave a comment explaining why.

81c36d7

It seems safer to have a new option for the check command --use-cache so that it can default to the current behavior.

@sd-st sd-st requested a review from belav March 16, 2026 13:47
@sd-st

sd-st commented Mar 16, 2026

Copy link
Copy Markdown
Author

I do think it's a little unfortunate to have a different API surface between checking and formatting but I made that change

@belav belav added this to the 1.3.0 milestone Mar 22, 2026

@belav belav left a comment

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.

Thanks for updating. I was thinking that running the check command in a GH action may have had issues with using the cache. That might be why I disabled it for the check command.

@belav belav merged commit b12955b into belav:main Mar 22, 2026
7 checks passed
@sd-st

sd-st commented Mar 23, 2026

Copy link
Copy Markdown
Author

Thanks! I'm planning to try it out in CI so I'll report back if there are any issues.

ptr727-codegen Bot pushed a commit to ptr727/LanguageTags that referenced this pull request Jun 8, 2026
Updated [csharpier](https://github.com/belav/csharpier) from 1.2.6 to
1.3.0.

<details>
<summary>Release notes</summary>

_Sourced from [csharpier's
releases](https://github.com/belav/csharpier/releases)._

## 1.3.0

# 1.3.0
## Breaking Changes
### Change xml formatting to return error when it runs into syntax error
so it is consistent with c#
[#​1854](belav/csharpier#1854)
Previously CSharpier treated an invalid xml file as a warning instead of
an error. This was inconsistent with how it treated c# files.
Invalid c# or xml files are not treated as errors.  
The `--compilation-errors-as-warnings` argument has been renamed to
`--syntax-errors-as-warnings` and can be used to return warnings instead
of errors when encountering invalid files.

## What's Changed

### Feature: Configurable whitespace handling for xml
[#​1790](belav/csharpier#1790)
CSharpier now supports two types of xml whitespace formatting strict or
ignore.
By default all xml except `xaml` or `axaml` is treated as strict
whitespace. See
[details](https://csharpier.com/docs/Configuration#xml-whitespace-sensitivity)

### Feature: Move closing bracket for xml elements to the same line.
[#​1598](belav/csharpier#1598)
With strict xml whitespace handling, csharpier now keeps the closing
bracket for an element on the same line instead of breaking it to a new
line.
```xml
<!-- input & expected output -->
<ElementWithAttribute Attribute="AttributeValue__________________"
  >TextValue</ElementWithAttribute>

<!-- 1.2.6 -->
<ElementWithAttribute Attribute="AttributeValue__________________"
  >TextValue</ElementWithAttribute
>
```
### Feature: Support for csharpier-ignore with XML formatter
[#​1788](belav/csharpier#1788)
CSharpier now supports `csharpier-ignore` in xml files. See
[details](https://csharpier.com/docs/Ignore#xml)

### Feature: Add MSBuild transitive and multi-target support
[#​1833](belav/csharpier#1833)
CSharpier.MSBuild can now work as a transitive dependency.

### Feature: allow checking formatting with cache
[#​1830](belav/csharpier#1830)
The `csharpier check` command now supports a `--use-cache` option.

### Feature: remove dependency on Microsoft.AspNetCore.App
[#​1508](belav/csharpier#1508)
Previously CSharpier required that Microsoft.AspNetCore.App be
installed. CSharpier has been modified to use an HttpListener when it is
run using `server` to remove the need for this dependency.

### Fix: csharpier-ignore comment removes linespaces before block
[#​1867](belav/csharpier#1867)
CSharpier was removing blank lines before csharpier-ignore comments in
some cases
```c#
// input and expected output
var x = 1;
    
// csharpier-ignore
var y=1;

/// 1.2.6
var x = 1;
// csharpier-ignore
var y=1;
 ... (truncated)

Commits viewable in [compare view](belav/csharpier@1.2.6...1.3.0).
</details>

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=csharpier&package-manager=nuget&previous-version=1.2.6&new-version=1.3.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will remove the ignore condition of the specified dependency and ignore conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Jun 8, 2026
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