Overriding the value of the Inject attribute on a property in a derived class will not be applied
// overriding the value of the Inject attribute on a property in a derived class will not be applied,
// the value will be used when describing the attribute in the base class
TInjectedClass = class(TObject)
[Inject(1)]
property InjectedProperty: Integer read FInjectedProperty write FInjectedProperty;
end;
TNotInjected = class(TInjectedClass)
[Inject(2)] // useless
property InjectedProperty;
end;
Comments (3)
-
reporter -
repo owner - changed status to open
I can confirm the issue but the suggested change does break one unit test. I have a slighly different fix but have to verify it does not break anything.
Especially as you can in fact have two similar named properties (even though that is smelly code) that don't have to do anything with each other and thus should both handled by the injection and not cancel each other out.
-
reporter Your test crashed for a reason: Injection.Target = nil comes in TContainsMemberFilter.IsSatisfiedBy, which is strange in itself
- Log in to comment
So far replaced Spring.Container.Builder
if not model.PropertyInjections.TryGetFirst(injection,
TInjectionFilters.ContainsMember(prop)) then
if model.PropertyInjections.TryGetFirst(injection,
TInjectionFilters.ContainsMember(prop)) then
Contionue;
And Spring.Container.Core TContainsMemberFilter.IsSatisfiedBy
Result := injection.Target.Name = fmember.Name