Skip to content

Commit eb87efd

Browse files
committed
Remove FMED006 as we can't know if a handler exists in another project
1 parent 35e06d0 commit eb87efd

File tree

2 files changed

+2
-41
lines changed

2 files changed

+2
-41
lines changed

src/Foundatio.Mediator/HandlerGenerator.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -660,25 +660,10 @@ private static void ValidateCallSite(SourceProductionContext context, CallSiteIn
660660
return; // Only validate Invoke calls, not Publish
661661

662662
// If the message is a generic type parameter (e.g., T), we cannot know the handler at compile time,
663-
// so do not emit FMED006/FMDE007 for missing/multiple handlers.
663+
// so do not emit FMDE007 for missing/multiple handlers.
664664
if (callSite.MessageType.IsTypeParameter)
665665
return;
666666

667-
// FMED006: No handler found for invoke call
668-
if (handlersForMessage.Count == 0)
669-
{
670-
var diagnostic = new DiagnosticInfo
671-
{
672-
Identifier = "FMED006",
673-
Title = "No handler found for message",
674-
Message = $"No handler found for message type '{callSite.MessageType.FullName}'. Invoke calls require exactly one handler.",
675-
Severity = DiagnosticSeverity.Error,
676-
Location = callSite.Location
677-
};
678-
context.ReportDiagnostic(diagnostic.ToDiagnostic());
679-
return;
680-
}
681-
682667
// FMED007: Multiple handlers found for invoke call
683668
if (handlersForMessage.Count > 1)
684669
{

tests/Foundatio.Mediator.Tests/DiagnosticValidationTests.cs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,6 @@ public class DiagnosticValidationTests : GeneratorTestBase
44
{
55
private static readonly MediatorGenerator Gen = new();
66

7-
[Fact]
8-
public void FMED006_NoHandlerForInvoke()
9-
{
10-
var src = """
11-
using System.Threading;
12-
using System.Threading.Tasks;
13-
using Foundatio.Mediator;
14-
15-
public record Msg;
16-
public record Other;
17-
public class OtherHandler { public Task HandleAsync(Other m, CancellationToken ct) => Task.CompletedTask; }
18-
19-
public static class Calls {
20-
public static async Task Call(IMediator m) {
21-
await m.InvokeAsync(new Msg());
22-
}
23-
}
24-
""";
25-
26-
var (_, genDiags, _) = RunGenerator(src, [ Gen ]);
27-
Assert.Contains(genDiags, d => d.Id == "FMED006");
28-
}
29-
307
[Fact]
318
public void FMED007_MultipleHandlersForInvoke()
329
{
@@ -126,7 +103,6 @@ public static async Task Call<T>(IMediator m, T msg) {
126103
""";
127104

128105
var (_, genDiags, _) = RunGenerator(src, [ Gen ]);
129-
Assert.DoesNotContain(genDiags, d => d.Id == "FMED006");
106+
Assert.DoesNotContain(genDiags, d => d.Id == "FMED007");
130107
}
131108
}
132-

0 commit comments

Comments
 (0)