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

AttributeMetadata.OptionSet is null #165

Open
sybaris opened this issue Oct 16, 2024 · 1 comment
Open

AttributeMetadata.OptionSet is null #165

sybaris opened this issue Oct 16, 2024 · 1 comment

Comments

@sybaris
Copy link

sybaris commented Oct 16, 2024

Hi,

In the following program, I have attMetadata.OptionSet == null. Why ?

internal class Program
{
    public static IXrmFakedContext CreateXrmFakedContext(bool includeOrganizationEntity = true)
    {
        var context = MiddlewareBuilder
                    .New()
                    .AddCrud()
                    .AddFakeMessageExecutors()
                    .AddFakeMessageExecutors(Assembly.GetAssembly(typeof(RetrieveVersionRequestExecutor)))
                    .AddGenericFakeMessageExecutors(Assembly.GetAssembly(typeof(NavigateToNextEntityOrganizationRequestExecutor)))
                    .UseCrud()
                    .UseMessages()
                    .SetLicense(FakeXrmEasyLicense.RPL_1_5)
                    .Build();
        context.EnableProxyTypes(Assembly.GetExecutingAssembly());
        context.InitializeMetadata(Assembly.GetExecutingAssembly());

        if (includeOrganizationEntity)
        {
            context.AddEntity(new Organization() { Id = Guid.NewGuid(), Name = "UnitTestOrganization" });
            context.AddEntity(new Solution() { Id = Guid.NewGuid(), UniqueName = "UnitTestSolution" });
        }
        return context;
    }

    static void Main(string[] args)
    {
        var context = CreateXrmFakedContext();

        var crmService = context.GetOrganizationService();

        var attReq = new RetrieveAttributeRequest();
        attReq.EntityLogicalName = "solutioncomponent";
        attReq.LogicalName = "componenttype";
        attReq.RetrieveAsIfPublished = false;
        var attResponse = (RetrieveAttributeResponse)crmService.Execute(attReq);
        var attMetadata = (EnumAttributeMetadata)attResponse.AttributeMetadata;

        // Here attMetadata.OptionSet is null
        // Why ?
        Console.WriteLine(attMetadata.OptionSet.Options.Count);
    }
}

Here the complete program to reproduce :
Issue564Xrm.zip

Notice, that I have componenttype enum that is autogenerated...

Regards
Sybaris

@sybaris
Copy link
Author

sybaris commented Oct 24, 2024

Hi,

Any news ?

Regards
Sybaris

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

No branches or pull requests

1 participant