diff --git a/PropertyChanged.Fody/PropertyWeaver.cs b/PropertyChanged.Fody/PropertyWeaver.cs index af26529b..523dd88f 100644 --- a/PropertyChanged.Fody/PropertyWeaver.cs +++ b/PropertyChanged.Fody/PropertyWeaver.cs @@ -61,7 +61,7 @@ void InjectAtIndex(int index) foreach (var alsoNotifyForDefinition in propertyData.AlsoNotifyFor.Distinct()) { var alsoNotifyMethods = GetMethodsForProperty(propertyData.ParentType, alsoNotifyForDefinition); - + index = AddEventInvokeCall(index, alsoNotifyMethods, alsoNotifyForDefinition); } @@ -201,10 +201,13 @@ int AddOnChangedMethodCalls(int index, List onChangedMethods, P break; case OnChangedTypes.BeforeAfterTyped: - if (propertyDefinition.PropertyType.FullName == onChangedMethod.ArgumentTypeFullName) + if (propertyDefinition.PropertyType.FullName != onChangedMethod.ArgumentTypeFullName) { - index = AddBeforeAfterOnChangedCall(index, propertyDefinition, onChangedMethod.MethodReference, true); + var methodDefinition = onChangedMethod.MethodDefinition; + moduleWeaver.EmitConditionalWarning(methodDefinition, $"Unsupported signature for a On_PropertyName_Changed method: {methodDefinition.Name} in {methodDefinition.DeclaringType.FullName}"); + break; } + index = AddBeforeAfterOnChangedCall(index, propertyDefinition, onChangedMethod.MethodReference, true); break; } } diff --git a/Tests/AssemblyToProcessTests.cs b/Tests/AssemblyToProcessTests.cs index 8fe36de0..5dcb5411 100644 --- a/Tests/AssemblyToProcessTests.cs +++ b/Tests/AssemblyToProcessTests.cs @@ -391,7 +391,7 @@ public void OnPropertyNameChangedMethodWithBeforeAfterTypedWithInvalidSignatureD Assert.Null(instance.OnProperty1ChangedCalled); - Assert.DoesNotContain(testResult.Warnings, w => w.Text.ContainsWholeWord(nameof(ClassWithOnChangedBeforeAfterTypedInvalidSignatureDefault))); + Assert.Contains(testResult.Warnings, w => w.Text.ContainsWholeWord(nameof(ClassWithOnChangedBeforeAfterTypedInvalidSignatureDefault))); } [Fact]