-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove redundant reporting classes (#46)
- Loading branch information
1 parent
d6d82d3
commit 0c4b52d
Showing
6 changed files
with
10 additions
and
86 deletions.
There are no files selected for viewing
34 changes: 0 additions & 34 deletions
34
TestsHelper.SourceGenerator/Diagnostics/GlobalDiagnosticReporter.cs
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
TestsHelper.SourceGenerator/Diagnostics/Reporters/IDiagnosticReporter.cs
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
TestsHelper.SourceGenerator/Diagnostics/Reporters/ReportExtensions.cs
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
TestsHelper.SourceGenerator/SourceGeneratorImplementations/ActionDiagnosticReporter.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 9 additions & 5 deletions
14
TestsHelper.SourceGenerator/SourceGeneratorImplementations/ReportCatcher.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.CodeAnalysis; | ||
using TestsHelper.SourceGenerator.Diagnostics; | ||
using TestsHelper.SourceGenerator.Diagnostics.Exceptions; | ||
using TestsHelper.SourceGenerator.Diagnostics.Reporters; | ||
|
||
namespace TestsHelper.SourceGenerator.SourceGeneratorImplementations; | ||
|
||
public static class ReportCatcher | ||
{ | ||
public static void RunCode(Action action) | ||
public static void RunCode(Action action, Action<Diagnostic> reporter) | ||
{ | ||
IDiagnosticReporter reporter = GlobalDiagnosticReporter.Reporter!; | ||
try | ||
{ | ||
action(); | ||
} | ||
catch (DiagnosticException e) | ||
{ | ||
reporter.Report(e.Diagnostic); | ||
reporter(e.Diagnostic); | ||
} | ||
catch (MultipleDiagnosticsException e) | ||
{ | ||
reporter.ReportMultiple(e.Diagnostics); | ||
foreach (Diagnostic diagnostic in e.Diagnostics) | ||
{ | ||
reporter(diagnostic); | ||
} | ||
} | ||
} | ||
} |