stefanegli/ResxFormatter

Crash on launch with 1.1.44 and VS 16.9.3

Closed this issue · 3 comments

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)&#x000D;&#x000A; at EditorConfig.Core.EditorConfigFile.Parse(String file) in /home/runner/work/editorconfig-core-net/editorconfig-core-net/src/EditorConfig.Core/EditorConfigFile.cs:line 72&#x000D;&#x000A; at EditorConfig.Core.EditorConfigFile..ctor(String file) in /home/runner/work/editorconfig-core-net/editorconfig-core-net/src/EditorConfig.Core/EditorConfigFile.cs:line 43&#x000D;&#x000A; at EditorConfig.Core.EditorConfigParser.&lt;&gt;c.&lt;ParseConfigFilesTillRoot&gt;b__16_0(String f) in /home/runner/work/editorconfig-core-net/editorconfig-core-net/src/EditorConfig.Core/EditorConfigParser.cs:line 105&#x000D;&#x000A; at System.Linq.Enumerable.&lt;&gt;c__DisplayClass7_03.<CombineSelectors>b__0(TSource x) at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()&#x000D;&#x000A; at EditorConfig.Core.EditorConfigParser.&lt;ParseConfigFilesTillRoot&gt;d__16.MoveNext() in /home/runner/work/editorconfig-core-net/editorconfig-core-net/src/EditorConfig.Core/EditorConfigParser.cs:line 105&#x000D;&#x000A; at System.Linq.Buffer1..ctor(IEnumerable1 source)&#x000D;&#x000A; at System.Linq.Enumerable.&lt;ReverseIterator&gt;d__751.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)&#x000D;&#x000A; at EditorConfig.Core.EditorConfigParser.GetConfigurationFilesTillRoot(String file) in /home/runner/work/editorconfig-core-net/editorconfig-core-net/src/EditorConfig.Core/EditorConfigParser.cs:line 100&#x000D;&#x000A; at EditorConfig.Core.EditorConfigParser.Parse(String fileName, IEnumerable1 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:

  1. Download 1.1.44
  2. Open visual studio
  3. See error, error log pasted from ActivityLog.xml

Expected behavior
No error

Also tried to clear MEF cache, did not have effect.

I tried to make the stacktrace somewhat more readable

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.&lt;&gt;c.&lt;ParseConfigFilesTillRoot&gt;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.&lt;&gt;c__DisplayClass7_03.<CombineSelectors>b__0(TSource x) at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() 
  at EditorConfig.Core.EditorConfigParser.&lt;ParseConfigFilesTillRoot&gt;d__16.MoveNext() in /home/runner/work/editorconfig-core-net/editorconfig-core-net/src/EditorConfig.Core/EditorConfigParser.cs:line 105 
  at System.Linq.Buffer1..ctor(IEnumerable1 source) 
  at System.Linq.Enumerable.&lt;ReverseIterator&gt;d__751.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 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, IEnumerable1 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()

It looks like the EditorConfig component throws an exception. While I probably should deal with this better it may still be a good idea to verify that your EditorConfig files are "valid". Is there something in your file that would qualify as a "duplicate" section/item?

The latest build (1.1.46) catches this exception so that the plugin remains usable, but the actual cause of the exception is of course still unclear.

I can easily reproduce this exception if I have duplicate keys in my EditorConfig file. This can be seen in the output pane as follows:

[17:59:07] Failed to parse EditorConfig file:
System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.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 this point I do not see anything else I can do for this situation. Please make sure your EditorConfig file can be parsed correctly.