diff --git a/build/build.props b/build/build.props index 6801366..ee9bb34 100644 --- a/build/build.props +++ b/build/build.props @@ -6,7 +6,7 @@ LICENSE.txt https://github.com/jspuij/Cortex.Net true - 0.3.1 + 0.4.0 en-US diff --git a/docs/pages/changelog.md b/docs/pages/changelog.md index 8b23bb6..c037a88 100644 --- a/docs/pages/changelog.md +++ b/docs/pages/changelog.md @@ -2,6 +2,11 @@ The changelog is found below: +## 0.4.0 + +* Upgrade some dependencies. +* Fix for https://github.com/jspuij/Cortex.Net/issues/42. + ## 0.3.1 * Upgrade to Blazor final 3.2.0 diff --git a/samples/Cortex.Net.BlazorTodo/Cortex.Net.BlazorTodo.csproj b/samples/Cortex.Net.BlazorTodo/Cortex.Net.BlazorTodo.csproj index f2456e8..76017de 100644 --- a/samples/Cortex.Net.BlazorTodo/Cortex.Net.BlazorTodo.csproj +++ b/samples/Cortex.Net.BlazorTodo/Cortex.Net.BlazorTodo.csproj @@ -19,15 +19,15 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/samples/FlightFinder.Client/FlightFinder.Client.csproj b/samples/FlightFinder.Client/FlightFinder.Client.csproj index ccc023d..03af290 100644 --- a/samples/FlightFinder.Client/FlightFinder.Client.csproj +++ b/samples/FlightFinder.Client/FlightFinder.Client.csproj @@ -19,14 +19,14 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/samples/FlightFinder.Client/Program.cs b/samples/FlightFinder.Client/Program.cs index c9671ce..9fbed1b 100644 --- a/samples/FlightFinder.Client/Program.cs +++ b/samples/FlightFinder.Client/Program.cs @@ -26,7 +26,9 @@ namespace FlightFinder.Client /// /// The program class. Bootstraps the WASM application. /// +#pragma warning disable RCS1102 // Make class static. public class Program +#pragma warning restore RCS1102 // Make class static. { /// /// Main entry point for the WASM application. diff --git a/samples/FlightFinder.Server/FlightFinder.Server.csproj b/samples/FlightFinder.Server/FlightFinder.Server.csproj index bbc076a..25572fe 100644 --- a/samples/FlightFinder.Server/FlightFinder.Server.csproj +++ b/samples/FlightFinder.Server/FlightFinder.Server.csproj @@ -19,7 +19,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/samples/FlightFinder.Shared/FlightFinder.Shared.csproj b/samples/FlightFinder.Shared/FlightFinder.Shared.csproj index eb16c58..92ac1bc 100644 --- a/samples/FlightFinder.Shared/FlightFinder.Shared.csproj +++ b/samples/FlightFinder.Shared/FlightFinder.Shared.csproj @@ -27,7 +27,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Cortex.Net.Blazor/Cortex.Net.Blazor.csproj b/src/Cortex.Net.Blazor/Cortex.Net.Blazor.csproj index a99edfc..b10ba2d 100644 --- a/src/Cortex.Net.Blazor/Cortex.Net.Blazor.csproj +++ b/src/Cortex.Net.Blazor/Cortex.Net.Blazor.csproj @@ -19,9 +19,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Cortex.Net.Blazor/ObserverObject.cs b/src/Cortex.Net.Blazor/ObserverObject.cs index a94b563..d97fd92 100644 --- a/src/Cortex.Net.Blazor/ObserverObject.cs +++ b/src/Cortex.Net.Blazor/ObserverObject.cs @@ -57,12 +57,12 @@ public sealed class ObserverObject : IDisposable /// /// The next fragment Id. /// - private int nextFragmentId = 0; + private int nextFragmentId; /// /// Gets the current RenderFragment. /// - private RenderFragment current = null; + private RenderFragment current; /// /// Initializes a new instance of the class. diff --git a/src/Cortex.Net.DynamicData/Cortex.Net.DynamicData.csproj b/src/Cortex.Net.DynamicData/Cortex.Net.DynamicData.csproj index 14b91a1..e73ba65 100644 --- a/src/Cortex.Net.DynamicData/Cortex.Net.DynamicData.csproj +++ b/src/Cortex.Net.DynamicData/Cortex.Net.DynamicData.csproj @@ -20,8 +20,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Cortex.Net.Fody/ActionWeaver.cs b/src/Cortex.Net.Fody/ActionWeaver.cs index e7c940b..22c82f5 100644 --- a/src/Cortex.Net.Fody/ActionWeaver.cs +++ b/src/Cortex.Net.Fody/ActionWeaver.cs @@ -305,15 +305,18 @@ private void WeaveMethod(MethodDefinition methodDefinition) // push IL code for initialization of action members to the queue to emit in the ISharedState setter. this.processorQueue.SharedStateAssignmentQueue.Enqueue( - (declaringType, - false, - (processor, sharedStateBackingField) => this.EmitSharedStateSetter( + new SharedAssignmentQueueEntry + { + ReactiveObjectTypeDefinition = declaringType, + AddInjectAttribute = false, + ProcessorAction = (processor, sharedStateBackingField) => this.EmitSharedStateSetter( processor, sharedStateBackingField, methodDefinition, actionName, actionType, - actionFieldDefinition))); + actionFieldDefinition), + }); // extend the action method body. ExtendActionMethodBody(methodDefinition, actionType, entranceCounterDefinition, actionFieldDefinition); @@ -349,31 +352,37 @@ private void WeaveAsyncMethod(MethodDefinition methodDefinition) // push IL code for initialization of action members to the queue to emit in the ISharedState setter. this.processorQueue.SharedStateAssignmentQueue.Enqueue( - (stateMachineType, - false, - (processor, sharedStateBackingField) => - { - stateMachineSharedStateBackingField = sharedStateBackingField; - if (declaringTypeSharedStateBackingField != null) + new SharedAssignmentQueueEntry + { + ReactiveObjectTypeDefinition = stateMachineType, + AddInjectAttribute = false, + ProcessorAction = (processor, sharedStateBackingField) => { - this.ExtendMoveNextMethodBody(moveNextMethod, methodDefinition, stateMachineSharedStateBackingField); - this.ExtendAsyncMethodBody(methodDefinition, declaringTypeSharedStateBackingField, innerType); - } - })); + stateMachineSharedStateBackingField = sharedStateBackingField; + if (declaringTypeSharedStateBackingField != null) + { + this.ExtendMoveNextMethodBody(moveNextMethod, methodDefinition, stateMachineSharedStateBackingField); + this.ExtendAsyncMethodBody(methodDefinition, declaringTypeSharedStateBackingField, innerType); + } + }, + }); // push IL code for initialization of IShared State of inner struct / class for async. this.processorQueue.SharedStateAssignmentQueue.Enqueue( - (declaringType, - false, - (processor, sharedStateBackingField) => - { - declaringTypeSharedStateBackingField = sharedStateBackingField; - if (stateMachineSharedStateBackingField != null) + new SharedAssignmentQueueEntry + { + ReactiveObjectTypeDefinition = declaringType, + AddInjectAttribute = false, + ProcessorAction = (processor, sharedStateBackingField) => { - this.ExtendMoveNextMethodBody(moveNextMethod, methodDefinition, stateMachineSharedStateBackingField); - this.ExtendAsyncMethodBody(methodDefinition, declaringTypeSharedStateBackingField, innerType); - } - })); + declaringTypeSharedStateBackingField = sharedStateBackingField; + if (stateMachineSharedStateBackingField != null) + { + this.ExtendMoveNextMethodBody(moveNextMethod, methodDefinition, stateMachineSharedStateBackingField); + this.ExtendAsyncMethodBody(methodDefinition, declaringTypeSharedStateBackingField, innerType); + } + }, + }); } /// diff --git a/src/Cortex.Net.Fody/BlazorObserverWeaver.cs b/src/Cortex.Net.Fody/BlazorObserverWeaver.cs index 53d42a3..2e7a439 100644 --- a/src/Cortex.Net.Fody/BlazorObserverWeaver.cs +++ b/src/Cortex.Net.Fody/BlazorObserverWeaver.cs @@ -148,12 +148,18 @@ private void WeaveClass(TypeDefinition decoratedClass) } } - this.processorQueue.SharedStateAssignmentQueue.Enqueue((decoratedClass, true, (processor, sharedStateBackingField) => this.EmitObserverObjectInit( - processor, - observerName, - innerObserverObjectField, - buildRenderTreeMethod, - stateHasChangedMethod))); + this.processorQueue.SharedStateAssignmentQueue.Enqueue( + new SharedAssignmentQueueEntry + { + ReactiveObjectTypeDefinition = decoratedClass, + AddInjectAttribute = true, + ProcessorAction = (processor, sharedStateBackingField) => this.EmitObserverObjectInit( + processor, + observerName, + innerObserverObjectField, + buildRenderTreeMethod, + stateHasChangedMethod), + }); // add entrance counter field. var entranceCounterDefinition = decoratedType.CreateField(module.TypeSystem.Int32, $"{InnerCounterFieldPrefix}BuildRenderTree_EntranceCount", this.weavingContext, FieldAttributes.Private); diff --git a/src/Cortex.Net.Fody/ComputedWeaver.cs b/src/Cortex.Net.Fody/ComputedWeaver.cs index 4b9276b..24d07e6 100644 --- a/src/Cortex.Net.Fody/ComputedWeaver.cs +++ b/src/Cortex.Net.Fody/ComputedWeaver.cs @@ -53,15 +53,15 @@ public ComputedWeaver(ModuleWeaver parentWeaver, ISharedStateAssignmentILProcess internal void Execute() { var decoratedProperties = from t in this.ParentWeaver.ModuleDefinition.GetTypes() - from m in t.Properties - where - t != null && - t.IsClass && - t.BaseType != null && - m != null && - m.CustomAttributes != null && - m.CustomAttributes.Any(x => x.AttributeType.FullName == this.WeavingContext.CortexNetApiComputedAttribute.FullName) - select m; + from m in t.Properties + where + t != null && + t.IsClass && + t.BaseType != null && + m != null && + m.CustomAttributes != null && + m.CustomAttributes.Any(x => x.AttributeType.FullName == this.WeavingContext.CortexNetApiComputedAttribute.FullName) + select m; foreach (var decoratedProperty in decoratedProperties.ToList()) { @@ -144,17 +144,20 @@ private void WeaveProperty(PropertyDefinition propertyDefinition) // push IL code for initialization of a computed member to the queue to emit in the ISharedState setter. this.ProcessorQueue.SharedStateAssignmentQueue.Enqueue( - (declaringType, - false, - (processor, sharedStateBackingField) => this.EmitComputedMemberAdd( - processor, - computedName, - methodDefinition, - propertyDefinition.SetMethod, - equalityComparerType, - requiresReaction, - keepAlive, - observableObjectField))); + new SharedAssignmentQueueEntry + { + ReactiveObjectTypeDefinition = declaringType, + AddInjectAttribute = false, + ProcessorAction = (processor, sharedStateBackingField) => this.EmitComputedMemberAdd( + processor, + computedName, + methodDefinition, + propertyDefinition.SetMethod, + equalityComparerType, + requiresReaction, + keepAlive, + observableObjectField), + }); var fieldAttributes = FieldAttributes.Private; if (methodDefinition.IsStatic) @@ -312,17 +315,20 @@ private void WeaveMethod(MethodDefinition methodDefinition) // push IL code for initialization of a computed member to the queue to emit in the ISharedState setter. this.ProcessorQueue.SharedStateAssignmentQueue.Enqueue( - (declaringType, - false, - (processor, sharedStateBackingField) => this.EmitComputedMemberAdd( - processor, - computedName, - methodDefinition, - null, - equalityComparerType, - requiresReaction, - keepAlive, - observableObjectField))); + new SharedAssignmentQueueEntry + { + ReactiveObjectTypeDefinition = declaringType, + AddInjectAttribute = false, + ProcessorAction = (processor, sharedStateBackingField) => this.EmitComputedMemberAdd( + processor, + computedName, + methodDefinition, + null, + equalityComparerType, + requiresReaction, + keepAlive, + observableObjectField), + }); var fieldAttributes = FieldAttributes.Private; if (methodDefinition.IsStatic) @@ -354,14 +360,17 @@ private FieldDefinition CreateObservableObjectField(TypeDefinition declaringType // push IL code for initialization of observableObject to the queue to emit in the ISharedState setter. this.ProcessorQueue.SharedStateAssignmentQueue.Enqueue( - (declaringType, - false, - (processor, sharedStateBackingField) => this.EmitObservableObjectInit( + new SharedAssignmentQueueEntry + { + ReactiveObjectTypeDefinition = declaringType, + AddInjectAttribute = false, + ProcessorAction = (processor, sharedStateBackingField) => this.EmitObservableObjectInit( processor, declaringType.Name, defaultEhancerType, sharedStateBackingField, - observableObjectField))); + observableObjectField), + }); } return observableObjectField; diff --git a/src/Cortex.Net.Fody/Cortex.Net.Fody.csproj b/src/Cortex.Net.Fody/Cortex.Net.Fody.csproj index f0a74e4..3431ea8 100644 --- a/src/Cortex.Net.Fody/Cortex.Net.Fody.csproj +++ b/src/Cortex.Net.Fody/Cortex.Net.Fody.csproj @@ -19,8 +19,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Cortex.Net.Fody/Cortex.Net.Fody.xml b/src/Cortex.Net.Fody/Cortex.Net.Fody.xml index dcba902..190a1e3 100644 --- a/src/Cortex.Net.Fody/Cortex.Net.Fody.xml +++ b/src/Cortex.Net.Fody/Cortex.Net.Fody.xml @@ -724,6 +724,26 @@ The backing field for the ISharedState" instance. A reference to the new private setter. + + + An entry in the Shared Assignment Queue. + + + + + Gets or sets type Definition of the Reactive Object. + + + + + Gets or sets a value indicating whether to add InjectAttribute. + + + + + Gets or sets the processor action. + + Extension methods for instances. diff --git a/src/Cortex.Net.Fody/EnumerableInterfaceWeaver.cs b/src/Cortex.Net.Fody/EnumerableInterfaceWeaver.cs index 4df081d..bf91115 100644 --- a/src/Cortex.Net.Fody/EnumerableInterfaceWeaver.cs +++ b/src/Cortex.Net.Fody/EnumerableInterfaceWeaver.cs @@ -180,15 +180,18 @@ private void ReassignEnumerable(PropertyDefinition propertyDefinition, TypeRefer // push IL code for initialization of a property to the queue to emit in the ISharedState setter. this.processorQueue.SharedStateAssignmentQueue.Enqueue( - (declaringType, - false, - (processor, sharedStateBackingField) => this.EmitObservableEnumerableCreation( + new SharedAssignmentQueueEntry + { + ReactiveObjectTypeDefinition = declaringType, + AddInjectAttribute = false, + ProcessorAction = (processor, sharedStateBackingField) => this.EmitObservableEnumerableCreation( processor, propertyName, constructorReference, enhancerType, sharedStateBackingField, - propertyBackingField))); + propertyBackingField), + }); } /// diff --git a/src/Cortex.Net.Fody/ISharedStateAssignmentILProcessorQueue.cs b/src/Cortex.Net.Fody/ISharedStateAssignmentILProcessorQueue.cs index f7925ea..b9a1fcd 100644 --- a/src/Cortex.Net.Fody/ISharedStateAssignmentILProcessorQueue.cs +++ b/src/Cortex.Net.Fody/ISharedStateAssignmentILProcessorQueue.cs @@ -30,6 +30,6 @@ public interface ISharedStateAssignmentILProcessorQueue /// /// Gets a with actions to be executed to emit the IL code on ISharedState Assignment. /// - Queue<(TypeDefinition, bool, Action)> SharedStateAssignmentQueue { get; } + Queue SharedStateAssignmentQueue { get; } } } diff --git a/src/Cortex.Net.Fody/ObservableWeaver.cs b/src/Cortex.Net.Fody/ObservableWeaver.cs index 425b048..0b8e867 100644 --- a/src/Cortex.Net.Fody/ObservableWeaver.cs +++ b/src/Cortex.Net.Fody/ObservableWeaver.cs @@ -43,7 +43,7 @@ internal class ObservableWeaver : ObservableObjectWeaverBase /// The queue to add ILProcessor actions to. /// The resolved types necessary by this weaver. /// When any of the arguments is null. - public ObservableWeaver(ModuleWeaver parentWeaver, IEnumerableInterfaceWeaver enumerableInterfaceWeaver, ISharedStateAssignmentILProcessorQueue processorQueue, WeavingContext weavingContext) + public ObservableWeaver(ModuleWeaver parentWeaver, IEnumerableInterfaceWeaver enumerableInterfaceWeaver, ISharedStateAssignmentILProcessorQueue processorQueue, WeavingContext weavingContext) : base(parentWeaver, processorQueue, weavingContext) { this.enumerableInterfaceWeaver = enumerableInterfaceWeaver ?? throw new ArgumentNullException(nameof(enumerableInterfaceWeaver)); @@ -55,15 +55,15 @@ public ObservableWeaver(ModuleWeaver parentWeaver, IEnumerableInterfaceWeaver en internal void Execute() { var decoratedProperties = from t in this.ParentWeaver.ModuleDefinition.GetTypes() - from p in t.Properties - where - t != null && - t.IsClass && - t.BaseType != null && - p != null && - p.CustomAttributes != null && - p.CustomAttributes.Any(x => x.AttributeType.FullName == this.WeavingContext.CortexNetApiObservableAttribute.FullName) - select p; + from p in t.Properties + where + t != null && + t.IsClass && + t.BaseType != null && + p != null && + p.CustomAttributes != null && + p.CustomAttributes.Any(x => x.AttributeType.FullName == this.WeavingContext.CortexNetApiObservableAttribute.FullName) + select p; foreach (var decoratedProperty in decoratedProperties.ToList()) { @@ -78,13 +78,13 @@ from p in t.Properties } var decoratedClasses = from t in this.ParentWeaver.ModuleDefinition.GetTypes() - where - t != null && - t.IsClass && - t.BaseType != null && - t.CustomAttributes != null && - t.CustomAttributes.Any(x => x.AttributeType.FullName == this.WeavingContext.CortexNetApiObservableAttribute.FullName) - select t; + where + t != null && + t.IsClass && + t.BaseType != null && + t.CustomAttributes != null && + t.CustomAttributes.Any(x => x.AttributeType.FullName == this.WeavingContext.CortexNetApiObservableAttribute.FullName) + select t; foreach (var decoratedClass in decoratedClasses.ToList()) { @@ -196,27 +196,33 @@ private void WeaveProperty(PropertyDefinition property, TypeReference defaultEnh // push IL code for initialization of observableObject to the queue to emit in the ISharedState setter. this.ProcessorQueue.SharedStateAssignmentQueue.Enqueue( - (declaringType, - false, - (processor, sharedStateBackingField) => this.EmitObservableObjectInit( + new SharedAssignmentQueueEntry + { + ReactiveObjectTypeDefinition = declaringType, + AddInjectAttribute = false, + ProcessorAction = (processor, sharedStateBackingField) => this.EmitObservableObjectInit( processor, declaringType.Name, defaultEhancerType, sharedStateBackingField, - observableObjectField))); + observableObjectField), + }); } // push IL code for initialization of a property to the queue to emit in the ISharedState setter. this.ProcessorQueue.SharedStateAssignmentQueue.Enqueue( - (declaringType, - false, - (processor, sharedStateBackingField) => this.EmitObservablePropertyAdd( + new SharedAssignmentQueueEntry + { + ReactiveObjectTypeDefinition = declaringType, + AddInjectAttribute = false, + ProcessorAction = (processor, sharedStateBackingField) => this.EmitObservablePropertyAdd( processor, propertyName, property.PropertyType, enhancerType, sharedStateBackingField, - observableObjectField))); + observableObjectField), + }); this.RewriteGetMethod(getMethod, observableObjectField, propertyName, property.PropertyType); this.RewriteSetMethod(setMethod, observableObjectField, propertyName, property.PropertyType); diff --git a/src/Cortex.Net.Fody/ReactiveObjectInterfaceWeaver.cs b/src/Cortex.Net.Fody/ReactiveObjectInterfaceWeaver.cs index 5877ca0..ca24521 100644 --- a/src/Cortex.Net.Fody/ReactiveObjectInterfaceWeaver.cs +++ b/src/Cortex.Net.Fody/ReactiveObjectInterfaceWeaver.cs @@ -59,7 +59,7 @@ public ReactiveObjectInterfaceWeaver(ModuleWeaver parentWeaver, WeavingContext w /// /// Gets a Queue with delegates to be executed to emit the IL code on sharedStateAssignment. /// - public Queue<(TypeDefinition, bool, Action)> SharedStateAssignmentQueue { get; } = new Queue<(TypeDefinition, bool, Action)>(); + public Queue SharedStateAssignmentQueue { get; } = new Queue(); /// /// Executes this weaver. @@ -70,13 +70,22 @@ internal void Execute() // sort queue contents by object, and group by type. var queueContent = from q in this.SharedStateAssignmentQueue.ToList() - group q by q.Item1 into g - select (g.Key, g.Any(x => x.Item2), g.Select(x => x.Item3)); + group q by q.ReactiveObjectTypeDefinition into g + select new + { + ReactiveObjectTypeDefinition = g.Key, + AddInjectAttribute = g.Any(x => x.AddInjectAttribute), + ProcessorActions = g.Select(x => x.ProcessorAction).ToList(), + }; this.SharedStateAssignmentQueue.Clear(); - foreach ((TypeDefinition reactiveObjectTypeDefinition, bool addInjectAttribute, IEnumerable> processorActions) in queueContent) + foreach (var item in queueContent) { + var reactiveObjectTypeDefinition = item.ReactiveObjectTypeDefinition; + var processorActions = item.ProcessorActions; + var addInjectAttribute = item.AddInjectAttribute; + var isBlazorComponent = IsBlazorComponent(reactiveObjectTypeDefinition); FieldDefinition backingField = null; @@ -148,7 +157,7 @@ group q by q.Item1 into g if (setOverride != null) { - backingField = reactiveObjectTypeDefinition.Fields.Single(x => x.Name.ToUpperInvariant().Contains("SHAREDSTATE") && x.FieldType.FullName == fieldTypeReference.FullName); + backingField = reactiveObjectTypeDefinition.Fields.Single(x => x.Name.IndexOf("SHAREDSTATE", StringComparison.InvariantCultureIgnoreCase) >= 0 && x.FieldType.FullName == fieldTypeReference.FullName); if (backingField != null) { diff --git a/src/Cortex.Net.Fody/SharedAssignmentQueueEntry.cs b/src/Cortex.Net.Fody/SharedAssignmentQueueEntry.cs new file mode 100644 index 0000000..a6cfc0a --- /dev/null +++ b/src/Cortex.Net.Fody/SharedAssignmentQueueEntry.cs @@ -0,0 +1,45 @@ +// +// Copyright 2019 Jan-Willem Spuij +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, +// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom +// the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +namespace Cortex.Net.Fody +{ + using System; + using System.Collections.Generic; + using System.Text; + using Mono.Cecil; + using Mono.Cecil.Cil; + + /// + /// An entry in the Shared Assignment Queue. + /// + public class SharedAssignmentQueueEntry + { + /// + /// Gets or sets type Definition of the Reactive Object. + /// + public TypeDefinition ReactiveObjectTypeDefinition { get; set; } + + /// + /// Gets or sets a value indicating whether to add InjectAttribute. + /// + public bool AddInjectAttribute { get; set; } + + /// + /// Gets or sets the processor action. + /// + public Action ProcessorAction { get; set; } + } +} diff --git a/src/Cortex.Net/ComputedValueOptions.cs b/src/Cortex.Net/ComputedValueOptions.cs index 8f3b370..cd5bf4f 100644 --- a/src/Cortex.Net/ComputedValueOptions.cs +++ b/src/Cortex.Net/ComputedValueOptions.cs @@ -51,7 +51,7 @@ public ComputedValueOptions(Func getter, string name) /// /// Gets or sets setter function. /// - public Action Setter { get; set; } = null; + public Action Setter { get; set; } /// /// Gets or sets the name of the computed value. @@ -71,11 +71,11 @@ public ComputedValueOptions(Func getter, string name) /// /// Gets or sets a value indicating whether the requires a reactive context. /// - public bool RequiresReaction { get; set; } = false; + public bool RequiresReaction { get; set; } /// /// Gets or sets a value indicating whether the computed value keeps calculating, even when it is not observed. /// - public bool KeepAlive { get; set; } = false; + public bool KeepAlive { get; set; } } } diff --git a/src/Cortex.Net/Core/Atom.cs b/src/Cortex.Net/Core/Atom.cs index fd2b6fc..627091e 100644 --- a/src/Cortex.Net/Core/Atom.cs +++ b/src/Cortex.Net/Core/Atom.cs @@ -63,21 +63,21 @@ internal Atom(ISharedState sharedState, string name) /// /// Gets or sets a value indicating whether this atom is pending Unobservation. /// - public bool IsPendingUnobservation { get; set; } = false; + public bool IsPendingUnobservation { get; set; } /// /// Gets or sets the Id of the derivation run that last accessed this observable. /// If this Id equals the of the current derivation /// the dependency is already established. /// - public int LastAccessedBy { get; set; } = 0; + public int LastAccessedBy { get; set; } /// /// Gets or sets a value indicating whether the observable is being observed. /// An observable is being observed when at least one derivation actually accesses its /// value. /// - public bool IsBeingObserved { get; set; } = false; + public bool IsBeingObserved { get; set; } /// /// Gets or sets the lowest on any of it's observers. diff --git a/src/Cortex.Net/Core/ComputedValue.cs b/src/Cortex.Net/Core/ComputedValue.cs index e12388a..4507660 100644 --- a/src/Cortex.Net/Core/ComputedValue.cs +++ b/src/Cortex.Net/Core/ComputedValue.cs @@ -70,17 +70,17 @@ public class ComputedValue : IObservable, IDerivation, IComputedValue /// /// To check for evaluation cycles. /// - private bool isComputing = false; + private bool isComputing; /// /// To check for setter cycles. /// - private bool isRunningSetter = false; + private bool isRunningSetter; /// /// To support computed weaving with reentrancy we allow 1 cycle of reentrance immediately after derivation call. /// - private bool immediateDerivationCall = false; + private bool immediateDerivationCall; /// /// The computed value. @@ -184,21 +184,21 @@ public event EventHandler> Changed /// /// Gets or sets a value indicating whether this atom is pending Unobservation. /// - public bool IsPendingUnobservation { get; set; } = false; + public bool IsPendingUnobservation { get; set; } /// /// Gets or sets the Id of the derivation run that last accessed this observable. /// If this Id equals the of the current derivation /// the dependency is already established. /// - public int LastAccessedBy { get; set; } = 0; + public int LastAccessedBy { get; set; } /// /// Gets or sets a value indicating whether the observable is being observed. /// An observable is being observed when at least one derivation actually accesses its /// value. /// - public bool IsBeingObserved { get; set; } = false; + public bool IsBeingObserved { get; set; } /// /// Gets or sets the lowest on any of it's observers. diff --git a/src/Cortex.Net/Cortex.Net.csproj b/src/Cortex.Net/Cortex.Net.csproj index dd477d7..2d7cdf7 100644 --- a/src/Cortex.Net/Cortex.Net.csproj +++ b/src/Cortex.Net/Cortex.Net.csproj @@ -24,8 +24,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Cortex.Net/SharedState.cs b/src/Cortex.Net/SharedState.cs index 4b70aab..fe8035d 100644 --- a/src/Cortex.Net/SharedState.cs +++ b/src/Cortex.Net/SharedState.cs @@ -51,12 +51,12 @@ public sealed partial class SharedState : ISharedState /// /// Batch counter to support reentrance of Start and EndBatch. /// - private int batchCount = 0; + private int batchCount; /// /// A unique Id that is incremented and used to identify instances. /// - private int uniqueId = 0; + private int uniqueId; /// /// Initializes a new instance of the class. @@ -152,23 +152,23 @@ public static ISharedState GlobalState /// /// Gets the shared derivation RunId counter. /// - public int RunId { get; private set; } = 0; + public int RunId { get; private set; } /// /// Gets or sets the computation depth. /// - public int ComputationDepth { get; set; } = 0; + public int ComputationDepth { get; set; } /// /// Gets or sets a value indicating whether to suppress reaction errors. /// Suppressing happens when an action is the root cause of reactions to fail further because of the incorrect state. /// - public bool SuppressReactionErrors { get; set; } = false; + public bool SuppressReactionErrors { get; set; } /// /// Gets or sets the Id of the Current Action. /// - public int CurrentActionId { get; set; } = 0; + public int CurrentActionId { get; set; } /// /// Gets or sets the Id of the Next Action. diff --git a/src/Cortex.Net/Utils/ReferenceEqualityComparer.cs b/src/Cortex.Net/Utils/ReferenceEqualityComparer.cs index 36dba71..cc06cce 100644 --- a/src/Cortex.Net/Utils/ReferenceEqualityComparer.cs +++ b/src/Cortex.Net/Utils/ReferenceEqualityComparer.cs @@ -49,7 +49,9 @@ public bool Equals(T x, T y) /// A hash code for the specified object. public int GetHashCode(T obj) { +#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations throw new NotImplementedException(); +#pragma warning restore CA1065 // Do not raise exceptions in unexpected locations } } } diff --git a/src/Cortext.Next.Playground/Cortext.Next.Playground.csproj b/src/Cortext.Next.Playground/Cortext.Next.Playground.csproj index 9b5756a..4a60200 100644 --- a/src/Cortext.Next.Playground/Cortext.Next.Playground.csproj +++ b/src/Cortext.Next.Playground/Cortext.Next.Playground.csproj @@ -7,12 +7,12 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/test/Cortex.Net.Fody.Test/Cortex.Net.Fody.Test.csproj b/test/Cortex.Net.Fody.Test/Cortex.Net.Fody.Test.csproj index e7b6e4f..09c3942 100644 --- a/test/Cortex.Net.Fody.Test/Cortex.Net.Fody.Test.csproj +++ b/test/Cortex.Net.Fody.Test/Cortex.Net.Fody.Test.csproj @@ -19,22 +19,22 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/test/Cortex.Net.Test/Cortex.Net.Test.csproj b/test/Cortex.Net.Test/Cortex.Net.Test.csproj index 4700646..979d050 100644 --- a/test/Cortex.Net.Test/Cortex.Net.Test.csproj +++ b/test/Cortex.Net.Test/Cortex.Net.Test.csproj @@ -20,18 +20,18 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive