diff --git a/external/FluentIL b/external/FluentIL index 3998b823..6140c539 160000 --- a/external/FluentIL +++ b/external/FluentIL @@ -1 +1 @@ -Subproject commit 3998b8238d0eeea467c71df70781693b07e01309 +Subproject commit 6140c5396e5358c16e72b69ec85b370a9e92a1ea diff --git a/src/AspectInjector.Core/Models/AspectDefinition.cs b/src/AspectInjector.Core/Models/AspectDefinition.cs index 4254c1d4..238c87d8 100644 --- a/src/AspectInjector.Core/Models/AspectDefinition.cs +++ b/src/AspectInjector.Core/Models/AspectDefinition.cs @@ -47,7 +47,7 @@ public bool Validate(ILogger log) { var result = true; - if(Scope!= Scope.Global && Scope!= Scope.PerInstance) + if (Scope != Scope.Global && Scope != Scope.PerInstance) log.Log(GeneralRules.UnknownCompilationOption, Host, GeneralRules.Literals.UnknownAspectScope(Scope.ToString())); if (!Effects.Any()) @@ -59,6 +59,12 @@ public bool Validate(ILogger log) result = false; } + if (!Host.IsPublic && !Host.IsNestedPublic) + { + log.Log(AspectRules.AspectMustHaveValidSignature, Host, Host.Name, AspectRules.Literals.IsNotPublic); + result = false; + } + if (Host.IsAbstract) { if (Host.IsSealed) diff --git a/src/AspectInjector.Rules/AspectRules.cs b/src/AspectInjector.Rules/AspectRules.cs index ce5a478d..6e23bcc2 100644 --- a/src/AspectInjector.Rules/AspectRules.cs +++ b/src/AspectInjector.Rules/AspectRules.cs @@ -8,6 +8,7 @@ public static class Literals { public static readonly string HasGenericParams = "has generic parameters"; public static readonly string IsAbstract = "is abstract"; + public static readonly string IsNotPublic = "is not public"; public static readonly string IsStatic = "is static"; } @@ -20,9 +21,9 @@ public static class Literals public static readonly Rule AspectMustHaveValidSignature = GeneralRules.Make("AI_A001", - "Aspect must not be generic, abstract or static", + "Aspect must not be generic, abstract or static. And it should be public.", "Aspect '{0}' {1}", - "Aspect must have valid signature. Aspect must be non-generic, non-abstract and non-static class."); + "Aspect must have valid signature. Aspect must be non-generic, non-abstract and non-static public class."); public static readonly Rule AspectFactoryMustContainFactoryMethod = GeneralRules.Make("AI_A002", diff --git a/tests/AspectInjector.Tests.Runtime/Advices/AccessModifiersTests.cs b/tests/AspectInjector.Tests.Runtime/Advices/AccessModifiersTests.cs index 368afba5..6d16fb5d 100644 --- a/tests/AspectInjector.Tests.Runtime/Advices/AccessModifiersTests.cs +++ b/tests/AspectInjector.Tests.Runtime/Advices/AccessModifiersTests.cs @@ -37,7 +37,7 @@ public void Public() { } [Aspect(Scope.Global)] [Injection(typeof(AccessTestAspect))] - internal class AccessTestAspect : Attribute + public class AccessTestAspect : Attribute { [Advice(Kind.Around, Targets = Target.Internal)] public object TestAccess([Argument(Source.Metadata)] MethodBase method) diff --git a/tests/AspectInjector.Tests.Runtime/Advices/AfterTests.cs b/tests/AspectInjector.Tests.Runtime/Advices/AfterTests.cs index a9c2572e..ac04ee66 100644 --- a/tests/AspectInjector.Tests.Runtime/Advices/AfterTests.cs +++ b/tests/AspectInjector.Tests.Runtime/Advices/AfterTests.cs @@ -138,7 +138,7 @@ public int TestCustomSetterProperty //aspects [Aspect(Scope.Global)] [Injection(typeof(AfterTests_AfterMethodAspect))] - internal class AfterTests_AfterMethodAspect : Attribute + public class AfterTests_AfterMethodAspect : Attribute { //Property [Advice(Kind.After, Targets = Target.Setter)] @@ -161,7 +161,7 @@ internal class AfterTests_AfterMethodAspect : Attribute [Aspect(Scope.Global)] [Injection(typeof(AfterTests_AfterConstructorAspect))] - internal class AfterTests_AfterConstructorAspect : Attribute + public class AfterTests_AfterConstructorAspect : Attribute { [Advice(Kind.After, Targets = Target.Constructor)] public void AfterConstructor() { Checker.Passed = true; } diff --git a/tests/AspectInjector.Tests.Runtime/Advices/ArgumentsTests.cs b/tests/AspectInjector.Tests.Runtime/Advices/ArgumentsTests.cs index f9a35bff..f3ae916a 100644 --- a/tests/AspectInjector.Tests.Runtime/Advices/ArgumentsTests.cs +++ b/tests/AspectInjector.Tests.Runtime/Advices/ArgumentsTests.cs @@ -132,7 +132,7 @@ public void Fact() [Aspect(Scope.Global)] [Injection(typeof(ArgumentsTests_InstanceAspect))] - internal class ArgumentsTests_InstanceAspect : Attribute + public class ArgumentsTests_InstanceAspect : Attribute { [Advice(Kind.Before, Targets = Target.Method)] public void BeforeMethod([Argument(Source.Instance)] object instance) @@ -151,7 +151,7 @@ public static void Fact() [Aspect(Scope.Global)] [Injection(typeof(ArgumentsTests_StaticInstanceAspect))] - internal class ArgumentsTests_StaticInstanceAspect:Attribute + public class ArgumentsTests_StaticInstanceAspect:Attribute { [Advice(Kind.Before, Targets = Target.Method)] public void BeforeMethod([Argument(Source.Instance)] object instance) @@ -170,7 +170,7 @@ public static void Fact() [Aspect(Scope.Global)] [Injection(typeof(ArgumentsTests_ReturnTypeAspect))] - internal class ArgumentsTests_ReturnTypeAspect: Attribute + public class ArgumentsTests_ReturnTypeAspect: Attribute { [Advice(Kind.Before, Targets = Target.Method)] public void BeforeMethod([Argument(Source.Type)] System.Type type) @@ -197,7 +197,7 @@ static ArgumentsTests_StaticConstructorTarget() [Aspect(Scope.Global)] [Injection(typeof(ArgumentsTests_StaticMethodAspect))] - internal class ArgumentsTests_StaticMethodAspect : Attribute + public class ArgumentsTests_StaticMethodAspect : Attribute { [Advice(Kind.Before, Targets = Target.Method | Target.Constructor)] public void BeforeMethod([Argument(Source.Metadata)] MethodBase method) @@ -245,7 +245,7 @@ public ArgumentsTests_ConstructorTarget() [Aspect(Scope.Global)] [Injection(typeof(ArgumentsTests_MethodAspect))] - internal class ArgumentsTests_MethodAspect:Attribute + public class ArgumentsTests_MethodAspect:Attribute { [Advice(Kind.Before, Targets = Target.Method | Target.Constructor)] public void BeforeMethod([Argument(Source.Metadata)] MethodBase method) @@ -266,7 +266,7 @@ public void Fact(object obj, ref object objRef, out object objOut, int value, re [Aspect(Scope.Global)] [Injection(typeof(ArgumentsTests_ArgumentsAspect))] - internal class ArgumentsTests_ArgumentsAspect:Attribute + public class ArgumentsTests_ArgumentsAspect:Attribute { [Advice(Kind.Before, Targets = Target.Method)] public void BeforeMethod([Argument(Source.Arguments)] object[] args) @@ -287,7 +287,7 @@ public static void Fact(int a, string b) [Aspect(Scope.Global)] [Injection(typeof(ArgumentsTests_StaticArgumentsAspect))] - internal class ArgumentsTests_StaticArgumentsAspect :Attribute + public class ArgumentsTests_StaticArgumentsAspect :Attribute { [Advice(Kind.Before, Targets = Target.Method)] public void BeforeMethod([Argument(Source.Arguments)] object[] args) @@ -306,7 +306,7 @@ public void Fact() [Aspect(Scope.Global)] [Injection(typeof(ArgumentsTests_AroundMethodAspect))] - internal class ArgumentsTests_AroundMethodAspect : Attribute + public class ArgumentsTests_AroundMethodAspect : Attribute { [Advice(Kind.Around, Targets = Target.Method)] public object BeforeMethod([Argument(Source.Metadata)] MethodBase method) @@ -327,7 +327,7 @@ public object Fact() [Aspect(Scope.Global)] [Injection(typeof(ArgumentsTests_AroundRetValAspect))] - internal class ArgumentsTests_AroundRetValAspect:Attribute + public class ArgumentsTests_AroundRetValAspect:Attribute { [Advice(Kind.After, Targets = Target.Method)] public void AfterMethod([Argument(Source.ReturnValue)] object ret) @@ -344,7 +344,7 @@ internal class ArgumentsTests_PropertyTarget [Injection(typeof(ArgumentsTests_PropertyTarget_Aspect))] [Aspect(Scope.Global)] - class ArgumentsTests_PropertyTarget_Aspect : Attribute + public class ArgumentsTests_PropertyTarget_Aspect : Attribute { [Advice(Kind.Before)] public void TestName([Argument(Source.Name)] string name) diff --git a/tests/AspectInjector.Tests.Runtime/Advices/AroundTests.cs b/tests/AspectInjector.Tests.Runtime/Advices/AroundTests.cs index aad97215..216ffb6f 100644 --- a/tests/AspectInjector.Tests.Runtime/Advices/AroundTests.cs +++ b/tests/AspectInjector.Tests.Runtime/Advices/AroundTests.cs @@ -189,7 +189,7 @@ public T Generic(T data) [Aspect(Scope.Global)] [Injection(typeof(AroundTests_Simple))] - internal class AroundTests_Simple : Attribute + public class AroundTests_Simple : Attribute { [Advice(Kind.Around, Targets = Target.Method)] public object AroundMethod([Argument(Source.Target)] Func target, @@ -201,7 +201,7 @@ public object AroundMethod([Argument(Source.Target)] Func targ [Aspect(Scope.Global)] [Injection(typeof(AroundTests_Aspect1))] - internal class AroundTests_Aspect1 : Attribute + public class AroundTests_Aspect1 : Attribute { [Advice(Kind.Around, Targets = Target.Method)] public object AroundMethod([Argument(Source.Target)] Func target, @@ -213,7 +213,7 @@ public object AroundMethod([Argument(Source.Target)] Func targ [Aspect(Scope.Global)] [Injection(typeof(AroundTests_Aspect2))] - internal class AroundTests_Aspect2 : Attribute + public class AroundTests_Aspect2 : Attribute { [Advice(Kind.Around, Targets = Target.Method)] public object AroundMethod([Argument(Source.Target)] Func target, @@ -235,7 +235,7 @@ public void Fact(ref int i) [Aspect(Scope.Global)] [Injection(typeof(AroundTests_ArgumentsModificationAspect))] - internal class AroundTests_ArgumentsModificationAspect : Attribute + public class AroundTests_ArgumentsModificationAspect : Attribute { [Advice(Kind.Around, Targets = Target.Method)] public object AroundMethod( diff --git a/tests/AspectInjector.Tests.Runtime/Advices/BeforeTests.cs b/tests/AspectInjector.Tests.Runtime/Advices/BeforeTests.cs index 90f0cedf..e22442dc 100644 --- a/tests/AspectInjector.Tests.Runtime/Advices/BeforeTests.cs +++ b/tests/AspectInjector.Tests.Runtime/Advices/BeforeTests.cs @@ -99,7 +99,7 @@ public void Fact(string data) //aspects [Aspect(Scope.Global)] [Injection(typeof(BeforeTests_Aspect))] - internal class BeforeTests_Aspect : Attribute + public class BeforeTests_Aspect : Attribute { //Property [Advice(Kind.Before, Targets = Target.Setter)] @@ -122,7 +122,7 @@ internal class BeforeTests_Aspect : Attribute [Aspect( Scope.Global)] [Injection(typeof(BeforeTests_BeforeConstructorAspect))] - internal class BeforeTests_BeforeConstructorAspect : Attribute + public class BeforeTests_BeforeConstructorAspect : Attribute { [Advice(Kind.Before, Targets = Target.Constructor)] public void BeforeConstructor([Argument(Source.Instance)] object instance) @@ -135,7 +135,7 @@ public void BeforeConstructor([Argument(Source.Instance)] object instance) [Mixin(typeof(IDisposable))] [Aspect(Scope.Global)] [Injection(typeof(BeforeTests_BeforeConstructorWithInterfaceAspect))] - internal class BeforeTests_BeforeConstructorWithInterfaceAspect : Attribute, IDisposable + public class BeforeTests_BeforeConstructorWithInterfaceAspect : Attribute, IDisposable { [Advice(Kind.Before, Targets = Target.Constructor)] public void BeforeConstructor() { Checker.Passed = true; } diff --git a/tests/AspectInjector.Tests.Runtime/Advices/GenericTests.cs b/tests/AspectInjector.Tests.Runtime/Advices/GenericTests.cs index 6a310c9f..7639522e 100644 --- a/tests/AspectInjector.Tests.Runtime/Advices/GenericTests.cs +++ b/tests/AspectInjector.Tests.Runtime/Advices/GenericTests.cs @@ -59,7 +59,7 @@ public void TestGenericMethod() [Aspect(Scope.Global)] [Injection(typeof(GenericTests_Aspect))] - internal class GenericTests_Aspect : Attribute + public class GenericTests_Aspect : Attribute { [Advice(Kind.Before, Targets = Target.Method)] public void BeforeMethod() { Checker.Passed = true; } @@ -80,7 +80,7 @@ public void Fact() [Aspect(Scope.Global)] [Injection(typeof(GenericTests_OpenGenericAspect))] - internal class GenericTests_OpenGenericAspect:Attribute + public class GenericTests_OpenGenericAspect:Attribute { [Advice(Kind.Before, Targets = Target.Method)] public void BeforeMethod() { Checker.Passed = true; } @@ -98,7 +98,7 @@ public T Fact(ref T value) [Aspect(Scope.Global)] [Injection(typeof(GenericAroundTests_Aspect))] - internal class GenericAroundTests_Aspect : Attribute + public class GenericAroundTests_Aspect : Attribute { [Advice(Kind.Around, Targets = Target.Method)] public object AroundAdvice([Argument(Source.Target)] Func target, diff --git a/tests/AspectInjector.Tests.Runtime/Advices/OrderTests.cs b/tests/AspectInjector.Tests.Runtime/Advices/OrderTests.cs index cf90f066..0c02a0c9 100644 --- a/tests/AspectInjector.Tests.Runtime/Advices/OrderTests.cs +++ b/tests/AspectInjector.Tests.Runtime/Advices/OrderTests.cs @@ -31,7 +31,7 @@ public void Fact() class Trigger : Attribute { } [Aspect(Scope.Global)] - internal class OrderTests_Aspect1 + public class OrderTests_Aspect1 { [Advice(Kind.Before)] public void BeforeMethod() @@ -41,7 +41,7 @@ public void BeforeMethod() } [Aspect(Scope.Global)] - internal class OrderTests_Aspect2 + public class OrderTests_Aspect2 { [Advice(Kind.Before)] public void BeforeMethod() @@ -51,7 +51,7 @@ public void BeforeMethod() } [Aspect(Scope.Global)] - internal class OrderTests_Aspect3 + public class OrderTests_Aspect3 { [Advice(Kind.Before)] public void BeforeMethod() diff --git a/tests/AspectInjector.Tests.Runtime/Advices/StaticTests.cs b/tests/AspectInjector.Tests.Runtime/Advices/StaticTests.cs index 7a99d38c..dced1430 100644 --- a/tests/AspectInjector.Tests.Runtime/Advices/StaticTests.cs +++ b/tests/AspectInjector.Tests.Runtime/Advices/StaticTests.cs @@ -45,7 +45,7 @@ public static int Do123(int data, StringBuilder sb, object to, bool passed, bool [Aspect(Scope.Global)] [Injection(typeof(StaticTests_AroundAspect1))] - internal class StaticTests_AroundAspect1 : Attribute + public class StaticTests_AroundAspect1 : Attribute { [Advice(Kind.Around, Targets = Target.Method)] public object AroundMethod([Argument(Source.Target)] Func target, @@ -57,7 +57,7 @@ public object AroundMethod([Argument(Source.Target)] Func targ [Aspect(Scope.Global)] [Injection(typeof(StaticTests_AroundAspect2))] - internal class StaticTests_AroundAspect2 : Attribute + public class StaticTests_AroundAspect2 : Attribute { [Advice(Kind.Around, Targets = Target.Method)] public object AroundMethod([Argument(Source.Target)] Func target, @@ -81,7 +81,7 @@ public void TestInstanceMethod() [Aspect(Scope.Global)] [Injection(typeof(StaticTests_BeforeAspect))] - internal class StaticTests_BeforeAspect : Attribute + public class StaticTests_BeforeAspect : Attribute { //Property [Advice(Kind.Before, Targets = Target.Method)] diff --git a/tests/AspectInjector.Tests.Runtime/General/AspectScopeTests.cs b/tests/AspectInjector.Tests.Runtime/General/AspectScopeTests.cs index 628f847e..07fda117 100644 --- a/tests/AspectInjector.Tests.Runtime/General/AspectScopeTests.cs +++ b/tests/AspectInjector.Tests.Runtime/General/AspectScopeTests.cs @@ -31,7 +31,7 @@ public void SCOPE_Create_Global_Aspect() [Aspect(Scope.PerInstance)] [Injection(typeof(AspectScopeTests_PerInstanceAspect))] - internal class AspectScopeTests_PerInstanceAspect:Attribute + public class AspectScopeTests_PerInstanceAspect:Attribute { public static int _counter; @@ -48,7 +48,7 @@ public void Do() [Aspect(Scope.Global)] [Injection(typeof(AspectScopeTests_GlobalAspect))] - internal class AspectScopeTests_GlobalAspect: Attribute + public class AspectScopeTests_GlobalAspect: Attribute { public static int _counter; diff --git a/tests/AspectInjector.Tests.Runtime/General/UnmanagedTests.cs b/tests/AspectInjector.Tests.Runtime/General/UnmanagedTests.cs index 40d44ea4..251133f7 100644 --- a/tests/AspectInjector.Tests.Runtime/General/UnmanagedTests.cs +++ b/tests/AspectInjector.Tests.Runtime/General/UnmanagedTests.cs @@ -14,7 +14,7 @@ public class UnmanagedTests [Aspect(Scope.Global)] [Injection(typeof(UnmanagedTests_Aspect))] - internal class UnmanagedTests_Aspect : Attribute + public class UnmanagedTests_Aspect : Attribute { [Advice(Kind.After, Targets = Target.Method)] public void Trace() diff --git a/tests/AspectInjector.Tests.Runtime/Injections/DirectInjectionsTests.cs b/tests/AspectInjector.Tests.Runtime/Injections/DirectInjectionsTests.cs index 806f84e0..69c2ebc7 100644 --- a/tests/AspectInjector.Tests.Runtime/Injections/DirectInjectionsTests.cs +++ b/tests/AspectInjector.Tests.Runtime/Injections/DirectInjectionsTests.cs @@ -23,7 +23,7 @@ private class TestTarget [Aspect(Scope.Global)] [Injection(typeof(TestAspect))] - private class TestAspect : Attribute + public class TestAspect : Attribute { private int _count = 0; diff --git a/tests/AspectInjector.Tests.Runtime/Injections/InjectionOrderTests.cs b/tests/AspectInjector.Tests.Runtime/Injections/InjectionOrderTests.cs index a64c92d6..8ae52eb1 100644 --- a/tests/AspectInjector.Tests.Runtime/Injections/InjectionOrderTests.cs +++ b/tests/AspectInjector.Tests.Runtime/Injections/InjectionOrderTests.cs @@ -18,7 +18,7 @@ public void AspectInstance_InHierarchy_MustBeOne() [Aspect(Scope.PerInstance)] [Injection(typeof(TestAspect))] - private class TestAspect : Attribute + public class TestAspect : Attribute { public int Count { get; private set; } diff --git a/tests/AspectInjector.Tests.Runtime/Injections/SkipInjectionsTests.cs b/tests/AspectInjector.Tests.Runtime/Injections/SkipInjectionsTests.cs index e59e001a..e6caf45f 100644 --- a/tests/AspectInjector.Tests.Runtime/Injections/SkipInjectionsTests.cs +++ b/tests/AspectInjector.Tests.Runtime/Injections/SkipInjectionsTests.cs @@ -39,7 +39,7 @@ public void Test() { } } [Aspect(Scope.Global)] - private class TestAspect + public class TestAspect { [Advice(Kind.Before, Targets = Target.Method)] public void Before() diff --git a/tests/AspectInjector.Tests.Runtime/Interfaces/GeneralTests.cs b/tests/AspectInjector.Tests.Runtime/Interfaces/GeneralTests.cs index 2eb833c9..91014b27 100644 --- a/tests/AspectInjector.Tests.Runtime/Interfaces/GeneralTests.cs +++ b/tests/AspectInjector.Tests.Runtime/Interfaces/GeneralTests.cs @@ -121,7 +121,7 @@ private class GeneralTests_Trigger : Attribute [Mixin(typeof(IGeneralTests))] [Mixin(typeof(INotifyPropertyChanged))] [Aspect(Scope.Global)] - internal class GeneralTests_Aspect : IGeneralTests, INotifyPropertyChanged + public class GeneralTests_Aspect : IGeneralTests, INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged = (s, e) => { }; diff --git a/tests/AspectInjector.Tests.Runtime/Issues/0098.cs b/tests/AspectInjector.Tests.Runtime/Issues/0098.cs index 7f5647de..cc3457c7 100644 --- a/tests/AspectInjector.Tests.Runtime/Issues/0098.cs +++ b/tests/AspectInjector.Tests.Runtime/Issues/0098.cs @@ -14,7 +14,7 @@ public void Fixed() [Aspect(Scope.PerInstance)] [Injection(typeof(TestAspect))] - private class TestAspect : Attribute + public class TestAspect : Attribute { [Advice(Kind.Before)] public void Before()