From: <and...@us...> - 2009-10-07 18:25:58
|
Revision: 268 http://structuremap.svn.sourceforge.net/structuremap/?rev=268&view=rev Author: andreas_ohlund Date: 2009-10-07 18:25:50 +0000 (Wed, 07 Oct 2009) Log Message: ----------- Fixed bug where FillAllPropertiesOfType didn't work for already configured instances Added missing test for the JITException bug Modified Paths: -------------- trunk/Source/StructureMap/Graph/PluginCache.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj Added Paths: ----------- trunk/Source/StructureMap.Testing/Bugs/FillAllPropertiesShouldWorkForAlreadyConfiguredPluginsBug.cs trunk/Source/StructureMap.Testing/Bugs/StaticPropertyCausesJITExceptionTester.cs Modified: trunk/Source/StructureMap/Graph/PluginCache.cs =================================================================== --- trunk/Source/StructureMap/Graph/PluginCache.cs 2009-10-07 17:17:56 UTC (rev 267) +++ trunk/Source/StructureMap/Graph/PluginCache.cs 2009-10-07 18:25:50 UTC (rev 268) @@ -106,7 +106,19 @@ public static void UseSetterRule(Predicate<PropertyInfo> predicate) { _setterRules.Add(predicate); - _plugins.Each(plugin => plugin.UseSetterRule(predicate)); + _plugins.Each(plugin => + { + plugin.UseSetterRule(predicate); + + //does any of the registered plugins have a setter matching the predicate? + if (plugin.PluggedType.GetProperties().Any(s => predicate(s))) + { + //rebuild the builder if nessesary + if (_builders[plugin.PluggedType] != null) + createAndStoreBuilders(new[] { plugin }); + } + }); + } } } \ No newline at end of file Added: trunk/Source/StructureMap.Testing/Bugs/FillAllPropertiesShouldWorkForAlreadyConfiguredPluginsBug.cs =================================================================== --- trunk/Source/StructureMap.Testing/Bugs/FillAllPropertiesShouldWorkForAlreadyConfiguredPluginsBug.cs (rev 0) +++ trunk/Source/StructureMap.Testing/Bugs/FillAllPropertiesShouldWorkForAlreadyConfiguredPluginsBug.cs 2009-10-07 18:25:50 UTC (rev 268) @@ -0,0 +1,51 @@ +using System.Collections.Generic; +using NUnit.Framework; + +namespace StructureMap.Testing.Bugs +{ + [TestFixture] + public class FillAllPropertiesShouldWorkForAlreadyConfiguredPluginsBug + { + + [Test] + public void Structuremap_should_autowire_setter_dependencies_regardless_of_order() + { + var container = new Container(); + + container.Configure(x => + { + x.ForConcreteType<ClassWithSetterDependency>(); + }); + + + container.Configure(x => + { + x.ForRequestedType<ISomeDependency>() + .TheDefaultIsConcreteType<ClassThatImplementsDependency>(); + + x.FillAllPropertiesOfType<ISomeDependency>(); + + + }); + + + + container.GetInstance<ClassWithSetterDependency>().Dependency.ShouldNotBeNull(); + } + + } + + + public class ClassWithSetterDependency + { + public ISomeDependency Dependency { get; set; } + public IList<string> SystemDependency { get; set; } + } + + public interface ISomeDependency { } + + public class ClassThatImplementsDependency : ISomeDependency { } + + public interface INonConfiguredInterface { } + +} Added: trunk/Source/StructureMap.Testing/Bugs/StaticPropertyCausesJITExceptionTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Bugs/StaticPropertyCausesJITExceptionTester.cs (rev 0) +++ trunk/Source/StructureMap.Testing/Bugs/StaticPropertyCausesJITExceptionTester.cs 2009-10-07 18:25:50 UTC (rev 268) @@ -0,0 +1,34 @@ +using NUnit.Framework; + +namespace StructureMap.Testing.Bugs +{ + [TestFixture] + public class StaticPropertyCausesJITExceptionTester + { + [Test] + public void Get_instance_should_work() + { + var container = new Container(x => x.ForConcreteType<ClassWithStaticProperty>()); + + container.GetInstance<ClassWithStaticProperty>(); + } + } + + public class ClassWithStaticProperty + { + + private static volatile bool disabled; + + public static bool Disabled + { + get + { + return disabled; + } + set + { + disabled = value; + } + } + } +} \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj =================================================================== --- trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-10-07 17:17:56 UTC (rev 267) +++ trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-10-07 18:25:50 UTC (rev 268) @@ -179,6 +179,7 @@ <Compile Include="AutoWiringExamples.cs" /> <Compile Include="BidirectionalDependencies.cs" /> <Compile Include="Bugs\BuildUpBug.cs" /> + <Compile Include="Bugs\FillAllPropertiesShouldWorkForAlreadyConfiguredPluginsBug.cs" /> <Compile Include="Bugs\HttpSessionNullRefBug.cs" /> <Compile Include="Bugs\IDictionaryAndXmlBugTester.cs" /> <Compile Include="Bugs\LambdaCreatesNullBugTester.cs" /> @@ -186,6 +187,7 @@ <Compile Include="Bugs\ScanIndexerBugTester.cs" /> <Compile Include="Bugs\SingletonShouldBeLazy.cs" /> <Compile Include="Bugs\SpecifyScopeInConfigureTester.cs" /> + <Compile Include="Bugs\StaticPropertyCausesJITExceptionTester.cs" /> <Compile Include="BuildSessionTester.cs" /> <Compile Include="BuildUpIntegratedTester.cs" /> <Compile Include="BuildUpTester.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |