Giter Club home page Giter Club logo

ncqrs's Introduction

The Ncqrs Framework

Ncqrs is a framework for .NET helps build scalable, extensible and maintainable applications by supporting developers apply the Command Query Responsibility Segregation (CQRS) architectural pattern. It does so by providing an infrastructure and implementations for the most important building blocks for command handling, domain modeling, event sourcing, and so. These building blocks help you to focus on the code that adds business value. They come with annotation, convention and configuration support and help you to write isolated and testable.

Build locally

Run BUILD.bat to build the Ncqrs Framework. This will build the framework, run all the tests and updates all the lib folders of other solutions (extensions and sample) with the result.

Discussion and feedback

The best source for discussion is the ncqrs-dev group. You could also drop quick messages to us using twitter.

To submit a bug or make a feature request use github issues.

Contribution

Since the code base of Ncqrs will never be complete. We encourage users to fork Ncqrs code, make changes, commit them to your forked repository, and submit pull requests.

You can use our [Redmine environment] to find support our project management. Use it to submit a bug, request a feature and to see our roadmap.

Why does git show that all of my files are modified?

Ncqrs is built by Windows users, so all of the text files have CRLF line endings. These line endings are stored as-is in git (which means we all have autocrlf turned off). If you have autocrlf enabled, when you retrieve files from git, it will modify all of your files. Your best bet is to turn off autocrlf, and re-create your clone of Ncqrs.

  1. Delete your local clone of the Ncqrs repository
  2. Type: git config --global core.autocrlf false
  3. Type: git config --system core.autocrlf false
  4. Clone the Ncqrs repository again

License

The Ncqrs framework and its documentation are licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Bitdeli Badge

ncqrs's People

Contributors

628426 avatar ammachado avatar aph5 avatar arnisl avatar ashic avatar aweiker avatar bitdeli-chef avatar bradtwurst avatar cgallegu avatar chrisnicola avatar funkycodin avatar fzawada avatar jackliusr avatar jansaris avatar jasondentler avatar joelvh avatar larsw avatar leemhenson avatar matt-sullivan avatar mrtns avatar mynkow avatar pjvds avatar pwistrand avatar rvlieshout avatar sbiaudet avatar szymonpobiega avatar theboringcoder avatar tkryskiewicz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ncqrs's Issues

Applying EntitySourcedEvent should fail on duplicate EntityId

In one of my aggregates I was applying by incident and entiyEvent twice on the same agregate root. When applying I applied the event twice with the same entityId. This should cause an exception because my entities within this aggregate aren't unique anymore now.

So there should be implemented an exception for applying two entities with the same id on one aggragate instance. So the entities will have unique id's within the aggregate.

Unit tests make nunit (any testing framework) crash

The latest archive cannot be built (run release to see) it crashes while performing unit tests complaining:

Must use the rewriter when using Contract.Requires

I'd include a screenshot of the stack trace but I can't add attachments in here, you may have to run it yourself to see it.

The JsonEventFormatter is the 3rd item in the stack trace (constructor)

Unfortunately I can't copy-paste the text since it's in a graphical window and nunit-console doesn't properly output it's result file, it crashes completely.

If I can find the problem, I'll send you a pull request

Tests should fail when the context isn't accepted

When you forget to accept the context in your CommandExecutors the tests still succeed. They should throw an ContextNotAcceptedException or something like that so this is also caught when testing your domainScenario's.

Rename Denormalizer component to EventHandler

Hello,

First, I want to say that you guys have done a great job with the framework; you've saved me from writing my own! I've been reading through the documentation, source code and tutorials and I have just one comment.

I was wondering if it would be possible to rename the denormalization component of the framework to something a bit more generic. In other words, rename IDenormalizer to IEventHandler. The name IDenormalizer implies that the only kind of response to an event in your domain is to denormalize your domain to your read store, which is somewhat limiting.

In practice, I believe one could respond to an event in any number of ways. For example, one event handler could end a client's long-polling operation. So, one would have an event handler that could update your read store, and another event handler that will handle the client waiting for a response from the server.

I can do this with your framework, but it seems unnatural to handle a client's long-polling request in an IDenormalizer.

Please let me know if I've missed something.

Is NCQRS discontinued?

It seems at first sight it is a great effort to be used at applying DDD, CQRS & ES. However I dont like the fact that thirdparty libraries are outdated for more than 3 years (e.g. NServiceBus is version 2.1 and its current version is 5.1). I guess the framework would be easier to rescue than the extensions. I would like to know if there is someone getting steam into this project. Thanks

NSBSample gets an exception

Hi,

with the last version of NCQRS, the sample NSBSample doesn't launch anymore. I get an exception from the file EndpointConfig.cs in Client project:

Message says:
"Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information."

Can someone fix it please ?

Gui88

PS: package's version is ncqrs-ncqrs-Merged_Event_and_EventData_again-399-gac8116a.zip

Lambda expression for the command attribute

Hello,

I think it will be very useful and more flexible to define type and the method with lambda expression in the MapsToAggregateRootMethodAttribute attribute. Now the refactor is disgusting with strings.

Something similar: [MapsToAggregateRootMethod(Sample.Domain.Message, c => c.UpdateMessageText())]

Thank you!

pifta

Refactoring DependencyInjection

In ncqrs, NcqrsEnvironment class act as a ServiceLocator. Few implementation are made in extensions with some IOC frameworks like Autofac, Windsor, ..... This pattern is good and used in lot of projects.

I propose a refactoring to be more compatible with dotnet core. asp.net core and ef core. Using a abstract library called Microsoft.Extensions.DependencyInjection.
This library have extensions to used others containers like Autofac, StructureMap. Using this library avoid the need to maintain our own IOC library. So we can shutdown some ncqrs extensions.

What's your feeling ?

Solution in development branch incorrect for "Any CPU" configuration

The ncqrs framework solution is incorrect for the "Any CPU" configuration.

Currently, the project Ncqrs.EventBus.IntegrationTest will not be built in this configuration.

Here is the patch for the solution file to correct the issues

480c480,481
<       {DC0FB020-79D9-497E-8869-9508FCFA6537}.Debug|Any CPU.ActiveCfg = Debug|x86

---
>       {DC0FB020-79D9-497E-8869-9508FCFA6537}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
>       {DC0FB020-79D9-497E-8869-9508FCFA6537}.Debug|Any CPU.Build.0 = Debug|Any CPU
485c486,487
<       {DC0FB020-79D9-497E-8869-9508FCFA6537}.Release|Any CPU.ActiveCfg = Release|x86

---
>       {DC0FB020-79D9-497E-8869-9508FCFA6537}.Release|Any CPU.ActiveCfg = Release|Any CPU
>       {DC0FB020-79D9-497E-8869-9508FCFA6537}.Release|Any CPU.Build.0 = Release|Any CPU

here is the patch for the Ncqrs.EventBus.IntegrationTest.csproj project file

36a37,44
>   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
>     <PlatformTarget>AnyCPU</PlatformTarget>
>     <OutputPath>bin\Debug\</OutputPath>
>   </PropertyGroup>
>   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
>     <PlatformTarget>AnyCPU</PlatformTarget>
>     <OutputPath>bin\Release\</OutputPath>
>   </PropertyGroup>

Must declare the scalar variable "@initialVersion".

I was trying to execute a command to create a new AR.

From peeking at the log of MsSqlServerEventStore I think it was probably broken by a merge/refactor between pwistrand's fix for deadlocks - which introduces this new variable - and aweiker's refactoring/cleanup:
699b665#Framework/src/Ncqrs/Eventing/Storage/SQL/MsSqlServerEventStore.cs
9fdb026#Framework/src/Ncqrs/Eventing/Storage/SQL/MsSqlServerEventStore.cs

