Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception thrown when processing write only properties #282

Open
roryprimrose opened this issue Aug 8, 2023 · 1 comment
Open

Exception thrown when processing write only properties #282

roryprimrose opened this issue Aug 8, 2023 · 1 comment

Comments

@roryprimrose
Copy link
Owner

ModelBuilder handles properties that are public set with private get. It fails however on purely write only properties. For example:

        public ProtectedItem PrivateWriteOnly
        {
            set
            {
            }
        }
@roryprimrose
Copy link
Owner Author

The context is


ModelBuilder.BuildException
Failed to create instance of type 'Divergic.Configuration.Autofac.UnitTests.Config'
   at ModelBuilder.DefaultExecuteStrategy.Build(Type type, Object[] args)
   at ModelBuilder.DefaultExecuteStrategy.Create(Type type, Object[] args)
   at ModelBuilder.Model.Create(Type instanceType, Object[] args)
   at Divergic.Configuration.Autofac.UnitTests.ConfigurationModuleTTests.InMemoryResolver`1.Resolve() in D:\Repos\roryprimrose\Divergic.Configuration.Autofac\Divergic.Configuration.Autofac.UnitTests\ConfigurationModuleTTests.cs:line 70
   at Divergic.Configuration.Autofac.ConfigurationModule.Load(ContainerBuilder builder) in D:\Repos\roryprimrose\Divergic.Configuration.Autofac\Divergic.Configuration.Autofac\ConfigurationModule.cs:line 31
   at Autofac.Module.Configure(IComponentRegistryBuilder componentRegistry)
   at Autofac.Core.Registration.ModuleRegistrar.<.ctor>b__1_0(IComponentRegistryBuilder reg)
   at Autofac.ContainerBuilder.Build(IComponentRegistryBuilder componentRegistry, Boolean excludeDefaultModules)
   at Autofac.ContainerBuilder.Build(ContainerBuildOptions options)
   at Divergic.Configuration.Autofac.UnitTests.ConfigurationModuleTTests.RegistersConfigurationWithNestedTypesTest() in D:\Repos\roryprimrose\Divergic.Configuration.Autofac\Divergic.Configuration.Autofac.UnitTests\ConfigurationModuleTTests.cs:line 19

System.ArgumentException
Property Get method was not found.
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
   at ModelBuilder.DefaultPropertyResolver.IsIgnored(IBuildConfiguration configuration, Object instance, PropertyInfo propertyInfo, Object[] args)
   at ModelBuilder.DefaultExecuteStrategy.AutoPopulateInstance(Object instance, Object[] args)
   at ModelBuilder.DefaultExecuteStrategy.Populate(IBuildCapability capability, Object instance, Object[] args)
   at ModelBuilder.DefaultExecuteStrategy.Build(Func`1 getCapability, Func`3 buildInstance, Type type, Object[] args)
   at ModelBuilder.DefaultExecuteStrategy.Build(PropertyInfo propertyInfo, Object[] args)
   at ModelBuilder.DefaultExecuteStrategy.PopulateProperty(PropertyInfo propertyInfo, Object instance, Object[] args)
   at ModelBuilder.DefaultExecuteStrategy.AutoPopulateInstance(Object instance, Object[] args)
   at ModelBuilder.DefaultExecuteStrategy.Populate(IBuildCapability capability, Object instance, Object[] args)
   at ModelBuilder.DefaultExecuteStrategy.Build(Func`1 getCapability, Func`3 buildInstance, Type type, Object[] args)
   at ModelBuilder.DefaultExecuteStrategy.Build(Type type, Object[] args)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant