Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Data Contract Serialization for Remoting Exceptions #629

Merged
merged 9 commits into from
Nov 9, 2023
43 changes: 32 additions & 11 deletions src/Hosting.Services.Remoting/HostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,17 @@ public static ServiceFabricHostBuilder<OmexStatefulService, StatefulServiceConte
this ServiceFabricHostBuilder<OmexStatefulService, StatefulServiceContext> builder,
string name,
FabricTransportRemotingListenerSettings? settings = null)
where TService : class, IService =>
builder
.ConfigureServices((_, services) => services.TryAddTransient<TService>())
.AddRemotingListener(name, (provider, _) => provider.GetRequiredService<TService>(), settings);
where TService : class, IService
{
if (settings == null)
{
settings = new FabricTransportRemotingListenerSettings();
}
settings.ExceptionSerializationTechnique = FabricTransportRemotingListenerSettings.ExceptionSerialization.Default;
return builder
.ConfigureServices((_, services) => services.TryAddTransient<TService>())
.AddRemotingListener(name, (provider, _) => provider.GetRequiredService<TService>(), settings);
}

/// <summary>
/// Adds remote listener to stateless service
Expand All @@ -34,10 +41,17 @@ public static ServiceFabricHostBuilder<OmexStatelessService, StatelessServiceCon
this ServiceFabricHostBuilder<OmexStatelessService, StatelessServiceContext> builder,
string name,
FabricTransportRemotingListenerSettings? settings = null)
where TService : class, IService =>
builder
.ConfigureServices((_, services) => services.TryAddTransient<TService>())
.AddRemotingListener(name, (provider, _) => provider.GetRequiredService<TService>(), settings);
where TService : class, IService
{
if (settings == null)
{
settings = new FabricTransportRemotingListenerSettings();
}
settings.ExceptionSerializationTechnique = FabricTransportRemotingListenerSettings.ExceptionSerialization.Default;
return builder
.ConfigureServices((_, services) => services.TryAddTransient<TService>())
.AddRemotingListener(name, (provider, _) => provider.GetRequiredService<TService>(), settings);
}
Pr1ynka marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Adds remote listener to stateful service
Expand All @@ -64,8 +78,15 @@ public static ServiceFabricHostBuilder<TService, TContext> AddRemotingListener<T
Func<IServiceProvider, TService, IService> createService,
FabricTransportRemotingListenerSettings? settings = null)
where TService : IServiceFabricService<TContext>
where TContext : ServiceContext =>
builder.AddServiceListener(p =>
new GenericRemotingListenerBuilder<TService>(name, p, createService, settings));
where TContext : ServiceContext
{
if (settings == null)
{
settings = new FabricTransportRemotingListenerSettings();
}
settings.ExceptionSerializationTechnique = FabricTransportRemotingListenerSettings.ExceptionSerialization.Default;
return builder.AddServiceListener(p =>
K-Cully marked this conversation as resolved.
Show resolved Hide resolved
new GenericRemotingListenerBuilder<TService>(name, p, createService, settings));
}
}
}