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

Early-bound "Responses" for messages have incorrect capitalization of attributes #519

Open
arp-mbender opened this issue Sep 25, 2024 · 2 comments

Comments

@arp-mbender
Copy link

arp-mbender commented Sep 25, 2024

Tool and Version
EarlyBoundGenerator V 2.2024.9.11

Describe the bug
Using Early Bound Generator V2 for custom messages produces incorrect attribute names in between getter / setter.

See following auto-generated code for a custom action response class:

	[System.Runtime.Serialization.DataContractAttribute(Namespace="http://schemas.microsoft.com/xrm/2011/inc/")]
	[Microsoft.Xrm.Sdk.Client.ResponseProxyAttribute("inc_calculateassettype")]
	public partial class Inc_CalculateAssetTypeResponse : Microsoft.Xrm.Sdk.OrganizationResponse
	{
		
		public Inc_CalculateAssetTypeResponse()
		{
		}
		
		public int ResultCustomerAssetType
		{
			get
			{
				if (this.Results.Contains("resultCustomerAssetType"))
				{
					return ((int)(this.Results["resultCustomerAssetType"]));
				}
				else
				{
					return default(int);
				}
			}
			set
			{
				this.Results["ResultCustomerAssetType"] = value;
			}
		}
	}

The get portion of the ResultCustomerAssetType is referencing field name resultCustomerAssetType (correct), while the get portion is referencing the field ResultCustomerAssetType (incorrect - will never be set).

Obviously these field strings need to match the actual parameters of the action in CRM in terms of capitalization (in this case the property in Dynamics starts with a lowercase).

To Reproduce
Generate early bounds for a custom action.

Expected behavior
Field getters and setters should use the same field name string.

@arp-mbender arp-mbender changed the title Early-bounds for messages have incorrect capitalization of attributes Early-bound "replies" for messages have incorrect capitalization of attributes Sep 25, 2024
@arp-mbender arp-mbender changed the title Early-bound "replies" for messages have incorrect capitalization of attributes Early-bound "Responses" for messages have incorrect capitalization of attributes Sep 25, 2024
@daryllabar
Copy link
Owner

Are all actions getting generated this way for you? Can you generate your metadata and submit that so I can see what's going on?
https://github.com/daryllabar/DLaB.Xrm.XrmToolBoxTools/wiki/EBG-%E2%80%90-Submitting-Metadata-For-Debugging

@arp-mbender
Copy link
Author

I'm a bit concerned sharing the whole metadata for this organization, as it's not "mine". I can, however, pick the custom action definition from the metadata, which is all that should be relevant.

I've tested this operation with another custom action I've just created and it's like before. For a moment I thought this may have something to do with CustomerAsset being a CRM entity (i.e. possibly capitalized because of this) but other outputs appear to be capitalized as well.

Metadata minimized to sample action:

<Metadata xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://DLaB.ModelBuilderExtensions">
  <MetadataMessages>
    <Messages xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
      <d3p1:KeyValueOfguidMetadataMessage7_SEpMnF1>
        <d3p1:Key>368f6b90-4a7b-ef11-ac20-000d3ada2d06</d3p1:Key>
        <d3p1:Value>
          <Id>368f6b90-4a7b-ef11-ac20-000d3ada2d06</Id>
          <IsCustomAction>true</IsCustomAction>
          <IsPrivate>false</IsPrivate>
          <MetadataFilters>
            <d3p1:KeyValueOfguidMetadataFilter7_SEpMnF1>
              <d3p1:Key>378f6b90-4a7b-ef11-ac20-000d3ada2d06</d3p1:Key>
              <d3p1:Value>
                <Id>378f6b90-4a7b-ef11-ac20-000d3ada2d06</Id>
                <IsVisible>false</IsVisible>
                <PrimaryObjectTypeCode>0</PrimaryObjectTypeCode>
                <SecondaryObjectTypeCode>0</SecondaryObjectTypeCode>
              </d3p1:Value>
            </d3p1:KeyValueOfguidMetadataFilter7_SEpMnF1>
          </MetadataFilters>
          <MetadataPairs>
            <d3p1:KeyValueOfguidMetadataPair7_SEpMnF1>
              <d3p1:Key>1bc915ce-4a7b-ef11-ac20-000d3ada2d06</d3p1:Key>
              <d3p1:Value>
                <Id>1bc915ce-4a7b-ef11-ac20-000d3ada2d06</Id>
                <MessageNamespace>http://schemas.microsoft.com/xrm/2011/inc/</MessageNamespace>
                <Request>
                  <Id>1cc915ce-4a7b-ef11-ac20-000d3ada2d06</Id>
                  <Name>inc_testcustomaction</Name>
                  <RequestFields />
                </Request>
                <Response>
                  <Id>1dc915ce-4a7b-ef11-ac20-000d3ada2d06</Id>
                  <ResponseFields>
                    <d3p1:KeyValueOfintMetadataResponseFieldkBKot4kd>
                      <d3p1:Key>1</d3p1:Key>
                      <d3p1:Value>
                        <CLRFormatter>System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</CLRFormatter>
                        <Index>1</Index>
                        <Name>CapitalizedArgument</Name>
                        <Value>CapitalizedArgument</Value>
                      </d3p1:Value>
                    </d3p1:KeyValueOfintMetadataResponseFieldkBKot4kd>
                    <d3p1:KeyValueOfintMetadataResponseFieldkBKot4kd>
                      <d3p1:Key>2</d3p1:Key>
                      <d3p1:Value>
                        <CLRFormatter>System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</CLRFormatter>
                        <Index>2</Index>
                        <Name>resultCustomerAsset</Name>
                        <Value>resultCustomerAsset</Value>
                      </d3p1:Value>
                    </d3p1:KeyValueOfintMetadataResponseFieldkBKot4kd>
                    <d3p1:KeyValueOfintMetadataResponseFieldkBKot4kd>
                      <d3p1:Key>0</d3p1:Key>
                      <d3p1:Value>
                        <CLRFormatter>System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</CLRFormatter>
                        <Index>0</Index>
                        <Name>uncapitalizedArgument</Name>
                        <Value>uncapitalizedArgument</Value>
                      </d3p1:Value>
                    </d3p1:KeyValueOfintMetadataResponseFieldkBKot4kd>
                  </ResponseFields>
                </Response>
              </d3p1:Value>
            </d3p1:KeyValueOfguidMetadataPair7_SEpMnF1>
          </MetadataPairs>
          <Name>inc_testcustomaction</Name>
        </d3p1:Value>
      </d3p1:KeyValueOfguidMetadataMessage7_SEpMnF1></Messages>
  </MetadataMessages>
  <OptionSets xmlns:d2p1="http://schemas.microsoft.com/xrm/2011/Metadata" />
</Metadata>

Resulting early bound cs file:

#pragma warning disable CS1591

namespace Vattenfall.InCharge.Plugins.DataverseLibrary
{
	
	
	[System.Runtime.Serialization.DataContractAttribute(Namespace="http://schemas.microsoft.com/xrm/2011/inc/")]
	[Microsoft.Xrm.Sdk.Client.RequestProxyAttribute("inc_testcustomaction")]
	public partial class Inc_TestCustomActionRequest : Microsoft.Xrm.Sdk.OrganizationRequest
	{
		
		public const string ActionLogicalName = "inc_testcustomaction";
		
		public Inc_TestCustomActionRequest()
		{
			this.RequestName = "inc_testcustomaction";
		}
	}
	
	[System.Runtime.Serialization.DataContractAttribute(Namespace="http://schemas.microsoft.com/xrm/2011/inc/")]
	[Microsoft.Xrm.Sdk.Client.ResponseProxyAttribute("inc_testcustomaction")]
	public partial class Inc_TestCustomActionResponse : Microsoft.Xrm.Sdk.OrganizationResponse
	{
		
		public static class Fields
		{
			public const string CapitalizedArgument = "CapitalizedArgument";
			public const string ResultCustomerAsset = "ResultCustomerAsset";
			public const string UncapitalizedArgument = "UncapitalizedArgument";
		}
		
		public const string ActionLogicalName = "inc_testcustomaction";
		
		public Inc_TestCustomActionResponse()
		{
		}
		
		public int CapitalizedArgument
		{
			get
			{
				if (this.Results.Contains("CapitalizedArgument"))
				{
					return ((int)(this.Results["CapitalizedArgument"]));
				}
				else
				{
					return default(int);
				}
			}
			set
			{
				this.Results["CapitalizedArgument"] = value;
			}
		}
		
		public int ResultCustomerAsset
		{
			get
			{
				if (this.Results.Contains("resultCustomerAsset"))
				{
					return ((int)(this.Results["resultCustomerAsset"]));
				}
				else
				{
					return default(int);
				}
			}
			set
			{
				this.Results["ResultCustomerAsset"] = value;
			}
		}
		
		public int UncapitalizedArgument
		{
			get
			{
				if (this.Results.Contains("uncapitalizedArgument"))
				{
					return ((int)(this.Results["uncapitalizedArgument"]));
				}
				else
				{
					return default(int);
				}
			}
			set
			{
				this.Results["UncapitalizedArgument"] = value;
			}
		}
	}
}
#pragma warning restore CS1591

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants