You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current process when writing an IceRPC+Slice application is:
a) describe your Slice interfaces in a Slice file (.slice)
b) generate code from these Slice files with the Slice compiler
c) write your own code that calls the generated proxy (for invocations) or implements the generated Service interfaces (for service implementations)
This is a proposal to allow IceRPC users to skip (a) and (b), and write IceRPC+Slice applications without Slice files or the Slice compiler.
Note that this proposed path is an alternative to the current path. Not a replacement.
Proxies
If you write a client application, you could define a Slice proxy by adding an attribute to your own hand-written interface, for example:
[IceRpc.Slice.SliceProxy] instructs the IceRpc+Slice source generator to generate a NameProxy struct that implements all the methods of this interface. These methods must return a Task or Task<T> and have an Async suffix. The features parameter is optional (i.e. the user doesn't need to include it). Maybe the cancellationToken can be optional too.
We would offer some level of customization for the generated proxy, such as the ability to set the default path and the ability to set the operation name (all via attributes).
Services
If you write a server application, you can define a service by adding an attribute to your hand-written class:
namespace Xyz.Server;[SliceService]internalpartialclassChatbot// must be partial{// any access-level is fineinternalValueTask<string>GreetAsync(stringname,CancellationTokencancellationToken){
Console.WriteLine($"Dispatching greet request {{ name = '{name}' }}");returnnew($"Hello, {name}!");}}
The (existing) attribute [IceRpc.Slice.SliceService] instructs the IceRpc+Slice source generator to implement IDispatcher using the xxxAsync methods defined by this class.
Like for the proxy methods, IFeatureCollection and possibly CancellationToken would be optional. We would also provide an attribute to exclude methods from the source-generated dispatch.
The parameters of implicitly defined Slice operations need to be encodable/decodable. So they are either primitive types like String and int, or they are user-defined types with Slice attributes.
The current process when writing an IceRPC+Slice application is:
a) describe your Slice interfaces in a Slice file (.slice)
b) generate code from these Slice files with the Slice compiler
c) write your own code that calls the generated proxy (for invocations) or implements the generated Service interfaces (for service implementations)
This is a proposal to allow IceRPC users to skip (a) and (b), and write IceRPC+Slice applications without Slice files or the Slice compiler.
Note that this proposed path is an alternative to the current path. Not a replacement.
Proxies
If you write a client application, you could define a Slice proxy by adding an attribute to your own hand-written interface, for example:
[IceRpc.Slice.SliceProxy]
instructs the IceRpc+Slice source generator to generate a NameProxy struct that implements all the methods of this interface. These methods must return aTask
orTask<T>
and have an Async suffix. The features parameter is optional (i.e. the user doesn't need to include it). Maybe the cancellationToken can be optional too.We would offer some level of customization for the generated proxy, such as the ability to set the default path and the ability to set the operation name (all via attributes).
Services
If you write a server application, you can define a service by adding an attribute to your hand-written class:
The (existing) attribute
[IceRpc.Slice.SliceService]
instructs the IceRpc+Slice source generator to implement IDispatcher using the xxxAsync methods defined by this class.Like for the proxy methods, IFeatureCollection and possibly CancellationToken would be optional. We would also provide an attribute to exclude methods from the source-generated dispatch.
Related issue: #3738.
The text was updated successfully, but these errors were encountered: