stefanegli / resxformatter Goto Github PK
View Code? Open in Web Editor NEWFormats .resx files: Sorts data entries by name and removes xml comments.
License: MIT License
Formats .resx files: Sorts data entries by name and removes xml comments.
License: MIT License
First, thank you very, very much for this extension. It's a must have.
As you know, most of the context of a resx file is clutter, in fact, most of the time, the entire file is useless.
Would it be possible to add an option to automatically delete empty resx files or, better yet, disable their generation?
Thanks again.
Set machine localization to US English ->
(Control Panel -> Clock and region -> Formats -> English (United States)
Create an en-us resx file with the following labels:
"Api"
"Assigned"
"Attribute"
"Average"
"Azure"
See the resx be sorted to the above alphabetical order.
Update machine localization from En-Us over to Estonian
(Control Panel -> Clock and Region -> Formats -> Estonian (Estonia))
Open Visual Studio > Navigate to the Resx file
Create a new label + hit save.
The order is updated to:
"Api"
"Assigned"
"Azure"
"Attribute"
"Average"
Why
According to the Estonian alphabet Z comes before T So it alphabetizes based on the local machine rules for the user as opposed to the resx language of choice.
Potential Solution
Add an option on sorting to allow culture invariant sorting, so all resx will follow the same pattern independent of if the team is across different localizations.
Describe the bug
The extension was working ok but at some point recently it stopped working. I'm keeping my VS2019 updated, using the last version v16.7.2, in windows 10. When I hit save (in the save icon or with the ctrl + s shortcut), the resource strings are not being sorted. The file is not being updated in any way. I tried in two different computers.
Describe the bug
Resource file will not reload when changed and saved when setting Reload file after saving
is set to AfterModification
To Reproduce
Steps to reproduce the behavior:
AfterModification
"Expected behavior
Changed resource file is reloaded
Screenshots
n.a.
Desktop (please complete the following information):
n.a.
Smartphone (please complete the following information):
n.a.
Additional context
Line 88 in ResxFormatterPackage.cs
should read:
if ((formatter.Run(document.Path) && settings.ReloadFile == ReloadMode.AfterModification)
Describe the bug
The setting resx_formatter_remove_documentation_comment
is either named misleadingly or incorrect.
What resx_formatter_remove_documentation_comment=true
does:
What resx_formatter_remove_documentation_comment=false
does:
Expected behavior
What resx_formatter_remove_documentation_comment=true
should do:
Microsoft ResX Schema
stringWhat resx_formatter_remove_documentation_comment=false
should do:
Desktop (please complete the following information):
Additional context
I think it should be totally legit to have XML comments throughout the ResX file and the extension just ignoring them.
Please strip the comments from the Designer.cs file that is being generated by VisualStudio from resx files.
In our team we have VisualStudio installations with different language settings (i.e. English and German) and every time someone touches a resx file (for localization) the corresponding Designer.cs file is being generated and all comments therein are being replaced in whatever language has is being configured in the local VisualStudio. That leads to crazy conflicts when two people with different language settings are editing the same resx file.
So I propose, for any resx file your extension is editing, look for a corresponding Designer.cs file and strip comments from there, also.
Example:
"Localization.resx" is being edited
"Localization.Designer.cs" file is being generated by VisualStudio
=> ResxFormatter should strip comments from both files.
The sort function that was added uses StringComparer.Ordinal
, making it case-sensitive. This messes up the order of all of my resx files because the previous extension I had for older versions of VS sorted case-insensitively.
I'm not sure whether this was intentional, since the Sort.resx
test case is very simple with three lower-case strings.
abc
def
ghi
However when you try to sort resx
files with mixed-case strings, they don't come out in case-insensitive order:
Alaska
ARIZONA
Aardvark
amazing
ABOUT
Is sorted as:
ABOUT
ARIZONA
Aardvark
Alaska
amazing
Describe the solution you'd like
What I would like this to sort as would be in pure alphabetical order, regardless of case:
Aardvark
ABOUT
Alaska
amazing
ARIZONA
To do this requires using StringComparer.OrdinalIgnoreCase
instead of StringComparer.Ordinal
.
I have a patch which adds a new option, resx_formatter_sort_entries_case_sensitive
. This works in conjunction with resx_formatter_sort_entries
so that if resx_formatter_sort_entries
is false, the new option is ignored.
I have not added a test case yet but can quite easily once it's said that this is a feature you want to add.
Describe the bug
I get the following error in the ActivityLog when loading the ResxFormatter package (2.0.68)
<description>
SetSite failed for package [ResxFormatterPackage]Source:'Microsoft.VisualStudio.Shell.15.0' Description: Due to high risk of deadlock you cannot call GetService from a background thread in an AsyncPackage derived class. You should instead call GetServiceAsync (without calling Result or Wait on the resultant Task object) or switch to the UI thread with the JoinableTaskFactory.SwitchToMainThreadAsync method before calling GetService.
System.InvalidOperationException: Due to high risk of deadlock you cannot call GetService from a background thread in an AsyncPackage derived class. You should instead call GetServiceAsync (without calling Result or Wait on the resultant Task object) or switch to the UI thread with the JoinableTaskFactory.SwitchToMainThreadAsync method before calling GetService.
at Microsoft.VisualStudio.Shell.AsyncPackage.GetService(Type serviceType)
at Microsoft.VisualStudio.Shell.Package.System.IServiceProvider.GetService(Type serviceType)
at Microsoft.VisualStudio.Shell.Package.PackageContainer.GetService(Type serviceType)
at System.ComponentModel.Container.Site.GetService(Type service)
at System.ComponentModel.Component.GetService(Type service)
at Microsoft.VisualStudio.Shell.DialogPage.get_SettingsManager()
at Microsoft.VisualStudio.Shell.DialogPage.LoadSettingsFromStorage()
at Microsoft.VisualStudio.Shell.DialogPage.set_Site(ISite value)
at System.ComponentModel.Container.Add(IComponent component, String name)
at System.ComponentModel.Container.Add(IComponent component)
at Microsoft.VisualStudio.Shell.Package.GetDialogPage(Type dialogPageType)
at ResxFormatter.ResxFormatterPackage.get_Settings()
at ResxFormatter.ResxFormatterPackage.<InitializeAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Shell.AsyncPackage.<>c__DisplayClass17_0.<<Microsoft-VisualStudio-Shell-Interop-IAsyncLoadablePackageInitialize-Initialize>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask.<JoinAsync>d__78.MoveNext()</description>
To Reproduce
Just install the package in Visual Studio 2017 using vsixinstaller
Expected behavior
No error when package loading
Desktop (please complete the following information):
Windows 10
Smartphone (please complete the following information):
N/A
Additional context
Just add the following statement (as first statement) to the protected override async Task InitializeAsync(....)
(ResxFormatterPackage.cs):
await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
When I update from 2.0.68 to 3.0.76 I noticed that newly added resx entries no longer reordered themselves alphabetically, older entries stayed as is. The designer file is fine and orders itself correctly.
Desktop
Additional context
Moving back to 2.0.68 worked. I also tried to make 3.0.76 work with changing settings in Tools -> options -> ResxFormatter -> General and with making changes in .editorconfig
Describe the bug
SetSite failed for package [ResxFormatterPackage]Source: 'mscorlib' Description: An item with the same key has already been added.
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add)
 at EditorConfig.Core.EditorConfigFile.Parse(String file) in /home/runner/work/editorconfig-core-net/editorconfig-core-net/src/EditorConfig.Core/EditorConfigFile.cs:line 72
 at EditorConfig.Core.EditorConfigFile..ctor(String file) in /home/runner/work/editorconfig-core-net/editorconfig-core-net/src/EditorConfig.Core/EditorConfigFile.cs:line 43
 at EditorConfig.Core.EditorConfigParser.<>c.<ParseConfigFilesTillRoot>b__16_0(String f) in /home/runner/work/editorconfig-core-net/editorconfig-core-net/src/EditorConfig.Core/EditorConfigParser.cs:line 105
 at System.Linq.Enumerable.<>c__DisplayClass7_0
3.<CombineSelectors>b__0(TSource x)
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
 at EditorConfig.Core.EditorConfigParser.<ParseConfigFilesTillRoot>d__16.MoveNext() in /home/runner/work/editorconfig-core-net/editorconfig-core-net/src/EditorConfig.Core/EditorConfigParser.cs:line 105
 at System.Linq.Buffer
1..ctor(IEnumerable1 source)
 at System.Linq.Enumerable.<ReverseIterator>d__75
1.MoveNext()
at System.Collections.Generic.List1..ctor(IEnumerable
1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)
 at EditorConfig.Core.EditorConfigParser.GetConfigurationFilesTillRoot(String file) in /home/runner/work/editorconfig-core-net/editorconfig-core-net/src/EditorConfig.Core/EditorConfigParser.cs:line 100
 at EditorConfig.Core.EditorConfigParser.Parse(String fileName, IEnumerable
1 editorConfigFiles) in /home/runner/work/editorconfig-core-net/editorconfig-core-net/src/EditorConfig.Core/EditorConfigParser.cs:line 72
at ResxFormatter.ResxEditorConfigSettings..ctor(String targetFile)
at ResxFormatter.ResxFormatterPackage.ApplyEditorConfigSettings(OptionPageGrid currentSettings)
at ResxFormatter.ResxFormatterPackage.get_Settings()
at ResxFormatter.ResxFormatterPackage.<InitializeAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Shell.AsyncPackage.<>c__DisplayClass20_0.<<Microsoft-VisualStudio-Shell-Interop-IAsyncLoadablePackageInitialize-Initialize>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Shell.UIThreadReentrancyScope.WaitOnTaskCompleteInternal(Task task, CancellationToken cancel, Int32 ms)
at Microsoft.VisualStudio.Shell.UIThreadReentrancyScope.WaitOnTaskComplete(Task task, CancellationToken cancel, Int32 ms)
at Microsoft.VisualStudio.Services.VsTask.<>c__DisplayClass100_1.<InternalGetResult>b__1()
at Microsoft.VisualStudio.Services.VsTask.IgnoreObjectDisposedException(Action action)
at Microsoft.VisualStudio.Services.VsTask.<>c__DisplayClass100_0.<InternalGetResult>b__0()
at Microsoft.VisualStudio.Services.VsTask.<>c__DisplayClass108_0.<InvokeWithWaitDialog>b__0()
at Microsoft.VisualStudio.Services.VsTask.InvokeWithWaitDialog[T](Func`1 function)
at Microsoft.VisualStudio.Services.VsTask.InvokeWithWaitDialog(Action action)
at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck)
at Microsoft.VisualStudio.Services.VsTask.GetResult()
To Reproduce
Steps to reproduce the behavior:
Expected behavior
No error
Also tried to clear MEF cache, did not have effect.
Hi Stefan
Thank you very much for ResXFormatter, it's a simple but so useful tool notably when using git. I saw there is a preview version for VS2022, as of August 2021. What's the status for it? Is it stable, does it has bugs, would you have a release date in mind?
Thank again for your time and effort on it!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.