Skip to content

Commit 79ddc44

Browse files
Fix #3377: Extend error information if multiple assemblies with the same (short) name are selected when creating a solution file.
1 parent c0c5559 commit 79ddc44

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

ILSpy/SolutionWriter.cs

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
using ICSharpCode.Decompiler;
2929
using ICSharpCode.Decompiler.Solution;
3030
using ICSharpCode.Decompiler.Util;
31-
using ICSharpCode.ILSpy.Docking;
3231
using ICSharpCode.ILSpy.TextView;
3332
using ICSharpCode.ILSpy.ViewModels;
3433
using ICSharpCode.ILSpyX;
@@ -99,13 +98,42 @@ async Task<AvalonEditTextOutput> CreateSolution(TabPageModel tabPage, IEnumerabl
9998
{
10099
var result = new AvalonEditTextOutput();
101100

102-
var duplicates = new HashSet<string>();
103-
if (assemblies.Any(asm => !duplicates.Add(asm.ShortName)))
101+
var assembliesByShortName = assemblies.ToLookup(_ => _.ShortName);
102+
bool first = true;
103+
bool abort = false;
104+
105+
foreach (var item in assembliesByShortName)
104106
{
105-
result.WriteLine("Duplicate assembly names selected, cannot generate a solution.");
106-
return result;
107+
var enumerator = item.GetEnumerator();
108+
if (!enumerator.MoveNext())
109+
continue;
110+
var firstAssembly = enumerator.Current;
111+
if (!enumerator.MoveNext())
112+
continue;
113+
if (first)
114+
{
115+
result.WriteLine("Duplicate assembly names selected, cannot generate a solution:");
116+
abort = true;
117+
}
118+
119+
result.Write("- " + firstAssembly.Text + " conflicts with ");
120+
121+
first = true;
122+
do
123+
{
124+
var asm = enumerator.Current;
125+
if (!first)
126+
result.Write(", ");
127+
result.Write(asm.Text);
128+
first = false;
129+
} while (enumerator.MoveNext());
130+
result.WriteLine();
131+
first = false;
107132
}
108133

134+
if (abort)
135+
return result;
136+
109137
Stopwatch stopwatch = Stopwatch.StartNew();
110138

111139
try

0 commit comments

Comments
 (0)