Skip to content

Commit 5598372

Browse files
committed
Various updates
1 parent ff0548a commit 5598372

14 files changed

+764
-669
lines changed

samples/ConsoleSample/ConsoleSample.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
<!-- Emit compiler generated files for debugging purposes -->
1010
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
1111
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
12-
<InterceptorsNamespaces>$(InterceptorsNamespaces);Foundatio.Mediator</InterceptorsNamespaces>
12+
<DisableMediatorInterceptors>true</DisableMediatorInterceptors>
1313
</PropertyGroup>
1414

1515
<ItemGroup>
16+
<CompilerVisibleProperty Include="DisableMediatorInterceptors" />
1617
<!-- Exclude the output of source generators from the compilation -->
1718
<Compile Remove="$(CompilerGeneratedFilesOutputPath)/**/*.cs" />
1819
</ItemGroup>

src/Foundatio.Mediator.SourceGenerator/DIRegistrationGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static string GenerateDIRegistration(List<HandlerInfo> handlers, List<Mid
7070
else
7171
{
7272
// For sync handlers, we need to provide a dummy async wrapper that calls the sync method
73-
source.AppendLine($" (mediator, message, cancellationToken, responseType) => new ValueTask<object>({wrapperClassName}.UntypedHandle(mediator, message, cancellationToken, responseType)),");
73+
source.AppendLine($" (mediator, message, cancellationToken, responseType) => new ValueTask<object?>({wrapperClassName}.UntypedHandle(mediator, message, cancellationToken, responseType)),");
7474
source.AppendLine($" {wrapperClassName}.UntypedHandle,");
7575
}
7676

src/Foundatio.Mediator.SourceGenerator/Foundatio.Mediator.SourceGenerator.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
<ItemGroup>
1616
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
1717
<None Include="..\Foundatio.Mediator\bin\$(Configuration)\netstandard2.0\Foundatio.Mediator.dll" Pack="true" PackagePath="lib/netstandard2.0" Visible="false" />
18+
<None Include="Foundatio.Mediators.SourceGenerator.props" Pack="true" PackagePath="build" Visible="true" />
19+
<None Include="Foundatio.Mediators.SourceGenerator.targets" Pack="true" PackagePath="build" Visible="true" />
1820
</ItemGroup>
1921

2022
</Project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project>
2+
<ItemGroup>
3+
<CompilerVisibleProperty Include="DisableMediatorInterceptors" />
4+
</ItemGroup>
5+
</Project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project InitialTargets="Foundatio_Mediator_Interceptors">
2+
<Target Name="Foundatio_Mediator_Interceptors">
3+
<PropertyGroup Condition="'$(DisableMediatorInterceptors)' != 'true'">
4+
<InterceptorsNamespaces>$(InterceptorsNamespaces);Foundatio.Mediators</InterceptorsNamespaces>
5+
<InterceptorsPreviewNamespaces>$(InterceptorsPreviewNamespaces);Foundatio.Mediators</InterceptorsPreviewNamespaces>
6+
</PropertyGroup>
7+
</Target>
8+
</Project>

src/Foundatio.Mediator.SourceGenerator/HandlerInfo.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public readonly record struct HandlerInfo
1313
public readonly bool IsStatic;
1414
public readonly EquatableArray<ParameterInfo> Parameters;
1515
public readonly EquatableArray<string> MessageTypeHierarchy;
16+
public readonly EquatableArray<CallSiteInfo> CallSites;
1617

1718
public HandlerInfo(
1819
string handlerTypeName,
@@ -23,7 +24,8 @@ public HandlerInfo(
2324
bool isAsync,
2425
bool isStatic,
2526
List<ParameterInfo> parameters,
26-
List<string> messageTypeHierarchy)
27+
List<string> messageTypeHierarchy,
28+
List<CallSiteInfo> callSites)
2729
{
2830
HandlerTypeName = handlerTypeName;
2931
MessageTypeName = messageTypeName;
@@ -34,6 +36,7 @@ public HandlerInfo(
3436
IsStatic = isStatic;
3537
Parameters = new(parameters.ToArray());
3638
MessageTypeHierarchy = new(messageTypeHierarchy.ToArray());
39+
CallSites = new(callSites.ToArray());
3740
}
3841
}
3942

src/Foundatio.Mediator.SourceGenerator/HandlerWrapperGenerator.cs

Lines changed: 681 additions & 334 deletions
Large diffs are not rendered by default.

src/Foundatio.Mediator.SourceGenerator/InterceptorGenerator.cs

Lines changed: 0 additions & 283 deletions
This file was deleted.

0 commit comments

Comments
 (0)