question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Aliase for type parameters

See original GitHub issue

I use my xml file as configuration file for the end user. It would be great if I could specify aliases for types. So that the user could do sth like

        <AlbedoColor type="Color">
          <R>156</R>
          <G>208</G>
          <B>84</B>
          <A>255</A>
        </AlbedoColor>

Instead of

        <AlbedoColor type="OpenTK.Graphics.Color4">
          <R>156</R>
          <G>208</G>
          <B>84</B>
          <A>255</A>
        </AlbedoColor>

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:37 (27 by maintainers)

github_iconTop GitHub Comments

2reactions
WojciechNagorskicommented, Feb 16, 2017

Version 1.5.0 supports XmlRootAttribute and XmlElementAttribute. In these attributes you can change name.

XmlElement attribute

	public class TestClassWithXmlElementAttribute
	{
		[XmlElement(ElementName = "Identifier")]
		public int Id { get; set; }
	}

Xml will be look like:

<TestClassWithXmlElementAttribute type=""ExtendedXmlSerialization.Test.TestObject.TestClassWithXmlElementAttribute"">
  <Identifier>123</Identifier>
</TestClassWithXmlElementAttribute>

And XmlRoot attribute:

	[XmlRoot(ElementName = "TestClass")]
	public class TestClassWithXmlRootAttribute
	{
		public int Id { get; set; }
	}

Xml will be look like:

<TestClass type=""ExtendedXmlSerialization.Test.TestObject.TestClassWithXmlRootAttribute"">
  <Id>123</Id>
</TestClass>

Currently in v2, these xmls will look like:

<?xml version="1.0" encoding="utf-8"?>
<TestClassWithXmlElementAttribute xmlns="clr-namespace:ExtendedXmlSerialization.Test.TestObject;assembly=ExtendedXmlSerializerTest">
	<Identifier>123</Identifier>
</TestClassWithXmlElementAttribute>
<?xml version="1.0" encoding="utf-8"?>
<TestClass xmlns="clr-namespace:ExtendedXmlSerialization.Test.TestObject;assembly=ExtendedXmlSerializerTest">
	<Id>123</Id>
</TestClass>

XmlElementAttribute has counterpart in configuration:

cfg => cfg.ConfigureType<TestClassWithXmlElementAttribute>()
					   .Property(p => p.Id).Name("Identifier")

XmlRoot attribute doesn’t have counterpart in configuration. @Mike-EEE Do you think (like me) that it is the same function. If yes we should add cfg.ConfigType<Color4>().Name("Color"); instead of cfg.ConfigType<Color4>().Alias("Color");

1reaction
michidkcommented, Aug 13, 2017

Haha, great 😆 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Type aliases requiring type parameters · Issue #1616
I don't think so. The issue is that the any use of a type alias is always equivalent to a thing that we...
Read more >
Is it possible to create a type alias for multiple parameters ...
You can make a type object that is an alias for the type arguments passed into the templated function. It evaluates to undefined...
Read more >
Type aliases & function types | Academy
Type aliases. Create your own custom types using the "type" keyword, understand the "void" type, and learn how to write custom function types....
Read more >
PEP 695 – Type Parameter Syntax
This PEP specifies an improved syntax for specifying type parameters within a generic class, function, or type alias.
Read more >
Creating type aliases - Learn TypeScript
The syntax for creating a type alias ... type TypeAliasName = ExistingType;. So, the type keyword is placed before the chosen name for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found