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

WCF service with DataContract and EnumValues not returning enum values in result #101594

Closed
nealculiner opened this issue Apr 24, 2024 · 10 comments
Closed
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers os-ios Apple iOS

Comments

@nealculiner
Copy link

Description

I'm in the process of migrating a Xamarin.iOS app to net8.0-ios. I'm finding that some WCF service methods are broken which seem to be related to the wrong serializer being used from what I can tell. I'm using Visual Studio 2022 17.9.6 which is the latest as of this writing. It's a basic WCF service call to a service I host which returns a DataContract with an array of a class which contains an Enum. The enum is decorated with DataContract and each Enum value is decorated with EnumValue and there is an assignment for the 0 value. No matter what I try the enum value is always 0 in the returned array containing a list of this enum object. There are no DataSets in the return value as I've read there is an issue in net8-ios with using the Xml serializer instead of the DataContract serializer. Does anyone have any tips to resolve this as it seems WCF is broken in net8.0-ios.

Steps to Reproduce

Basic WCF service with a class marked with DataContract and enum values marked with EnumValue. I return a List of a class that contains this enum as one of the properties. The enum always comes across as 0.

Link to public reproduction project repository

No response

Version with bug

8.0.3 GA

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

17

Did you find any workaround?

No response

Relevant log output

No response

@vitek-karas
Copy link
Member

Does it work in Debug build? Or it's always broken?

@nealculiner
Copy link
Author

I'm only using debug build as I do the migration from Xamarin.iOS.

@nealculiner
Copy link
Author

Here is the class of which an array of is returned from the WCF service method:

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="Subscription", Namespace="http://schemas.datacontract.org/2004/07/AppServices.DataContracts")]
public partial class Subscription : object
{

    private System.DateTime ExpirationUtcField;

    private bool IsUserAuthenticatedField;

    private string LinkField;

    private NCSoftware.Utilities.SubscriptionPlan PlanField;

    private string TitleField;

    private string[] UserRolesField;

