Skip to content

Commit

Permalink
Recognise IAsyncEnumerable as a channel type (#43)
Browse files Browse the repository at this point in the history
* Recognise IAsyncEnumerable as a channel type

Fixes #38

* Need to go to .net standard 2.1 for IAsyncEnumerable

Co-authored-by: dave <[email protected]>
  • Loading branch information
danzel and danzel authored May 20, 2022
1 parent 478d4d1 commit ca4fa64
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 12 deletions.
4 changes: 1 addition & 3 deletions src/HelloSignalR/HelloSignalR.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.3" />
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SigSpec.AspNetCore\SigSpec.AspNetCore.csproj" />
Expand Down
6 changes: 3 additions & 3 deletions src/HelloSignalR/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ public void ConfigureServices(IServiceCollection services)
});
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseStaticFiles();
app.UseCors();

app.UseSigSpec();
app.UseSigSpecUi();

app.UseSignalR(routes =>
app.UseEndpoints(endpoints =>
{
routes.MapHub<ChatHub>("/chat");
endpoints.MapHub<ChatHub>("/chat");
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/SigSpec.AspNetCore/SigSpec.AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<Owners>Rico Suter</Owners>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<Owners>Rico Suter</Owners>
Expand Down
2 changes: 1 addition & 1 deletion src/SigSpec.CodeGeneration/SigSpec.CodeGeneration.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<Owners>Rico Suter</Owners>
Expand Down
2 changes: 1 addition & 1 deletion src/SigSpec.Core/SigSpec.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<Owners>Rico Suter</Owners>
Expand Down
4 changes: 2 additions & 2 deletions src/SigSpec.Core/SigSpecGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private IEnumerable<MethodInfo> GetOperationMethods(Type type)
{
return type.GetTypeInfo().GetRuntimeMethods().Where(m =>
{
var returnsChannelReader = m.ReturnType.IsGenericType && m.ReturnType.GetGenericTypeDefinition() == typeof(ChannelReader<>);
var returnsChannelReader = m.ReturnType.IsGenericType && (m.ReturnType.GetGenericTypeDefinition() == typeof(ChannelReader<>) || m.ReturnType.GetGenericTypeDefinition() == typeof(IAsyncEnumerable<>));
return
m.IsPublic &&
m.IsSpecialName == false &&
Expand All @@ -90,7 +90,7 @@ private IEnumerable<MethodInfo> GetChannelMethods(Type type)
{
return type.GetTypeInfo().GetRuntimeMethods().Where(m =>
{
var returnsChannelReader = m.ReturnType.IsGenericType && m.ReturnType.GetGenericTypeDefinition() == typeof(ChannelReader<>);
var returnsChannelReader = m.ReturnType.IsGenericType && (m.ReturnType.GetGenericTypeDefinition() == typeof(ChannelReader<>) || m.ReturnType.GetGenericTypeDefinition() == typeof(IAsyncEnumerable<>));
return
m.IsPublic &&
m.IsSpecialName == false &&
Expand Down

0 comments on commit ca4fa64

Please sign in to comment.