Skip to content

Commit

Permalink
Default service path cleanup (icerpc#3723)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier authored Oct 19, 2023
1 parent bb016e8 commit 2311983
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 68 deletions.
39 changes: 0 additions & 39 deletions src/IceRpc.Slice/DefaultServicePathTypeExtensions.cs

This file was deleted.

22 changes: 0 additions & 22 deletions tests/IceRpc.Slice.Tests/TypeIdAttributeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public sealed class TypeIdAttributeTests
/// <param name="expected">The expected type ID.</param>
[TestCase(typeof(IceObjectProxy), "::Ice::Object")]
[TestCase(typeof(PingableProxy), "::IceRpc::Slice::Tests::Pingable")]
[TestCase(typeof(IMyInterface), "::IceRpc::Slice::Tests::TypeIdAttributeTestNamespace::MyInterface")]
[TestCase(typeof(MyInterfaceProxy), "::IceRpc::Slice::Tests::TypeIdAttributeTestNamespace::MyInterface")]
[TestCase(typeof(IMyInterfaceService), "::IceRpc::Slice::Tests::TypeIdAttributeTestNamespace::MyInterface")]
[TestCase(typeof(MyOtherInterfaceProxy), "::IceRpc::Slice::Tests::TypeIdAttributeTestNamespace::myOtherInterface")]
Expand All @@ -23,25 +22,4 @@ public void Get_slice_type_id(Type type, string? expected)
string? typeId = type.GetSliceTypeId();
Assert.That(typeId, Is.EqualTo(expected));
}

/// <summary>Verifies that types generated from Slice definitions have the expected default path.</summary>
/// <param name="type">The <see cref="Type" /> of the generated type to test.</param>
/// <param name="expected">The expected type ID.</param>
[TestCase(typeof(IceObjectProxy), "/Ice.Object")]
[TestCase(typeof(PingableProxy), "/IceRpc.Slice.Tests.Pingable")]
[TestCase(typeof(IMyInterface), "/IceRpc.Slice.Tests.TypeIdAttributeTestNamespace.MyInterface")]
[TestCase(typeof(MyInterfaceProxy), "/IceRpc.Slice.Tests.TypeIdAttributeTestNamespace.MyInterface")]
[TestCase(typeof(IMyInterfaceService), "/IceRpc.Slice.Tests.TypeIdAttributeTestNamespace.MyInterface")]
[TestCase(typeof(MyOtherInterfaceProxy), "/IceRpc.Slice.Tests.TypeIdAttributeTestNamespace.myOtherInterface")]
public void Get_default_path(Type type, string expected)
{
string defaultPath = type.GetDefaultServicePath();
Assert.That(defaultPath, Is.EqualTo(expected));
}

[TestCase(typeof(MyClass))]
[TestCase(typeof(MyException))]
[TestCase(typeof(ServerAddress))]
public void Get_default_path_exception(Type type) =>
Assert.That(type.GetDefaultServicePath, Throws.ArgumentException);
}
5 changes: 2 additions & 3 deletions tools/IceRpc.ProtocGen/ClientGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ internal static string GenerateImplementation(ServiceDescriptor service)
/// <remarks>protoc-gen-icerpc-csharp generated this record struct from Protobuf service <c>{service.Name}</c>.</remarks>
public readonly partial record struct {clientImplementationName} : I{service.Name.ToPascalCase()}
{{
/// <summary>Gets the default service address for services that implement Protobuf service {service.FullName}.
/// Its protocol is <c>icerpc</c> and its path is the Protobuf service name.
/// </summary>
/// <summary>Gets the default service address for services that implement Protobuf service {service.FullName}:
/// <c>icerpc:/{service.Name}</c>.</summary>
public static IceRpc.ServiceAddress DefaultServiceAddress {{ get; }} =
new(IceRpc.Protocol.IceRpc) {{ Path = ""/{service.Name}"" }};
Expand Down
6 changes: 2 additions & 4 deletions tools/slicec-cs/src/generators/proxy_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ pub fn generate_proxy(interface_def: &Interface) -> CodeBlock {
interface_def,
)
.add_comments(interface_def.formatted_doc_comment_seealso())
.add_type_id_attribute(interface_def)
.add_bases(&interface_bases)
.add_block(proxy_interface_operations(interface_def));
code.add_block(&proxy_interface_builder.build());
Expand All @@ -67,9 +66,8 @@ This remote service must implement Slice interface {slice_interface}."#
.add_block(
format!(
r#"
/// <summary>Gets the default service address for services that implement Slice interface {slice_interface}.
/// Its protocol is <see cref="IceRpc.Protocol.IceRpc" /> and its path is computed from the name of the Slice interface.
/// </summary>
/// <summary>Gets the default service address for services that implement Slice interface {slice_interface}:
/// <c>icerpc:{default_service_path}</c>.</summary>
public static IceRpc.ServiceAddress DefaultServiceAddress {{ get; }} =
new(IceRpc.Protocol.IceRpc) {{ Path = "{default_service_path}" }};
Expand Down

0 comments on commit 2311983

Please sign in to comment.