Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properties are not filled in despite EnableParameterizedContentWithPropertyAssignments #427

Closed
maxkoshevoi opened this issue Aug 14, 2020 · 10 comments
Assignees
Labels
bug (cc: fix) Something isn't working

Comments

@maxkoshevoi
Copy link

maxkoshevoi commented Aug 14, 2020

Hi again =)

So now I'm facing denationalization issue. Type has parameterized constructor, it serializes fine, and on deserialization constructor is called, but no other properties are filled in:

image

Updated repository, so it contains repro code for this issue: https://github.com/maxkoshevoi/ExtendedXmlSerializer-423

@issue-label-bot issue-label-bot bot added the bug (cc: fix) Something isn't working label Aug 14, 2020
@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.63. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@Mike-E-angelo Mike-E-angelo self-assigned this Aug 14, 2020
@Mike-E-angelo
Copy link
Member

Hey! 😅 Thank you for taking the time to report these issues. 👍

To start, are you sure this is using the latest preview? (#424 (comment))

I did try reproducing it but I have a passing test here:

[Fact]
public void Verify()
{
var config = new NewFieldInfo(FieldType.OptionSet)
{
Name = "ASDF",
TargetName = "What?"
};
var element = new[] {config};
var serializer = new ConfigurationContainer().UseOptimizedNamespaces()
.EnableImplicitTypingFromPublicNested<Issue427Tests>()
.EnableParameterizedContentWithPropertyAssignments()
.Create()
.ForTesting();
serializer.Cycle(config).Should().BeEquivalentTo(config);
serializer.Cycle(element).Should().BeEquivalentTo(element.Cast<NewFieldInfo>());
}
public class ExistingOptionSetFieldInfo : NewFieldInfo
{
public ExistingOptionSetFieldInfo() : base(FieldType.OptionSet)
{
IsExistsOnSource = true;
}
public bool IsExistsOnSource { get; protected set; }
public string OptionSetName { get; set; }
}
public enum FieldType
{
OptionSet
}
public class NewFieldInfo
{
public NewFieldInfo(FieldType type)
{
Type = type;
}
public FieldType Type { get; }
public string Name { get; set; }
public string Description { get; set; } = null;
public bool IsRequired { get; set; }
public string TargetName { get; set; }
public bool ShouldCreateFieldOnTarget { get; set; }
}
public class NewOptionSetFieldInfo : ExistingOptionSetFieldInfo
{
public NewOptionSetFieldInfo()
{
IsExistsOnSource = false;
}
public Dictionary<int, string> Values { get; } = new Dictionary<int, string>();
}

Is there a difference in the class/graph perhaps? If you can provide some code again I can check it out further for you.

@maxkoshevoi
Copy link
Author

maxkoshevoi commented Aug 14, 2020

It's not latest preview, this issue is not related to previous one. It's latest stable (3.2.4). Code is in the same repository: https://github.com/maxkoshevoi/ExtendedXmlSerializer-423
I've updated it to, so it contains code for this issue now.

@maxkoshevoi
Copy link
Author

Oh, regarding the test. Your array type is wrong. It should be NewTypeInfo (base class of NewFieldInfo)

@Mike-E-angelo
Copy link
Member

OK! I see it now. This is actually an issue with both EnableParameterizedContent* extensions. Nice find. Tricky. :) It also looks involved, so it might take a while. I'll see if I can carve up some time this weekend to investigate further. In the meantime, please do use arrays aligned with the same element type if you can manage.

@Mike-E-angelo
Copy link
Member

Goodness, I gotta say that whenever a new issue is reported here now part of me freaks out as I have to dig through code I wrote over 3 years ago and get acclimated with how I was thinking back then which is NOTHING LIKE WOULD DO NOW. 😅

Anyways, this was a tricky one but I think I got it situated for you:
#428 (comment)

@maxkoshevoi maxkoshevoi changed the title Properties are not field in despite EnableParameterizedContentWithPropertyAssignments Properties are not filled in despite EnableParameterizedContentWithPropertyAssignments Aug 16, 2020
@maxkoshevoi
Copy link
Author

Thank you so much for (in no particular order) fixing this so quickly and maintaining your 3-year-old repository.
If it wasn't for this NuGet, I don't know how would I do xml serialization.

So, fix for this and previous issues are releasing this Thursday, right? Or should I use pre-release version for now. I need to store child classes in base class array.

@Mike-E-angelo
Copy link
Member

Thank you for the kind words, @maxkoshevoi 🙏

Indeed, you should use the preview version for now until Tuesday, at which point I will release to NuGet. Please let me know if you encounter any other/additional issues between now and then and I will look into them for you. 👍

@Mike-E-angelo
Copy link
Member

Mike-E-angelo commented Aug 16, 2020

I have merged in this PR so the updated version for the preview feed should be used:

Install-Package ExtendedXmlSerializer -Version 3.2.4.4 -Source https://ci.appveyor.com/nuget/extendedxmlserializer-preview

Unfortunately, AppVeyor doesn't provide notifications on PR merges, only commits so I have to provide this manually. The above should work, let me know if it doesn't otherwise.

@Mike-E-angelo
Copy link
Member

Mike-E-angelo commented Aug 18, 2020

This fix has been deployed to NuGet and can be found here:

https://www.nuget.org/packages/ExtendedXmlSerializer/

Thanks again for reporting and providing code towards discovering, diagnosing, and ultimately fixing this issue. Please do let me know of any issues you find around this or any other issue and I will take a look into it for you. Closing this issue for now.

An extensible Xml Serializer for .NET that builds on the functionality of the classic XmlSerializer with a powerful and robust extension model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (cc: fix) Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants