diff --git a/src/IceRpc.Slice/DefaultServicePathTypeExtensions.cs b/src/IceRpc.Slice/DefaultServicePathTypeExtensions.cs deleted file mode 100644 index 565dc0476..000000000 --- a/src/IceRpc.Slice/DefaultServicePathTypeExtensions.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) ZeroC, Inc. - -using System.Diagnostics; -using ZeroC.Slice; - -namespace IceRpc.Slice; - -/// Provides an extension method for to get the default service path from a generated -/// interface or proxy type. -/// -public static class DefaultServicePathTypeExtensions -{ - /// Computes the default service path for this type using its Slice type ID attribute. - /// The service interface or proxy struct generated by the Slice compiler. - /// The default service path. - /// Thrown if is not an interface or a struct, or if - /// it does not have a attribute. - public static string GetDefaultServicePath(this Type type) - { - if (type.IsInterface || type.IsValueType) - { - if (type.GetSliceTypeId() is string typeId) - { - Debug.Assert(typeId.StartsWith("::", StringComparison.Ordinal)); - return "/" + typeId[2..].Replace("::", ".", StringComparison.Ordinal); - } - else - { - throw new ArgumentException( - $"The type '{type}' doesn't have a {nameof(SliceTypeIdAttribute)} attribute.", - nameof(type)); - } - } - else - { - throw new ArgumentException($"The type '{type}' is neither an interface nor a struct.", nameof(type)); - } - } -} diff --git a/tests/IceRpc.Slice.Tests/TypeIdAttributeTests.cs b/tests/IceRpc.Slice.Tests/TypeIdAttributeTests.cs index 482490895..8795c7cc3 100644 --- a/tests/IceRpc.Slice.Tests/TypeIdAttributeTests.cs +++ b/tests/IceRpc.Slice.Tests/TypeIdAttributeTests.cs @@ -13,7 +13,6 @@ public sealed class TypeIdAttributeTests /// The expected type ID. [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")] @@ -23,25 +22,4 @@ public void Get_slice_type_id(Type type, string? expected) string? typeId = type.GetSliceTypeId(); Assert.That(typeId, Is.EqualTo(expected)); } - - /// Verifies that types generated from Slice definitions have the expected default path. - /// The of the generated type to test. - /// The expected type ID. - [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); } diff --git a/tools/IceRpc.ProtocGen/ClientGenerator.cs b/tools/IceRpc.ProtocGen/ClientGenerator.cs index de9cde7d5..e2e7ff69b 100644 --- a/tools/IceRpc.ProtocGen/ClientGenerator.cs +++ b/tools/IceRpc.ProtocGen/ClientGenerator.cs @@ -86,9 +86,8 @@ internal static string GenerateImplementation(ServiceDescriptor service) /// protoc-gen-icerpc-csharp generated this record struct from Protobuf service {service.Name}. public readonly partial record struct {clientImplementationName} : I{service.Name.ToPascalCase()} {{ - /// Gets the default service address for services that implement Protobuf service {service.FullName}. - /// Its protocol is icerpc and its path is the Protobuf service name. - /// + /// Gets the default service address for services that implement Protobuf service {service.FullName}: + /// icerpc:/{service.Name}. public static IceRpc.ServiceAddress DefaultServiceAddress {{ get; }} = new(IceRpc.Protocol.IceRpc) {{ Path = ""/{service.Name}"" }}; diff --git a/tools/slicec-cs/src/generators/proxy_generator.rs b/tools/slicec-cs/src/generators/proxy_generator.rs index 76ac7ed24..0dc610c3d 100644 --- a/tools/slicec-cs/src/generators/proxy_generator.rs +++ b/tools/slicec-cs/src/generators/proxy_generator.rs @@ -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()); @@ -67,9 +66,8 @@ This remote service must implement Slice interface {slice_interface}."# .add_block( format!( r#" -/// Gets the default service address for services that implement Slice interface {slice_interface}. -/// Its protocol is and its path is computed from the name of the Slice interface. -/// +/// Gets the default service address for services that implement Slice interface {slice_interface}: +/// icerpc:{default_service_path}. public static IceRpc.ServiceAddress DefaultServiceAddress {{ get; }} = new(IceRpc.Protocol.IceRpc) {{ Path = "{default_service_path}" }};