Type configuration being applied to all derived types of the abstract class that implements the member
See original GitHub issueHi @Mike-E-wins not sure if this is a bug but I’m seeing somewhat the opposite of issue #398 where I configure the member of a derived type, but all types deriving from the base where the member is defined receive that configuration. I tried both with and without the custom extension from #398
Here’s myrepro:
[Test]
public void MyTest()
{
var serializer = new ConfigurationContainer()
.EnableImplicitTyping(typeof(Subject))
.UseOptimizedNamespaces()
.Type<SubjectA>().Member(x => x.Signature).Ignore() // <-- only configuring SubjectA, not SubjectB
.Create();
var subjects = new List<ISubject>();
subjects.Add(new SubjectA { Signature = "testa" });
subjects.Add(new SubjectB { Signature = "testb" });
var str = serializer.Serialize(
new XmlWriterSettings { Indent = true }, subjects);
Console.WriteLine(str);
}
interface ISubject
{
string Signature { get; set; }
}
public abstract class BaseSubject : ISubject
{
public string Signature { get; set; }
}
public class SubjectA : BaseSubject
{
}
public class SubjectB : BaseSubject
{
}
Output is:
<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ns1="clr-namespace:SerializerTests;assembly=UnitTestSerializer" xmlns:exs="https://extendedxmlserializer.github.io/v2" exs:arguments="ns1:Playground-ISubject" xmlns="https://extendedxmlserializer.github.io/system">
<Capacity>4</Capacity>
<ns1:Playground-SubjectA />
<ns1:Playground-SubjectB />
</List>
I would have thought it would only ignore Signature
on SubjectA
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Abstract and Sealed Classes and Class Members - C# ...
The abstract keyword enables you to create classes and class members that are incomplete and must be implemented in a derived class.
Read more >How can a user choose the implementation of an abstract ...
I want users of my class "ShapeHolder" to be able to set the "Shape shape" member variable to be any class with the...
Read more >C# | Abstract Classes
Abstract classes are used to define a common set of behaviors or properties ... and all derived classes must implement abstract definitions.
Read more >What code should be included in an abstract class?
In these cases, the abstract class is usually used as a place where you can put any kind of common code that current...
Read more >Abstract Class in Java
Java Abstract class is used to provide common method implementation to all the subclasses or to provide default implementation. We can run ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @Mike-E-angelo !
Issue-Label Bot is automatically applying the label
bug
to this issue, with a confidence of 0.66. Please mark this comment with 👍 or 👎 to give our bot feedback!Links: app homepage, dashboard and code for this bot.