StackTrace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Ncqrs.Eventing.Storage.SQL.MsSqlServerEventStore.UpdateEventSourceVersion(Guid eventSourceId, Int64 newVersion, SqlTransaction transaction) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Eventing\Storage\SQL\MsSqlServerEventStore.cs:line 425
at Ncqrs.Eventing.Storage.SQL.MsSqlServerEventStore.StoreEventsFromSource(Guid eventSourceId, Int64 eventSourceVersion, IEnumerable1 events, SqlTransaction transaction) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Eventing\Storage\SQL\MsSqlServerEventStore.cs:line 530 at Ncqrs.Eventing.Storage.SQL.MsSqlServerEventStore.Store(UncommittedEventStream eventStream) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Eventing\Storage\SQL\MsSqlServerEventStore.cs:line 340 at Ncqrs.Domain.UnitOfWork.Accept() in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Domain\UnitOfWork.cs:line 91 at Ncqrs.Commanding.CommandExecution.Mapping.UoWMappedCommandExecutor.UoWMappedCommandExecutorCallbacks.ExecuteActionCreatingNewInstance(Func2 action) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\UoWMappedCommandExecutor.cs:line 49
at Ncqrs.Commanding.CommandExecution.Mapping.Attributes.MapsToAggregateRootConstructorAttributeHandler.<>c__DisplayClass3.b__2() in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\Attributes\MapsToAggregateRootConstructorAttributeHandler.cs:line 22
at Ncqrs.Commanding.CommandExecution.Mapping.Attributes.MapsToAggregateRootConstructorAttributeHandler.Map(MapsToAggregateRootConstructorAttribute attribute, ICommand command, IMappedCommandExecutor executor) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\Attributes\MapsToAggregateRootConstructorAttributeHandler.cs:line 31
at CallSite.Target(Closure , CallSite , Object , Object , ICommand , IMappedCommandExecutor )
at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid4[T0,T1,T2,T3](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at Ncqrs.Commanding.CommandExecution.Mapping.Attributes.AttributeBasedCommandMapper.Map(ICommand command, IMappedCommandExecutor executor) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\Attributes\AttributeBasedCommandMapper.cs:line 59
at Ncqrs.Commanding.CommandExecution.Mapping.UoWMappedCommandExecutor.ExecuteInContext(IUnitOfWorkContext context, ICommand command) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\UoWMappedCommandExecutor.cs:line 17
at Ncqrs.Commanding.CommandExecution.CommandExecutorBase1.Execute(TCommand command) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Commanding\CommandExecution\CommandExecutorBase.cs:line 53 at Ncqrs.Commanding.ServiceModel.CommandService.<>c__DisplayClass91.b__8(ICommand cmd) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Commanding\ServiceModel\CommandService.cs:line 74
at Ncqrs.Commanding.ServiceModel.CommandService.Execute(ICommand command) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Commanding\ServiceModel\CommandService.cs:line 56
at radiochart_driver.Program.Main() in D:\workspace\hg\radiochart\radiochart-driver\Program.cs:line 21
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Sql Deadlocks.

Sql deadlocks are back in the the current branch. Occurred after a pull from the master into the current dev branch. Also the cause for the initialVersion problem that is happening as the sql event store has been pulled from a previous version but the supporting files are for the deadlock fix.

NuGet Package Update

The NuGet package in the official NuGet repository appears to be out of date. It shows a last updated date of 1/7/2011. It would be great to be able to pull the latest stable release from NuGet.

I am working on a CQRS library based heavily on NCQRS that supports .NET 7, AOT, and Source Code Generators

I realize that NCQRS has not been updated in almost 7 years. So I decided to take it upon myself to re-engineer it. I am making it async by default, moving it to .NET 7, and enabling Source Code Generation so that it works with AOT (It already can process a command, trigger events, and call Event Handlers as native code in AOT, all in 5MB). I'm also working on Roslyn Code fixers / Code Analysis to enforce best practices (and the things that need to be done a certain way to work with Source Code Generation). It is signficantly faster as it completely avoids reflection in major parts of the software (i.e. each Command mapped via Mapping attributes, actually generates a new CommandExecutor that deals with the concrete classes, methods, and properties). I'm a long ways from done, but being able to process commands to event handlers is pretty good ๐Ÿ˜„ Here is the example output of the source code generator.

This:

[Handler<NameHandler>]
    [Handler<NameHandler2>]
    [Handler<AddressHandler>]
    [Handler<TargetCreatedHandler>]
    [Command<SetName, SetNameExecutor>]
    [Command<CorrectlyMappedCommand>] // Create
    [Command<UpdateFoo>] // Method call
    internal partial class MyBusTypeHandler : GeneratedTypeManager
    {
    }

turns into this at build time

 internal partial class MyBusTypeHandler : GeneratedTypeManager {
    private List<AggregateRoot> aggregateRoots = new ();
        public MyBusTypeHandler() {
            var handler0 = Create<Example.NameHandler>();
            var handler1 = Create<Example.NameHandler2>();
            AddHandlers<Example.Name>(new List<Func<PublishedEvent, Task>>
            {
                (evt) => { handler0.Handle((IPublishedEvent<Example.Name>)evt); return Task.CompletedTask; }, 
                (evt) => handler1.HandleAsync((IPublishedEvent<Example.Name>)evt)
            });
            var handler2 = Create<Example.AddressHandler>();
            AddHandlers<Example.Address>(new List<Func<PublishedEvent, Task>>
            {
                (evt) => { handler2.Handle((IPublishedEvent<Example.Address>)evt); return Task.CompletedTask; }
            });
            var handler5 = Create<Example.TargetCreatedHandler>();
            AddHandlers<Example.TargetCreated>(new List<Func<PublishedEvent, Task>>
            {
                (evt) => { handler5.Handle((IPublishedEvent<Example.TargetCreated>)evt); return Task.CompletedTask; }
            });
            var executor0 = Create<Example.SetNameExecutor>();
            AddCommandExecutor(typeof(Example.SetName), (cmd) => executor0.Execute((Example.SetName)cmd));
            var executor1 = MapperToCommandExecutor<CorrectlyMappedCommandMapper>();
            AddCommandExecutor(typeof(Example.CorrectlyMappedCommand), (cmd) => executor1.Execute((Example.CorrectlyMappedCommand)cmd));
            var executor2 = MapperToCommandExecutor<UpdateFooMapper>();
            AddCommandExecutor(typeof(Example.UpdateFoo), (cmd) => executor2.Execute((Example.UpdateFoo)cmd));
            AddAggregateRoot<Example.TargetAggRoot>(); // Is discovered from the command mappings
        }
        private Dictionary<Type, Func<IPublishableEvent, PublishedEvent>> publishers = new Dictionary<Type, Func<IPublishableEvent, PublishedEvent>> {
            [typeof(Example.Name)] = evt => new PublishedEvent<Example.Name>(evt),
            [typeof(Example.Address)] = evt => new PublishedEvent<Example.Address>(evt),
            [typeof(Example.TargetCreated)] = evt => new PublishedEvent<Example.TargetCreated>(evt)
        };
        public override PublishedEvent GetPublishedEvent(Type evtType, IPublishableEvent evt)
        {
            return publishers[evtType](evt);
        }
    }
    
    internal class CorrectlyMappedCommandMapper : AbstractAggregateMapper {
        public override async Task Map(ICommand command, IMappedCommandExecutor executor) {
           var commandType = typeof(Example.CorrectlyMappedCommand);
            AggregateRoot Create(ICommand c) {
                var actualCommand = c as Example.CorrectlyMappedCommand;
                return new Example.TargetAggRoot(actualCommand.Id, actualCommand.Foo, actualCommand.Bar);
           }
           var executorAction = () => {
               executor.ExecuteActionCreatingNewInstance(Create);
               return Task.CompletedTask;
           };
           await WrapInTransaction(commandType, executorAction);
        }
     }
    internal class UpdateFooMapper : AbstractAggregateMapper {
        public override async Task Map(ICommand command, IMappedCommandExecutor executor) {
           var commandType = typeof(Example.UpdateFoo);
           void Run(AggregateRoot agg, ICommand c) {
                var actualCommand = c as Example.UpdateFoo;
                var actualAggregate = agg as Example.TargetAggRoot;
                actualAggregate.UpdateFoo(actualCommand.Foo);
           }
           Guid GetAggregateRootId(ICommand cmd) { return (cmd as Example.UpdateFoo).AggregateRootId; }
           var executorAction = () =>
           {
               executor.ExecuteActionOnExistingInstance(GetAggregateRootId, (cmd) => typeof(Example.TargetAggRoot), Run);
               return Task.CompletedTask;
           };
           await WrapInTransaction(commandType, executorAction);
        }
     }
}

Missing dependency (StructureMap)

In the "MyNotes" sample the "CommandService" project references StructureMap which isn't in the expected lib.

"StructureMap, Version=2.6.1.0, Culture=neutral, PublicKeyToken=e60ad81abae3c223, processorArchitecture=MSIL"
HintPath ....\lib\Ncqrs.Config.StructureMap\StructureMap.dll

"Ncqrs.Config.StructureMap, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"
HintPath ....\lib\Ncqrs.Config.StructureMap\Ncqrs.Config.StructureMap.dll

Could not build from master branch

  1. Forked repo.
  2. Intalled Code Contracts
  3. Opened NcqrsFramework.sln solution in VS2010
  4. Build

Finished up with errors. Seems like Code Contacts issues (could not diagnose deeply since lack CC expertise)

NcqrsFramework.sln

------ Build started: Project: Ncqrs, Configuration: Debug Any CPU ------
EXEC : error CC1019: Type 'Ncqrs.Eventing.IEvent' specifies the class 'Ncqrs.Eventing.IEventContracts' as its contract class, but that class does not point back to this type.
EXEC : error CC1019: Type 'Ncqrs.Eventing.Sourcing.ISourcedEventHandler' specifies the class 'Ncqrs.Eventing.Sourcing.IEventSourcedHandlerContracts' as its contract class, but that class does not point back to this type.
d:\Development\Projects\ncqrs\Framework\src\Ncqrs\Eventing\Sourcing\TypeThresholdedActionBasedSourcedEventHandler.cs(71,13): warning CC1033: Method 'Ncqrs.Eventing.Sourcing.TypeThresholdedActionBasedDomainEventHandler.HandleEvent(Ncqrs.Eventing.Sourcing.ISourcedEvent)' implements interface method 'Ncqrs.Eventing.Sourcing.ISourcedEventHandler.HandleEvent(Ncqrs.Eventing.Sourcing.ISourcedEvent)', thus cannot add Requires.
EXEC : error CC1019: Type 'Ncqrs.Eventing.Storage.IEventStore' specifies the class 'Ncqrs.Eventing.Storage.IEventStoreContracts' as its contract class, but that class does not point back to this type.
EXEC : error CC1019: Type 'Ncqrs.Eventing.Storage.ISnapshotStore' specifies the class 'Ncqrs.Eventing.Storage.ISnapshotStoreContracts' as its contract class, but that class does not point back to this type.
EXEC : error CC1019: Type 'Ncqrs.Commanding.CommandExecution.ICommandExecutor1' specifies the class 'Ncqrs.Commanding.CommandExecution.ICommandExecutorContracts1' as its contract class, but that class does not point back to this type.
EXEC : error CC1019: Type 'Ncqrs.Commanding.CommandExecution.Mapping.Attributes.CommandMappingAttribute' specifies the class 'Ncqrs.Commanding.CommandExecution.Mapping.Attributes.CommandMappingAttributeContracts' as its contract class, but that class does not point back to this type.
d:\Development\Projects\ncqrs\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\Fluent\MappedCommandToAggregateRoot.cs(42,13): warning CC1032: Method 'Ncqrs.Commanding.CommandExecution.Mapping.Fluent.MappedCommandToAggregateRoot2.Execute(type parameter.TCommand)' overrides 'Ncqrs.Commanding.CommandExecution.Mapping.Fluent.MappedCommandToAggregateRoot1.Execute(type parameter.TCommand)', thus cannot add Requires.
d:\Development\Projects\ncqrs\Framework\src\Ncqrs\Commanding\CommandExecution\ICommandExecutor.cs(26,13): warning CC1033: Method 'Ncqrs.Commanding.CommandExecution.ICommandExecutorContracts1.Execute(type parameter.TCommand)' implements interface method 'Ncqrs.Commanding.CommandExecution.ICommandExecutor1.Execute(type parameter.TCommand)', thus cannot add Requires.
EXEC : error CC1019: Type 'Ncqrs.IClock' specifies the class 'Ncqrs.IClockContracts' as its contract class, but that class does not point back to this type.
d:\Development\Projects\ncqrs\Framework\src\Ncqrs\Eventing\Sourcing\EventSource.cs(112,13): warning CC1033: Method 'Ncqrs.Eventing.Sourcing.EventSource.InitializeFromHistory(System.Collections.Generic.IEnumerable1<Ncqrs.Eventing.Sourcing.ISourcedEvent>)' implements interface method 'Ncqrs.Eventing.Sourcing.IEventSource.InitializeFromHistory(System.Collections.Generic.IEnumerable1<Ncqrs.Eventing.Sourcing.ISourcedEvent>)', thus cannot add Requires.
d:\Development\Projects\ncqrs\Framework\src\Ncqrs\Eventing\Sourcing\Mapping\ExpressionBasedEventHandlerMappingStrategy.cs(43,13): warning CC1033: Method 'Ncqrs.Eventing.Sourcing.Mapping.ExpressionBasedEventHandlerMappingStrategy.GetEventHandlers(System.Object)' implements interface method 'Ncqrs.Eventing.Sourcing.Mapping.IEventHandlerMappingStrategy.GetEventHandlers(System.Object)', thus cannot add Requires.
d:\Development\Projects\ncqrs\Framework\src\Ncqrs\Eventing\Sourcing\ISourcedEventHandler.cs(27,13): warning CC1033: Method 'Ncqrs.Eventing.Sourcing.IEventSourcedHandlerContracts.HandleEvent(Ncqrs.Eventing.Sourcing.ISourcedEvent)' implements interface method 'Ncqrs.Eventing.Sourcing.ISourcedEventHandler.HandleEvent(Ncqrs.Eventing.Sourcing.ISourcedEvent)', thus cannot add Requires.
EXEC : error CC1019: Type 'Ncqrs.Eventing.Sourcing.Snapshotting.ISnapshotable1' specifies the class 'Ncqrs.Eventing.Sourcing.Snapshotting.SnapshotableContracts1' as its contract class, but that class does not point back to this type.
EXEC : error CC1019: Type 'Ncqrs.Eventing.Storage.IEventTypeResolver' specifies the class 'Ncqrs.Eventing.Storage.IEventTypeResolverContracts' as its contract class, but that class does not point back to this type.
d:\Development\Projects\ncqrs\Framework\src\Ncqrs\Eventing\Storage\ISnapshotStore.cs(26,13): warning CC1033: Method 'Ncqrs.Eventing.Storage.ISnapshotStoreContracts.SaveShapshot(Ncqrs.Eventing.Sourcing.Snapshotting.ISnapshot)' implements interface method 'Ncqrs.Eventing.Storage.ISnapshotStore.SaveShapshot(Ncqrs.Eventing.Sourcing.Snapshotting.ISnapshot)', thus cannot add Requires.
EXEC : error CC1019: Type 'Ncqrs.Eventing.Storage.Serialization.IEventConverter' specifies the class 'Ncqrs.Eventing.Storage.Serialization.IEventConverterContracts' as its contract class, but that class does not point back to this type.
d:\Development\Projects\ncqrs\Framework\src\Ncqrs\Eventing\Storage\Serialization\IEventConverter.cs(44,13): warning CC1033: Method 'Ncqrs.Eventing.Storage.Serialization.IEventConverterContracts.Upgrade(Ncqrs.Eventing.Storage.StoredEvent1<Newtonsoft.Json.Linq.JObject>)' implements interface method 'Ncqrs.Eventing.Storage.Serialization.IEventConverter.Upgrade(Ncqrs.Eventing.Storage.StoredEvent1<Newtonsoft.Json.Linq.JObject>)', thus cannot add Requires.
EXEC : error CC1019: Type 'Ncqrs.Eventing.Storage.Serialization.IEventFormatter1' specifies the class 'Ncqrs.Eventing.Storage.Serialization.IEventFormatterContracts1' as its contract class, but that class does not point back to this type.
EXEC : error CC1019: Type 'Ncqrs.Eventing.Storage.Serialization.IEventTranslator1' specifies the class 'Ncqrs.Eventing.Storage.Serialization.IEventTranslatorContracts1' as its contract class, but that class does not point back to this type.
d:\Development\Projects\ncqrs\Framework\src\Ncqrs\Eventing\Storage\Serialization\IEventTranslator.cs(37,13): warning CC1033: Method 'Ncqrs.Eventing.Storage.Serialization.IEventTranslatorContracts1.TranslateToCommon(Ncqrs.Eventing.Storage.StoredEvent1)' implements interface method 'Ncqrs.Eventing.Storage.Serialization.IEventTranslator1<type parameter.T>.TranslateToCommon(Ncqrs.Eventing.Storage.StoredEvent1)', thus cannot add Requires.
d:\Development\Projects\ncqrs\Framework\src\Ncqrs\Eventing\Storage\Serialization\IEventTranslator.cs(44,13): warning CC1033: Method 'Ncqrs.Eventing.Storage.Serialization.IEventTranslatorContracts1.TranslateToRaw(Ncqrs.Eventing.Storage.StoredEvent1<Newtonsoft.Json.Linq.JObject>)' implements interface method 'Ncqrs.Eventing.Storage.Serialization.IEventTranslator1<type parameter.T>.TranslateToRaw(Ncqrs.Eventing.Storage.StoredEvent1<Newtonsoft.Json.Linq.JObject>)', thus cannot add Requires.
d:\Development\Projects\ncqrs\Framework\src\Ncqrs\Eventing\Storage\Serialization\IEventFormatter.cs(46,13): warning CC1033: Method 'Ncqrs.Eventing.Storage.Serialization.IEventFormatterContracts1.Serialize(Ncqrs.Eventing.Sourcing.ISourcedEvent)' implements interface method 'Ncqrs.Eventing.Storage.Serialization.IEventFormatter1.Serialize(Ncqrs.Eventing.Sourcing.ISourcedEvent)',thus cannot add Requires.
d:\Development\Projects\ncqrs\Framework\src\Ncqrs\Eventing\Storage\Serialization\IEventFormatter.cs(53,13): warning CC1033: Method 'Ncqrs.Eventing.Storage.Serialization.IEventFormatterContracts1.Deserialize(Ncqrs.Eventing.Storage.StoredEvent1)' implements interface method 'Ncqrs.Eventing.Storage.Serialization.IEventFormatter1<type parameter.T>.Deserialize(Ncqrs.Eventing.Storage.StoredEvent1)', thus cannot add Requires.
EXEC : error CC1019: Type 'Ncqrs.Config.IEnvironmentConfiguration' specifies the class 'Ncqrs.Config.IEnvironmentConfigurationContracts' as its contract class, but that class does not point back to this type.
d:\Development\Projects\ncqrs\Framework\src\Ncqrs\Eventing\Sourcing\Mapping\AttributeBasedEventHandlerMappingStrategy.cs(40,13): warning CC1033: Method 'Ncqrs.Eventing.Sourcing.Mapping.AttributeBasedEventHandlerMappingStrategy.GetEventHandlers(System.Object)' implements interface method 'Ncqrs.Eventing.Sourcing.Mapping.IEventHandlerMappingStrategy.GetEventHandlers(System.Object)', thus cannot add Requires.
d:\Development\Projects\ncqrs\Framework\src\Ncqrs\Eventing\Sourcing\Mapping\ConventionBasedEventHandlerMappingStrategy.cs(40,13): warning CC1033: Method 'Ncqrs.Eventing.Sourcing.Mapping.ConventionBasedEventHandlerMappingStrategy.GetEventHandlers(System.Object)' implements interface method 'Ncqrs.Eventing.Sourcing.Mapping.IEventHandlerMappingStrategy.GetEventHandlers(System.Object)', thus cannot add Requires.
EXEC : error CC1019: Type 'Ncqrs.Domain.Storage.IDomainRepository' specifies the class 'Ncqrs.Domain.Storage.IDomainRepositoryContracts' as its contract class, but that class does not point back to this type.
d:\Development\Projects\ncqrs\Framework\src\Ncqrs\Domain\Storage\IDomainRepository.cs(40,13): warning CC1033: Method 'Ncqrs.Domain.Storage.IDomainRepositoryContracts.GetById(System.Type,System.Guid)' implements interface method 'Ncqrs.Domain.Storage.IDomainRepository.GetById(System.Type,System.Guid)', thus cannot add Requires.
d:\Development\Projects\ncqrs\Framework\src\Ncqrs\Domain\Storage\IDomainRepository.cs(52,13): warning CC1033: Method 'Ncqrs.Domain.Storage.IDomainRepositoryContracts.Save(Ncqrs.Domain.AggregateRoot)' implements interface method 'Ncqrs.Domain.Storage.IDomainRepository.Save(Ncqrs.Domain.AggregateRoot)', thus cannot add Requires.
d:\Development\Projects\ncqrs\Framework\src\Ncqrs\Domain\UnitOfWork.cs(194,13): warning CC1033: Method 'Ncqrs.Domain.UnitOfWork.Accept' implements interface method 'Ncqrs.Domain.IUnitOfWorkContext.Accept', thus cannot add Requires.
d:\Development\Projects\ncqrs\Framework\src\Ncqrs\Eventing\Storage\IEventStore.cs(54,13): warning CC1033: Method 'Ncqrs.Eventing.Storage.IEventStoreContracts.Save(Ncqrs.Eventing.Sourcing.IEventSource)' implements interface method 'Ncqrs.Eventing.Storage.IEventStore.Save(Ncqrs.Eventing.Sourcing.IEventSource)', thus cannot add Requires.
elapsed time: 711,0407ms
C:\Program Files\Microsoft\Contracts\MsBuild\v4.0\Microsoft.CodeContracts.targets(231,5): error MSB3073: The command ""C:\Program Files\Microsoft\Contracts\Bin\ccrewrite" "@Ncqrsccrewrite.rsp"" exited with code 14.
------ Build started: Project: Ncqrs.Tests, Configuration: Debug Any CPU ------
EnsureContractReferenceAssemblies: D:\Development\Projects\ncqrs\Framework\src\Ncqrs\bin\Debug\Ncqrs.dll
Ncqrs.Tests -> D:\Development\Projects\ncqrs\Framework\src\Ncqrs.Tests\bin\Debug\Ncqrs.Tests.dll
------ Build started: Project: Ncqrs.Spec, Configuration: Debug Any CPU ------
Ncqrs.Spec -> D:\Development\Projects\ncqrs\Framework\src\Ncqrs.Spec\bin\Debug\Ncqrs.Spec.dll
========== Build: 2 succeeded or up-to-date, 1 failed, 0 skipped ==========

