Replies: 7 comments 1 reply
-
@lamelyan First thing to do is check where those files were written to. The should be directly in your project root under /Internal/Generated. If not, there's an explicit config option to "force" the files to go to the right place. |
Beta Was this translation helpful? Give feedback.
-
@jeremydmiller yes, the files are pre-generated in my main project's /Internal/Generated folder. Here is a screenshot that shows the file that is not found by tests - BuyerProvider466321713. Test run throws exception: I found the spot where the error is thrown. In the screenshot, I've set the TypeLoadMode to Dynamic. I need to step through to see what exactly happens when it's Static. It looks like on line 109, the types are loaded (via AttachTypesSynchronously) and that fails. |
Beta Was this translation helpful? Give feedback.
-
Can you tell if the expected types are compile in? Are you committing the generated files? Is the type name mismatched? Your error is just “I cannot find the type I expected in the main application assembly”Sent from my iPhoneOn Dec 21, 2022, at 10:41 AM, Leo Amelyan ***@***.***> wrote:
@jeremydmiller yes, the files are pre-generated in my main project's /Internal/Generated folder. However, they are not found when tests are running.
I found the spot where the error is thrown. In the screenshot, I've set the TypeLoadMode to Dynamic. I need to step through to see what exactly happens when it's Static. It looks like on line 109, the types are loaded (via AttachTypesSynchronously) and they fail.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Oh, and one more thing, and this is annoying, but next do a |
Beta Was this translation helpful? Give feedback.
-
@lamelyan this is possibly because your entry assembly is the test-runner, and Marten is looking there for the generated code. There's an example in the docs where you can set the Application Assembly when it's not the entry assembly: using var host = Host.CreateDefaultBuilder()
.ConfigureServices(services =>
{
services.AddMarten(opts =>
{
opts.Connection("some connection string");
opts.SetApplicationProject(typeof(User).Assembly);
});
})
.StartAsync(); This fixed it for me, when I had a similar |
Beta Was this translation helpful? Give feedback.
-
No recent activity, I'm moving this to a discussion |
Beta Was this translation helpful? Give feedback.
-
@jeremydmiller Let me join this discussion with similar problem that I'm facing off.
How Marten is configured: var marten = services
.AddMarten(options =>
{
options.Connection(Config.Storage.MartenConnectionString(config));
options.RegisterDocumentType<BankingConsent>();
options.Projections.Add<ConsentDetailsProjection>(ProjectionLifecycle.Inline);
})
.OptimizeArtifactWorkflow(TypeLoadMode.Static, Local)
.UseLightweightSessions();
if (hostEnv.EnvironmentName != "Tests")
{
marten.ApplyAllDatabaseChangesOnStartup();
} Code gen output from CI Wrote generated code file to /Internal/Generated/DocumentStorage/BankingConsentProvider693486893.cs
Wrote generated code file to /Internal/Generated/DocumentStorage/ConsentDetailsProvider929434506.cs
Wrote generated code file to /Internal/Generated/DocumentStorage/DeadLetterEventProvider834684974.cs
Wrote generated code file to /Internal/Generated/EventStore/EventStorage.cs
Wrote generated code file to /Internal/Generated/EventStore/ConsentDetailsProjectionRuntimeSupport10411[29] I also run Trying to generate all code and compile, this might take a bit.
[green]Success![/]% I viewed assemblies and see that some types related to |
Beta Was this translation helpful? Give feedback.
-
I generate static files in my main project. That works fine. However, when I run integration tests, I get the following error
The Document Store options are set to:
It looks like integration tests can't find pre-built types that are in the main project.
How should the integration tests behave when testing a project that contains the pre-built types?
Beta Was this translation helpful? Give feedback.
All reactions