Skip to content

dotnet format throws because it can't determine file encodings in 9.0.200 #46780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DavidZidar opened this issue Feb 12, 2025 · 30 comments · Fixed by dotnet/roslyn#77354
Closed
Assignees

Comments

@DavidZidar
Copy link

DavidZidar commented Feb 12, 2025

Describe the bug

It is no longer possible to use dotnet format without arguments to format code in certain projects because it has started throwing an error in 9.0.200. dotnet format --verify-no-changes does still work however.

What's worse, it doesn't specify what file might be the issue so it is very hard to figure out what might be going wrong.

To Reproduce

I'm not exactly sure since it doesn't tell me what file it has a problem with, but I'm just running dotnet format in an ASP.NET Core 9 project with about 1500 C# files.

Exceptions (if any)

Unhandled exception: System.Exception: source text did not have an identifiable encoding
   at Microsoft.CodeAnalysis.Tools.Formatters.CharsetFormatter.IsEncodingEquivalent(SourceText sourceText, Encoding encoding)
   at Microsoft.CodeAnalysis.Tools.Formatters.CharsetFormatter.<>c__DisplayClass10_0.<FormatFileAsync>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.Tools.Formatters.DocumentFormatter.GetFormattedSourceTextAsync(Document document, OptionSet optionSet, AnalyzerConfigOptions analyzerConfigOptions, FormatOptions formatOptions, ILogger logger, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.Formatters.DocumentFormatter.<>c__DisplayClass8_1.<<FormatFiles>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.Tools.Formatters.DocumentFormatter.ApplyFileChangesAsync(Solution solution, ImmutableArray`1 formattedDocuments, FormatOptions formatOptions, ILogger logger, List`1 formattedFiles, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.Formatters.DocumentFormatter.FormatAsync(Workspace workspace, Solution solution, ImmutableArray`1 formattableDocuments, FormatOptions formatOptions, ILogger logger, List`1 formattedFiles, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.CodeFormatter.RunCodeFormattersAsync(Workspace workspace, Solution solution, ImmutableArray`1 formattableDocuments, FormatOptions formatOptions, ILogger logger, List`1 formattedFiles, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.CodeFormatter.FormatWorkspaceAsync(FormatOptions formatOptions, ILogger logger, CancellationToken cancellationToken, String binaryLogPath)
   at Microsoft.CodeAnalysis.Tools.FormatCommandCommon.FormatAsync(FormatOptions formatOptions, ILogger`1 logger, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.Commands.RootFormatCommand.FormatCommandDefaultHandler.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)
   at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)

Further technical details

The error started showing up after installing Visual Studio 17.3, but it is also happening in WSL2 with the latest .NET SDK.

@ghost ghost added Area-NetSDK untriaged Request triage from a team member labels Feb 12, 2025
@DavidZidar
Copy link
Author

I did try running dotnet format --verbosity diag but did not receive any additional actionable information.

@adam-knights
Copy link

Incase its useful in fixing this, we see similar today having taken 9.0.200, but on Windows only, our Mac arm64 users do not see the errors. May not apply to all cases, but if someone is looking at this and can't reproduce, try Windows.

@caleblloyd
Copy link

caleblloyd commented Feb 12, 2025

I am hitting this on linux after the 9.0.200 upgrade today. Same deal, --verbosity diag doesn't show any other useful information. Reverting to 9.0.103 fixes.

@ChrisTTian667
Copy link

Incase its useful in fixing this, we see similar today having taken 9.0.200, but on Windows only, our Mac arm64 users do not see the errors. May not apply to all cases, but if someone is looking at this and can't reproduce, try Windows.

I'm a Mac ARM 64 User and have the same issue. I don't think that its related to the platform.

@MattEdwardsWaggleBee
Copy link

MattEdwardsWaggleBee commented Feb 14, 2025

I'm seeing this on my Windows 11 machine and my GitHub action running on "ubuntu-latest"

update: I'm on 9.0.200 co-worker doesn't see this on 9.0.103

@swharden
Copy link

Thanks for opening this issue and following-up with your suggestions!

I'm here to report I fixed this by locking the dotnet version to 9.0.103 too, as shown in ScottPlot/ScottPlot@57c9b02

@david-driscoll
Copy link
Contributor

I'm also hitting this as well on a mac m4.

@Kiruyuto
Copy link

This happened to me today, Win11 and .NET 9.0.200.
In my case, it was related to the fact that some files had UTF-8-BOM encoding which they should not (Per .editorconfig). Running dotnet format --severity info -v diag --verify-no-changes to locate them and then removing it via Rider fixed the usual dotnet format.

@arunchndr arunchndr removed the untriaged Request triage from a team member label Feb 18, 2025
@WernerMairl
Copy link

Same here!
Please fix this asap, it breaks some working projects/builds!

@zce
Copy link

zce commented Feb 20, 2025

When I moved the charset option to the root node, the issue was solved:

root = true
charset = utf-8

[*]
end_of_line = lf
insert_final_newline = true

# ...

@just-jim
Copy link

just-jim commented Feb 20, 2025

Are you sure? Rider says that you are not allowed to have multiple declaration in the top level

Image

@redbit86k
Copy link

Rider shows this error/warning but i can confirm, with this dotnet format runs without the error.
I can't say if its correct or good to have the charset in the editorconfig at the root level but it is a workaround at the moment.
I didn't notice any side effects besides the warning so far 🤞

@DavidZidar
Copy link
Author

The charset trick didn't work on my machine unfortunately, and neither did checking for files with unnecessary BOM-headers. I re-wrote all C#-files to disk without BOM to make sure.

@just-jim
Copy link

Until this is fixed, I will force my project to run on 9.0.100. To do so go to the root of your project and run:
dotnet new globaljson --sdk-version 9.0.100
(make sure you have 9.0.100 installed. Check the installed versions by: dotnet --list-sdks)
dotnet format works normally in version 9.0.100.

@WernerMairl
Copy link

Running dotnet format --severity info -v diag --verify-no-changes to locate them and then removing it

this helped me a lot: basically i had a single file somewhere in between that had a unexpected BOM ( "UTF8+BOM" instead of "UTF8")

If the Exception can be avoided : nice!!
If not, then i suggest to provide better exception message that avoids the extra step with dotnet format --severity info -v diag --verify-no-changes

the first class exception should

  • contain the path/filename of the involved file
  • show the expected encoding and the existing encoding!

Side note: Visual Studio is not showing the BOM status currently, i had to use VS-Code for deeper analysis.

BR Werner

@caleblloyd
Copy link

caleblloyd commented Feb 21, 2025

Here is a bash script to remove BOM from git tracked text files - tested on Linux but may work fine on macOS or WSL also:

# Process all tracked files
while read -r file; do
    # Check if file is binary using git-diff
    if ! git diff --no-index --numstat /dev/null "$file" | grep -q "^-"; then
        # Check if file has BOM
        if head -c3 "$file" | grep -q $'\xEF\xBB\xBF'; then
            echo "Removing BOM from: $file"
            sed -i '1s/^\xEF\xBB\xBF//' "$file"
        fi
    fi
done < <(git ls-files)

dotnet format seems to be working for me again after running this.

@cfbao
Copy link

cfbao commented Feb 21, 2025

Just to clarify - removing BOM doesn't fix real the problem.

If dotnet format (in 9.0.200) catches any formatting problem (BOM is just one of them), it will fail to auto format the files.

kohanyirobert added a commit to kohanyirobert/DisplayDetective that referenced this issue Feb 22, 2025
I bumped into an issue with dotnet format.
See: dotnet/sdk#46780
@sharwell
Copy link
Contributor

@mattmc3 Thank you that is exactly what I needed

sharwell added a commit to dotnet/roslyn that referenced this issue Feb 27, 2025
Fixes dotnet/sdk#46780

This issue was introduced by #74623, which changed
`Document.WithSyntaxRoot` to always use the encoding specified by the
new syntax root. APIs like SyntaxRewriter do not preserve the input
encoding during node rewrites, so `Formatter.Format` would overwrite the
document syntax root with a node that did not specify any encoding. The
fix _allows_ `WithSyntaxRoot` to specify a new encoding, but for cases
where the encoding of the new syntax root is not known, we fall back to
the original behavior of preserving the encoding from the previous root
and/or document text.
github-actions bot pushed a commit to dotnet/roslyn that referenced this issue Feb 27, 2025
github-actions bot pushed a commit to dotnet/roslyn that referenced this issue Feb 27, 2025
jakubfijalkowski added a commit to leancodepl/exampleapp that referenced this issue Feb 27, 2025
333fred added a commit to dotnet/roslyn that referenced this issue Mar 11, 2025
* Parse partial events and constructors (#76860)

* Parse partial events and constructors

* Update pre-existing tests

* Explain why partial ctors are sometimes disallowed

* Parse `partial` constructors unconditionally

* Gate parsing on LangVersion

* Extend tests and docs

* Fix indentation

* Rename combinatorial values

* Test more lang versions

* Parse partial events unconditionally

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20250203.2

Microsoft.SourceBuild.Intermediate.source-build-reference-packages
 From Version 10.0.607901 -> To Version 10.0.610302

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20250204.2

Microsoft.SourceBuild.Intermediate.source-build-reference-packages
 From Version 10.0.607901 -> To Version 10.0.610402

* Partial events and constructors: merge and check symbols (#76970)

* Partial events and constructors: merge and check symbols

* Improve code

* Move partial availability check

* Improve code

* Fix duplicate definition diagnostic

* Test different ordering

* Avoid reporting diagnostic for escaped `partial`

* Clarify naming of AccessorsHaveImplementation property

* Add event definition accessor symbol

* Improve code

* Test sequence points

* Test extern IL

* Fix interface container diagnostics

* Fix sequence points issue in the test utility

* Ensure the new accessor owner is a definition

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20250210.2

Microsoft.SourceBuild.Intermediate.source-build-reference-packages
 From Version 10.0.607901 -> To Version 10.0.611002

* Remove async/await

* Update dependencies from https://github.com/dotnet/arcade build 20250211.5

Microsoft.SourceBuild.Intermediate.arcade , Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.Helix.Sdk , Microsoft.DotNet.XliffTasks
 From Version 9.0.0-beta.25077.4 -> To Version 9.0.0-beta.25111.5

* Partial events and constructors: check differences (#77118)

* Partial events and constructors: check differences

* Improve code and tests

* Complete constructor implementation part

* Report error for tuple differences in constructors

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20250212.3

Microsoft.SourceBuild.Intermediate.source-build-reference-packages
 From Version 10.0.608004 -> To Version 10.0.611203

* Add test for override completion error

* Fix override completion when attribute below

* Partial events and constructors: doc comments (#77200)

* Ensure generated operator methods have the format annotation

* Update VB tests to assert new formatting behavior

* Use raw strings in override tests

* Ensure diagnostics refresh when source generators run in balanced mode

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20250218.1

Microsoft.SourceBuild.Intermediate.source-build-reference-packages
 From Version 10.0.608004 -> To Version 10.0.611801

* Create missing options types

* Fix Quick Info nullability display for backing fields (#77240)

Co-authored-by: Cyrus Najmabadi <[email protected]>

* Mix the source generator version info into the dependent checksum we get for projects

* Make diagnostic checksum an extension

* Move

* simplify

* Fix crash in 'introduce variable' when converting an object creation expression to an implicit object creation expression

* Enable NRT

* Update src/Tools/SemanticSearch/ReferenceAssemblies/Apis/Microsoft.CodeAnalysis.CSharp.txt

* Partial events and constructors: attributes (#77182)

* Partial events and constructors: attributes

* Update pre-existing tests

* Fixup expected PEVerify output

* Check a flag before materializing syntax nodes

* Assert that the definition part of an event doesn't have accessors

* Keep pre-existing event attribute target behavior

* Improve code

* Add WorkItem attribute

* Strengthen asserts

Co-authored-by: Rikki Gibson <[email protected]>

---------

Co-authored-by: Rikki Gibson <[email protected]>

* Use proj dependent checksum instead now that it contains SG info

* disable realtime monitoring

* Update debugger contracts to fix hot reload issue

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20250219.1

Microsoft.SourceBuild.Intermediate.source-build-reference-packages
 From Version 10.0.608004 -> To Version 10.0.611901

* Return stronger-ly typed results from completion

* Forgot to change the file header when copying the file contents

* One level deep

* Add test

* Add an option to ignore aliases when moving using directives outside a namespace

* Add test

* Add work items

* Update runtime async spec (#76872)

* Update runtime async spec

Updates from the runtime side: dotnet/runtime#110420.

* Update method signature

* Add note about blocking

* Fill in more examples

* Remove outdated paragraph

* A bit of reorganization for clarity

* Collapse a number of samples to expandable section

* Fix heading

* Remove out of support branches from PublishData.json

* Switch TextDocumentState.GetTextVersionAsync to ValueTask to reduce allocations. (#77213)

The task creation from calling this method accounts for 36 MB (0.2%) of allocations in the CSharpEditingTests.Completion speedometer test. Speedometer results with this change show marked improvement in these allocations.

* Fix

* Update PublicAPI files for 17.13 ship (#77266) (#77295)

(cherry picked from commit f8f04dd)

* Expand doc comment

* Update azure-pipelines-official.yml

* Don't use hardcoded line endings (#77296)

Was causing these files to change every build on linux.

* Allow Semantic Search query function to take symbol parameter (#77272)

Fix

* Update to release nuget packages (#77261) (#77298)

* Update to release nuget packages

In order to publish 17.13 nuget packages, we need to update a few dependencies. I updated the minimum number of packages required from our public packages, then fixed up any restore issues. For each updated package, I then went and confirmed that the dll was actually present in 17.13.0, so we should be safe from dependency loading issues. This change does not need to be inserted into VS.

* Skip tests for microsoft/vs-solutionpersistence#95

* Skip failing tests, see #77293.

(cherry picked from commit 3350036)

* Generate Documentation Auto-Insert (#76665)

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* remove some commented out code

* still cleaning up

* revert file

* clean up + option

* wip

* dispose of disable of intellicode line completions

* comments

* comments

* add quota exceeded checks

* fix tests

* revert file

* remove unused optional params

* last few fixes

* feedback

* fix tests

* small fix

* fix

* feedback

* feedback

* removed per comments

* remove unused usings

* feedback

* feedback

* move stuff around with new EA structure in roslyn

* wip

* feedback

* feedbacl

* fix

* feedback

* feedback

* feedback

* revert

* remove null check

* clean up

* fix

* fix tests

* last fixes

* telemetry + fixes

* last comments

* Move check to 'make field readonly'

* Add test

* Update src/Tools/SemanticSearch/ReferenceAssemblies/Apis/Microsoft.CodeAnalysis.CSharp.txt

* Partial events and constructors: more tests (#77280)

* Add Copilot UI prototype to Semantic Search window (#77222)

* disable the WPF ComboBox Search behavior in Rename popup

* Change override completion to select text after updating the buffer. (#76983)

* Change override completion to select text after updating the buffer.

This (along with #76969) will allow a user to commit an override completion and easily replace the default text (and still use the expression body fixers).

This required the CompletionChange class to now allow the data to represent a selection instead of just a cursor position.

* Explictly jump off the main thread before serializing data to call Razor

* Reduce allocations during completion in FilterToVisibleAndBrowsableSymbols (#77315)

* Reduce allocations during completion in FilterToVisibleAndBrowsableSymbols

This method was visible in allocations in one of the completion speedometer profiles I was looking at and has a couple of easily removable allocations.

Can combine two WhereAsArray calls
Can switch to using WhereAsArray(ImmutableAray) instead of the IEnumerable overload
Can use the pooling support in MetadataUnifyingSymbolHashSet
Can avoid EditorBrowsableInfo allocation when input symbols is empty
Can avoid the closure allocation that was present in RemoveOverriddenSymbolsWithinSet
Even with all these changes, the net benefit didn't prove large from the speedometer run, but I've done the work, it doesn't complicate things, and every bit helps.

* Fix typos (#77316)

* Refresh diagnostics when fading options change

* Mix options into diagnostic data checksum

* Apply suggestions from code review

* Support 'view call hierarchy' on primary consstructor

* Fix

* Arrays

* cleanup tests

* Add test

* Docs

* NRT

* Primary constructor

* Add nuget to documentation (#77330)

* Implement TypeScript ExternalAccess wrappers for AsynchronousOperationListener (#77318)

* Update configs for 17.14 P2 snap (#77329)

* wip

* update configs for 17.14p2 snap

* Update eng/config/PublishData.json

Co-authored-by: Joey Robichaud <[email protected]>

---------

Co-authored-by: Joey Robichaud <[email protected]>

* Simplify

* Disallow initializers on partial constructor definitions (#77275)

* Partial events and constructors: public API (#77202)

* Partial events and constructors: public API

* Simplify code

* Add more `sealed`

* Add more asserts

* Null annotate MetadataHelpers (#77309)

* Null annotate MetadataHelpers

Issue #76394 indicites there is a null reference happening inside
`MetadataHelpers.GetInfoForImmediateNamespaceMembers`. The symptoms
indicate it's non-deterministic (deterministic ordering or race
condition).

Decided to null annotate the type and a few surrounding calls to see if
I could get lucky and spot the source of the NRE. Was not able to do
this but decided to submit the annotations.

* more

* more

* pr feedback

* pr feedback

* Allow expression body refactorings on non empty selections (#76969)

Currently, all expression/body refactorings only work with an empty selection. I've started looking into #29495 which requests overload completion to set the selection upon commit. Upon commit (and setting the selection), it's desirable to be able to do the expression/body refactoring. This change should allow that.

* PERF: Reduce the number of nodes walked during import completion commit. (#77305)

ImportAdderService.AddImportsAsync was previously doing a full tree walk (and realizing all the nodes in the tree) during override completion commit.

Noticed while looking at the csharp completion speedometer profile for the completion commit of override methods. Previously, this accounted for about 28% of CPU and 23% of allocations during CommitManager.TryCommit. With these changes applied, this enumeration is basically free.

See PR for details on the performance numbers

* Handle ModuleCancellationTokenExpression in AbstractFlow visitor (#77310)

* Fix issue in watch window completion (#77204)

* Fix issue in watch window completion

The issue here is when the watch window contains

for (int i = 0; i < 10; i++)
    [Console.WriteLine(i);]

where [] denotes the current statement. In that case, the adjusted context should be at the start of Console.WriteLine. Additionally, a semicolon should not be placed in the generated projection buffer before debuggerMappedSpan, as that would place debuggerMappedSpan outside the for loop.

Fixes #42718

* Don't realize the SourceText in SyntaxTree.OverlapsHiddenPosition if not needed (#77334)

This shows up in override completion commit in the speedometer profiles as 12.5% of allocations and 11.6% of CPU under CommitManager.TryCommit. We can avoid needing the SourceText in this method if the line mappings in the tree are empty. With this change, OverlapsHiddenRegion no longer appears in either allocations or cpu usage during override completion commit. I've also verified that these costs associated with creating this sourcetext weren't incurred elsewhere (at least under CommitManager.TryCommit)

See PR for more detailed numbers

* Expose some functionality from SourceGeneratedDocumentUri to Razor

* Update src/Tools/ExternalAccess/Razor/RazorUri.cs

* add resource to automate github action merge PRs

* Update resourceManagement.yml

* Preserve encoding during DocumentState updates

Fixes dotnet/sdk#46780

* Fix issue where we were crashing trying to get inheritance margin information for SG docs

* Docs

* Generate-Documentation Check if file is excluded (#77353)

* check for excluded files

* remove unused usings

* fix indentation

* PR Validation - allow insertion to run on commit that isn't latest (#77369)

* allow insertion to run on commit that isn't latest

* remove comments

* Allow PR Val pipeline runs to opt-out of the latest commit validation

* Update CI excludes paths to include some yml files

* Update setup-pr-validation.ps1

* Apply suggestions from code review

---------

Co-authored-by: Joey Robichaud <[email protected]>

* Fix yml typos

* Update PublishData.json after VS Snap (#77383)

* Fix formatting in tests

* Collection expr

* Collection expr

* Make selaed

* Make selaed

* Primary constructors

* Fix out of bounds in text extent computation

* Fix out of bounds in text extent computation

* Fix issue where goto-def wouldn't go to the right place after invoking twice

* [main] Update dependencies from dotnet/source-build-reference-packages (#77335)

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20250224.2

Microsoft.SourceBuild.Intermediate.source-build-reference-packages
 From Version 10.0.611901 -> To Version 10.0.612402

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20250225.2

Microsoft.SourceBuild.Intermediate.source-build-reference-packages
 From Version 10.0.611901 -> To Version 10.0.612502

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20250227.2

Microsoft.SourceBuild.Intermediate.source-build-reference-packages
 From Version 10.0.611901 -> To Version 10.0.612702

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20250228.4

Microsoft.SourceBuild.Intermediate.source-build-reference-packages
 From Version 10.0.611901 -> To Version 10.0.612804

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20250303.3

Microsoft.SourceBuild.Intermediate.source-build-reference-packages
 From Version 10.0.611901 -> To Version 10.0.615303

---------

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* Partial events and constructors: IDE (#77337)

* Partial events and constructors: IDE

* Fix event keyword recommender

* Fix symbol suggestions

* Fixup failing tests

* Fixup SymbolKey

* Improve code

* Use `Equal` instead of `Same` in SymbolKey tests

* Extend a test

* Use collection expressions

Co-authored-by: Cyrus Najmabadi <[email protected]>

---------

Co-authored-by: Cyrus Najmabadi <[email protected]>

* Partial events and constructors: compact error codes

* Detect more null check patterns

* Emit call to ThrowIfNull

* Add string checks

* Add string checks

* Add work items

* Improve performance of SyntaxReplacer.ReplaceNode (#77314)

Improve performance of SyntaxReplacer.ReplaceNode

This should allow better performance when replacing nodes. I've noticed overrides completion commit profiles as indicating a large amount of time/memory spent in their ReplaceNode calls. (about 18% of CPU time and 20% of memory allocations spent within CommitManager.TryCommit are attributable to ReplaceNode calls)

See PR for more details on the performance benefit the speedometer achieves with this change.

* Fix issue where we were changing semantics when converting to a collection expr

* Work item

* Update test

* Update formatting tests

* File scoped namespace

* Fix projects

* Configure main-vs-deps (#77408)

* Configure main-vs-deps

* Run every 3 hours

* Don't use an implicit-object if the lang version doesn't support it

* Add workitem

* Fix bot name (#77436)

* Auto merge PRs instead of just applying a label to them (#77438)

* Small cleanup in the packages and editor factories (#77439)

* Small cleanup in the packages and editor factories

This area is going to get some larger changes in Dev18. As I'm waiting for that branch to become available, do a small cleanup in the area in anticipation of those changes.

These changes are mostly cosmetic. The only change that is a bit more than that is the (Un)RegisterObjectBrowserLibraryManager changes to not be sync. This was done to remove a couple JTF.Runs in the code, and was done after verifying with JeffRo that our package disposal will indeed always be done on the main thread.

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20250305.3 (#77452)

Microsoft.SourceBuild.Intermediate.source-build-reference-packages
 From Version 10.0.615303 -> To Version 10.0.615503

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* Remove workaround of WPF bug

This shouldn't be needed anymore, and prevents some design time build
breaks if NuGet restore wasn't able to get this package.

Fixes #74923

* Fix design time build error in Roslyn.VisualStudio.Setup

The MSBuild task invocation here is a copy/paste from earlier in the
file, but the item group renamed so it didn't conflict. The rename
was in complete, so the use in the Properties property was still
using the old name; this had the effect that we wouldn't set the TFM
property, which would cause problems for multi-targeting projects.

* [Rename flyout] Fixed cropping issue on small screens

* Addressed feedback

* Remove BoundConversion.OriginalUserDefinedConversionsOpt property (#77465)

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20250306.1 (#77470)

Microsoft.SourceBuild.Intermediate.source-build-reference-packages
 From Version 10.0.615503 -> To Version 10.0.615601

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* Update dev18 target branch (#77443)

* Remove unnecessary imports

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20250310.1

Microsoft.SourceBuild.Intermediate.source-build-reference-packages
 From Version 10.0.615601 -> To Version 10.0.616001

* Mark partial events and ctors as complete (#77525)

---------

Co-authored-by: Jan Jones <[email protected]>
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Cyrus Najmabadi <[email protected]>
Co-authored-by: David Barbet <[email protected]>
Co-authored-by: Ankita Khera <[email protected]>
Co-authored-by: David Wengier <[email protected]>
Co-authored-by: Rikki Gibson <[email protected]>
Co-authored-by: Cyrus Najmabadi <[email protected]>
Co-authored-by: Rikki Gibson <[email protected]>
Co-authored-by: akhera99 <[email protected]>
Co-authored-by: Joey Robichaud <[email protected]>
Co-authored-by: Todd Grunke <[email protected]>
Co-authored-by: Youssef1313 <[email protected]>
Co-authored-by: Joey Robichaud <[email protected]>
Co-authored-by: Tomáš Matoušek <[email protected]>
Co-authored-by: Amadeusz Wieczorek <[email protected]>
Co-authored-by: Charles Stoner <[email protected]>
Co-authored-by: Jared Parsons <[email protected]>
Co-authored-by: Sam Harwell <[email protected]>
Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Jason Malinowski <[email protected]>
Co-authored-by: Etienne Baudoux <[email protected]>
Co-authored-by: AlekseyTs <[email protected]>
Co-authored-by: Jan Jones <[email protected]>
@rubo
Copy link

rubo commented Mar 11, 2025

When will the fix be released? v9.0.201 still has this problem.

@mattmc-jtb
Copy link

Agreed rubo. I'm surprised this wasn't considered a critical fix since dotnet format has been effectively broken for a month.

@just-jim
Copy link

So when should we expect to see the fix? In which version?

@JoeRobich
Copy link
Member

The fix merged into the 9.0.2xx branch and will be in the 9.0.202 SDK. I have verified the fix in the 9.0.300 nightly SDK (see https://github.com/dotnet/sdk/blob/main/documentation/package-table.md) build as well.

@dqwork
Copy link

dqwork commented Mar 26, 2025

When would 9.0.202 be included with Visual Studio - Just updated to the latest (17.13.5) and only got SDK 9.0.201 which still has this bug

russcam added a commit to russcam/qdrant-dotnet that referenced this issue Apr 18, 2025
This commit pins the SDK version used for compilation to
.net 8 to match the build and test projects.

There is an issue with `dotnet format` command when building
with certain versions of .net 9 SDK that results in:

```
Unhandled exception: System.Exception: source text did not have an identifiable encoding
```

Looks related to dotnet/sdk#46780, which is fixed in later .net 9 versions. The build doesn't need .net 9, so best to pin to .net 8.
Anush008 pushed a commit to qdrant/qdrant-dotnet that referenced this issue Apr 21, 2025
This commit pins the SDK version used for compilation to
.net 8 to match the build and test projects.

There is an issue with `dotnet format` command when building
with certain versions of .net 9 SDK that results in:

```
Unhandled exception: System.Exception: source text did not have an identifiable encoding
```

Looks related to dotnet/sdk#46780, which is fixed in later .net 9 versions. The build doesn't need .net 9, so best to pin to .net 8.
@mtmk
Copy link

mtmk commented May 12, 2025

fyi I was having the same issue (even after removing BOM) and wasted about an hour before I found this issue.

Upgrading to latest (as of today 9.0.203) fixed it for me.

> dotnet --version
9.0.203

@idgogoasa
Copy link

Running
dotnet format --verify-no-changes
will list the files that need encoding changes
Did that, fixed the encoding using Notepad++ and all is OK.

@jantrmer
Copy link

fyi I was having the same issue (even after removing BOM) and wasted about an hour before I found this issue.

Upgrading to latest (as of today ) fixed it for me.9.0.203

> dotnet --version
9.0.203

I was having the same issue, and downloading and installing SDK 9.0.300 fixed it. Release date: May 13, 2025. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.