This question is related to a previous, unanswered question of mine, as I'm still solving the same problem; this is about a different approach though.
I'm currently consuming a third-party SOAP web service in a C# .NET project. Unfortunately, the generated client proxy classes and class members have names that are inconsistent with my current conventions.
Until advised otherwise, I'm left to presume that Svcutil doesn't support aliasing (though, it certainly seem it would be most easily accomplished at that level)
I'm now considering wrapping the web service consumption into it's own project, thus assembly, and simply referencing that from other projects. I'm considering this given that it's possible to add some (presumably, assembly-level) declarations to expose the public types with different names than those defined within the assembly.
My question is; is it possible to expose different type/member names than those defined in the assembly, essentially aliasing them?
For example, given a magical assembly attribute:
[assembly: AssemblyTypeAlias(
Type = typeof(Foo.Bar.qux),
Name = "Qux"
)]
Thus, projects referencing this assembly would access Foo.Bar.qux
as Foo.Bar.Qux
.
Of course, a similar class-level attribute would be great too, seeing as the generated proxies are partial
:
namespace Foo.Bar
{
[Alias("Qux")]
public partial class qux
{
}
}
Yielding the same effect.
While I've only covered type names with my theoretical examples, a solution that allows the aliasing of member names would be spectacular.
Edit: I've said "alias", where the more applicable term would be "rename", in order to hide the original name; preferably the latter, but the former will work.
I've moved this answer suggesting use of the XmlType Attribute in the Reference to the Service to your other question, since this one is really asking about aliasing assemblies, whether they come from a service or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With