InprocessEventBus.RegisterAllDenormalizersInAssembly crash

InprocessEventBus.RegisterAllDenormalizersInAssembly crashes when the ReadModels (EF code first) are in a subnamespace.

For example:

Website.ReadModels.Denormalizers
- SomeReadmodelDenormalizer
- SomeOtherReadmodelDenormalizer
- SomeReadmodelDenormalizer2
- SomeOtherReadmodelDenormalizer2
Website.ReadModels
- SomeReadmodel --> Goes ok when bootstrapping the denormalizer
- SomeOtherReadModel --> Goes ok when bootstrapping the denormalizer
Website.ReadModels.SomesubNamespace
- SomeReadmodel2 --> Crashes
- Someotherreadmodel2 --> Crashes

Providing wrong AggregateRootId gives confusing exception (Non-Static method requires a target)

When you call a command with wrong AggregateRootId (I mean doesn't exists in the EventSource database), an exception of System.Reflection.TargetException occures.
Here is the problem :
Stack trace
at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Ncqrs.Commanding.CommandExecution.Mapping.Attributes.MapsToAggregateRootMethodAttributeHandler.<>c__DisplayClass3.b__0(AggregateRoot agg, ICommand cmd) in C:\Projects\ncqrs-ncqrs-ed26668\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\Attributes\MapsToAggregateRootMethodAttributeHandler.cs:line 21
at Ncqrs.Commanding.CommandExecution.Mapping.UoWMappedCommandExecutor.UoWMappedCommandExecutorCallbacks.ExecuteActionOnExistingInstance(Func2 idCallback, Func2 typeCallback, Action2 action) in C:\Projects\ncqrs-ncqrs-ed26668\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\UoWMappedCommandExecutor.cs:line 37 at Ncqrs.Commanding.CommandExecution.Mapping.Attributes.MapsToAggregateRootMethodAttributeHandler.<>c__DisplayClass3.<Map>b__2() in C:\Projects\ncqrs-ncqrs-ed26668\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\Attributes\MapsToAggregateRootMethodAttributeHandler.cs:line 24 at Ncqrs.Commanding.CommandExecution.Mapping.Attributes.MapsToAggregateRootMethodAttributeHandler.Map(MapsToAggregateRootMethodAttribute attribute, ICommand command, IMappedCommandExecutor executor) in C:\Projects\ncqrs-ncqrs-ed26668\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\Attributes\MapsToAggregateRootMethodAttributeHandler.cs:line 33 at CallSite.Target(Closure , CallSite , Object , Object , ICommand , IMappedCommandExecutor ) at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid4[T0,T1,T2,T3](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at Ncqrs.Commanding.CommandExecution.Mapping.Attributes.AttributeBasedCommandMapper.Map(ICommand command, IMappedCommandExecutor executor) in C:\Projects\ncqrs-ncqrs-ed26668\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\Attributes\AttributeBasedCommandMapper.cs:line 59 at Ncqrs.Commanding.CommandExecution.Mapping.UoWMappedCommandExecutor.ExecuteInContext(IUnitOfWorkContext context, ICommand command) in C:\Projects\ncqrs-ncqrs-ed26668\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\UoWMappedCommandExecutor.cs:line 17 at Ncqrs.Commanding.CommandExecution.CommandExecutorBase1.Execute(TCommand command) in C:\Projects\ncqrs-ncqrs-ed26668\Framework\src\Ncqrs\Commanding\CommandExecution\CommandExecutorBase.cs:line 53
at Ncqrs.NServiceBus.NsbCommandService.b__0(ICommand x)
at Ncqrs.Commanding.ServiceModel.CommandService.Execute(ICommand command) in C:\Projects\ncqrs-ncqrs-ed26668\Framework\src\Ncqrs\Commanding\ServiceModel\CommandService.cs:line 63
at Ncqrs.NServiceBus.NcqrsMessageHandler.Handle(CommandMessage message)

The problem begins in UoWMappedCommandExecutor class in the method (ExecuteActionOnExistingInstance)
in the following line:
var aggRoot = _uow.GetById(type, id, _command.KnownVersion);

aggrRoot is null !! because the id passed value is wrong
so the next line :
action(aggRoot, _command)
will fail.

it tooks me one hour to find out what the problem is.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.