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

Automatic Registration in Pipeline Simulation expects SdkMessage, SdkMessageFilter, SdkMessageProcessingStep and PluginType when using early bound entities #95

Closed
jordimontana82 opened this issue Apr 17, 2023 · 6 comments

Comments

@jordimontana82
Copy link
Contributor

jordimontana82 commented Apr 17, 2023

Check if using early bound and if all of the above entities were generated along with other entities. If not, raise a dedicated exception as the current message is a bit broad and not specific: "Could not find reflected type for sdkmessage".

@jordimontana82 jordimontana82 added this to To do in Main Backlog via automation Apr 17, 2023
@jordimontana82 jordimontana82 changed the title Automatic Registration in Pipeline Simulation expects SdkMessage, SdkMessageFilter, SdkMessageProcessingStep and PluginType if using early bound entities Automatic Registration in Pipeline Simulation expects SdkMessage, SdkMessageFilter, SdkMessageProcessingStep and PluginType when using early bound entities Apr 17, 2023
@teppolainio
Copy link

Am I correct on assuming this requirement will be removed in future? It is kind of unintriguing that one needs to generate early bound classes for requirements by unit test mockup library.

@jordimontana82
Copy link
Contributor Author

Great feedback @teppolainio !

I think we could also ship pre-generated early bound classes for these types SdkMessage, SdkMessageFilter, and so on, and automatically resolve them if not found in an assembly that was explicitly generated.

How does that sound?

@jordimontana82
Copy link
Contributor Author

jordimontana82 commented Apr 21, 2023

Hypothesis: this might also happen if RegisterPluginStep is called after .Initialize or any other method that sets an Assembly with early bound types prior to RegisterPluginStep is called.

@teppolainio
Copy link

teppolainio commented Apr 23, 2023

@jordimontana82 I tested your hypothesesis and it seems to hold true.

It would be great if one wouldn't have to add early bound classes for boilerplate entities just for the sake of mockup library. Could you for example ship some sort of metadata factory which could create necessary metadata for entities sdkmessage, sdkmessagefilter, sdkmessageprocessingstep and plugintype when these aren't included into those entities necessary for plugins application logic to run? Then you could hint on exception message something like "Metadata for entities these-and-these is required when using early bound classes. Either add these to your generated early-bound classes or add necessary metadata to FakeXrmEasy using ThisAwesomeMetadataFactory.CreateSomeBoilerplateEntityMetadata()" etc.

Original run
On test base class constructor:
context.EnableProxyTypes(typeof(VeryInterestingPlugin).Assembly);

On test method on separate test class:
context.Initialize(IEnumerable<Entity> entities)
var step = new PluginStepDefinition() { ... }
context.RegisterPluginStep<VeryInterestingPlugin>(step);
-->
Test run fails with System.Exception : Couldnt find reflected type for sdkmessage.

Modified run number one
On test base class constructor:
context.EnableProxyTypes(typeof(VeryInterestingPlugin).Assembly);

On test method on separate test class:
var step = new PluginStepDefinition() { ... }
context.RegisterPluginStep<VeryInterestingPlugin>(step);
context.Initialize(IEnumerable<Entity> entities)
-->
Test run fails with System.Exception : Couldnt find reflected type for sdkmessage.

Modified run number two
On test base class constructor:
// context.EnableProxyTypes(typeof(VeryInterestingPlugin).Assembly);

On test method on separate test class:
var step = new PluginStepDefinition() { ... }
context.RegisterPluginStep<VeryInterestingPlugin>(step);
context.Initialize(IEnumerable<Entity> entities)
-->
Test succeeds (or actually failed due to NotImplementedException from plugin class i.e. just like it should).

@jordimontana82
Copy link
Contributor Author

I like that idea @teppolainio

BetimBeja added a commit to BetimBeja/dynamicsvalue-fake-xrm-easy-core that referenced this issue May 3, 2023
Main Backlog automation moved this from To do to Done May 17, 2023
@jordimontana82
Copy link
Contributor Author

@teppolainio This made it to this version: https://www.nuget.org/packages/FakeXrmEasy.Plugins.v9/2.3.2#release-body-tab

Slightly different approach in the end, it'll check if using early bound, and if so, search for all the needed types.

If all of them are present in the user-defined assembly, it'll use those.
If none of them are present, it'll include them automatically.
If some of them are present but not all, will raise an exception to make it clearer.

Should cover all possible scenarios.

jordimontana82 added a commit to DynamicsValue/fake-xrm-easy-plugins that referenced this issue Oct 14, 2023
…s to prevent DynamicsValue/fake-xrm-easy#95 after introducing secure configs in pipeline simulation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

2 participants