mgravell / fast-member

Automatically exported from code.google.com/p/fast-member
Apache License 2.0
1.02k stars 137 forks source link

TypeAccessor doesn't allow to manipulate internal/private properties #84

Open maxijuice opened 4 years ago

maxijuice commented 4 years ago

Hello,

I'm using EFCore.BulkExtensions. It's dependent on your library when it's needed to merge objects passed with ones returned from DbContext. The problem is that entity I use in DbSet, has internal fields. Unfortunately, TypeAccessor can't resolve them even though it's created with allowNonPublicAccessors = true.

I've checked this on a simple scenario and here are the results

static void Main(string[] args)
 {
     var accessor = TypeAccessor.Create(typeof(TestClass), true);  
     Console.WriteLine(accessor.GetMembers().Count);  // output is 0
}

class TestClass
 {
      internal string InternalField { get; set; }
      private int PrivateField { get; set; }
}

Is it a desired behavior?

robertjak commented 4 years ago

I've just created a pull request with a fix for the issue above, so the internal and private properties are read as well.

Private fields are still ignored (?), I suppose they are almost never needed, but this could be easily fixed/changed as well.