    [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
    public System.DateTime ExpirationUtc
    {
        get
        {
            return this.ExpirationUtcField;
        }
        set
        {
            this.ExpirationUtcField = value;
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
    public bool IsUserAuthenticated
    {
        get
        {
            return this.IsUserAuthenticatedField;
        }
        set
        {
            this.IsUserAuthenticatedField = value;
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
    public string Link
    {
        get
        {
            return this.LinkField;
        }
        set
        {
            this.LinkField = value;
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
    public NCSoftware.Utilities.SubscriptionPlan Plan
    {
        get
        {
            return this.PlanField;
        }
        set
        {
            this.PlanField = value;
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
    public string Title
    {
        get
        {
            return this.TitleField;
        }
        set
        {
            this.TitleField = value;
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
    public string[] UserRoles
    {
        get
        {
            return this.UserRolesField;
        }
        set
        {
            this.UserRolesField = value;
        }
    }
}

This is the enum within the above:


namespace NCSoftware.Utilities
{
	[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
	[System.Runtime.Serialization.DataContractAttribute(Name="SubscriptionPlan", Namespace="http://schemas.datacontract.org/2004/07/NCSoftware.Utilities")]
	public enum SubscriptionPlan : int
	{

		[System.Runtime.Serialization.EnumMemberAttribute()]
		Beta = -2,

		[System.Runtime.Serialization.EnumMemberAttribute()]
		All = -1,

		[System.Runtime.Serialization.EnumMemberAttribute()]
		None = 0,

		[System.Runtime.Serialization.EnumMemberAttribute()]
		ScheduleImporter = 1,

		[System.Runtime.Serialization.EnumMemberAttribute()]
		CloudSync = 2,

		[System.Runtime.Serialization.EnumMemberAttribute()]
		CloudBackup = 3,

		[System.Runtime.Serialization.EnumMemberAttribute()]
		Combo = 4,

		[System.Runtime.Serialization.EnumMemberAttribute()]
		CloudDataShared = 5,

		[System.Runtime.Serialization.EnumMemberAttribute()]
		CloudDataPrivate = 6,

		[System.Runtime.Serialization.EnumMemberAttribute()]
		LogbookProMobile = 7,

		[System.Runtime.Serialization.EnumMemberAttribute()]
		APDLMobileBasic = 8,

		[System.Runtime.Serialization.EnumMemberAttribute()]
		APDLMobilePro = 9,

		[System.Runtime.Serialization.EnumMemberAttribute()]
		APDLMobilePrem = 10,

		[System.Runtime.Serialization.EnumMemberAttribute()]
		APDLMobileEnterprise = 11,

		[System.Runtime.Serialization.EnumMemberAttribute()]
		ScheduleImporterNoAPDL = 12,
	}

	[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
	[System.Runtime.Serialization.DataContractAttribute(Name="Collation", Namespace="http://schemas.datacontract.org/2004/07/NCSoftware.Utilities")]
	public enum Collation : int
	{
		
		[System.Runtime.Serialization.EnumMemberAttribute()]
		ByLeg = 0,
		
		[System.Runtime.Serialization.EnumMemberAttribute()]
		ByDay = 1,
	}
	
	[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
	[System.Runtime.Serialization.DataContractAttribute(Name="TimeZoneModes", Namespace="http://schemas.datacontract.org/2004/07/NCSoftware.Utilities")]
	public enum TimeZoneModes : int
	{
		
		[System.Runtime.Serialization.EnumMemberAttribute()]
		Local = 0,
		
		[System.Runtime.Serialization.EnumMemberAttribute()]
		UTC = 1,
		
		[System.Runtime.Serialization.EnumMemberAttribute()]
		UserDefined = 2,
	}

	[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
	[System.Runtime.Serialization.DataContractAttribute(Name="WeatherRadarImageSize", Namespace="http://schemas.datacontract.org/2004/07/NCSoftware.Utilities")]
	public enum WeatherRadarImageSize : int
	{

		[System.Runtime.Serialization.EnumMemberAttribute()]
		SizeAll = -1,

		[System.Runtime.Serialization.EnumMemberAttribute()]
		SizeRaw = 0,

		[System.Runtime.Serialization.EnumMemberAttribute()]
		Size680x320 = 1,

		[System.Runtime.Serialization.EnumMemberAttribute()]
		Size1360x640 = 2,
	}
}

@drasticactions
Copy link

Can you try running this in a .NET iOS app that doesn't use the MAUI UI Framework? You can do that by installing the iOS workload (dotnet workload install ios) and running dotnet new ios.

IMO This is highly likely to be a dotnet runtime issue and not related to the MAUI UI framework. I would be shocked if something specific within this repo would cause that. @rolfbjarne what do you think?

@rolfbjarne
Copy link
Member

IMO This is highly likely to be a dotnet runtime issue and not related to the MAUI UI framework. I would be shocked if something specific within this repo would cause that. @rolfbjarne what do you think?

Agreed, my guess would be either a serializer bug or something with the trimmer. In either case, it's a runtime issue.

@nealculiner
Copy link
Author

This is a net8.0-ios app, not maui, but I figured this was the place to log it as they seem to be almost one in the same now but only for ios in my case. I agree, it's probably runtime, if you want to move it, please do. I couldn't figure out where best to report this. Thank you.

@drasticactions
Copy link

This is a net8.0-ios app, not maui, but I figured this was the place to log it as they seem to be almost one in the same now but only for ios in my case. I agree, it's probably runtime, if you want to move it, please do. I couldn't figure out where best to report this. Thank you.

No worries, it's easy to confuse and it's easy to move to the right place (unless you're me, I don't have access ;-)) . This repo is for the cross-platform MAUI UI project, so issues like yours get filed here (since most people using the underlying SDK bindings and runtime are doing it through a framework like MAUI) so they hit runtime bugs and file it here since they assume it's one and the same.

For runtime issues, it should go to dotnet/runtime. Specific SDK issues go to xamarin-android and xamarin-macios.

@rolfbjarne (or anyone with access to move it) could you please move this to runtime? Thanks!

@rolfbjarne rolfbjarne transferred this issue from dotnet/maui Apr 26, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Apr 26, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Apr 26, 2024
@jeffschwMSFT jeffschwMSFT added os-ios Apple iOS area-Tools-ILLink .NET linker development as well as trimming analyzers labels May 1, 2024
Copy link
Contributor

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas
See info in area-owners.md if you want to be subscribed.

@vcsjones vcsjones removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label May 7, 2024
@agocke
Copy link
Member

agocke commented Jun 28, 2024

Without custom steps, XML Serializer isn't trim safe. If this is supposed to work in xamarin-ios then there is a bug in the custom steps. Otherwise, XMLSerializer is marked RUC so this is not expected to work through trimming.

@agocke
Copy link
Member

agocke commented Jun 28, 2024

Looks like I can't move issues cross-org, so I'm going to close this and link from a new issue.

@agocke agocke closed this as completed Jun 28, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Jun 28, 2024
@agocke agocke closed this as not planned Won't fix, can't repro, duplicate, stale Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers os-ios Apple iOS
Projects
Archived in project
Development

No branches or pull requests

7 participants