Skip to content

Commit

Permalink
#31 Visual Studio build is failing with error: "An unhandled error ha…
Browse files Browse the repository at this point in the history
…s occurred. Collection was modified"
  • Loading branch information
NikolayPianikov committed Aug 8, 2023
1 parent f0c54be commit 6ac11d9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Pure.DI.Core/Core/DependencyGraphBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ bool TryCreateOnCannotResolve(MdSetup mdSetup, DependencyNode ownerNode, Injecti
processed.Add(node);
}

foreach (var key in map.Keys.Where(i => ReferenceEquals(i.Tag, MdTag.ContextTag)))
foreach (var key in map.Keys.Where(i => ReferenceEquals(i.Tag, MdTag.ContextTag)).ToArray())
{
map.Remove(key);
}
Expand Down
2 changes: 0 additions & 2 deletions src/Pure.DI.Core/Core/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ public Unit Build(IEnumerable<SyntaxUpdate> updates)
default,
LogId.ErrorUnhandled,
error));

throw;
}
finally
{
Expand Down
12 changes: 11 additions & 1 deletion src/Pure.DI.Core/Core/LogInfoBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,17 @@ public LogInfo Build(LogEntry logEntry)
DiagnosticDescriptor? descriptor = default;
if (!string.IsNullOrWhiteSpace(logEntry.Id))
{
descriptor = new DiagnosticDescriptor(logEntry.Id!, severityCode, firstLine, severityCode, logEntry.Severity, true);
var message = new StringBuilder(firstLine);
if (logEntry.Exception is { } exception)
{
message.Append(", Message: \"");
message.Append(exception.Message);
message.Append("\", Stack Trace: \"");
message.Append(exception.StackTrace.Replace(System.Environment.NewLine, " "));
message.Append('"');
}

descriptor = new DiagnosticDescriptor(logEntry.Id!, severityCode, message.ToString(), severityCode, logEntry.Severity, true);
}

return new LogInfo(
Expand Down
2 changes: 1 addition & 1 deletion src/Pure.DI/Pure.DI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</PropertyGroup>

<!--<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants>TRACE;TRACE_MODE</DefineConstants>
<DefineConstants>DEBUG_MODE</DefineConstants>
</PropertyGroup>-->

<ItemGroup>
Expand Down

0 comments on commit 6ac11d9

Please sign in to comment.