Enhancer Bug

6 posts, 0 answers
  1. Pål
    Pål avatar
    53 posts
    Member since:
    Sep 2012

    Posted 19 Sep 2010 Link to this post

    Hi.

    I think I have found a bug in the new enhancer. The enhancer tries to resolve a referenced assembly but cannot find it (in the obj folder I think)

    The exception occurs when using three assemblies and a persistent type in one assembly references a persisten type in another. Both classes extending a third persistent class a third assembly.

    The exception is created in method:
    namespace Mono.Cecil
      
        public abstract class BaseAssemblyResolver : IAssemblyResolver {
      
            public virtual AssemblyDefinition Resolve(AssemblyNameReference name){
              
                AssemblyDefinition assemblyInGac = this.SearchDirectory(name, this.directories);
      
                (...)
      
                throw new FileNotFoundException("Could not resolve: " + name);
            }
        }
    }

    The 'SearchDirectory' function tries to locate the referenced assembly but cannot find it. It loops through a list of directories bu the list only contains "." and "bin\"
    private AssemblyDefinition SearchDirectory(AssemblyNameReference name, IEnumerable<string> directories)
    {
      string[] strArray = new string[] { ".exe", ".dll" };
      foreach (string str in directories)
      {
        foreach (string str2 in strArray)
        {
          string path = Path.Combine(str, name.Name + str2);
          if (File.Exists(path))
          {
            return this.GetAssembly(path);
          }
        }
      }
      return null;
    }

    The assembly is passed in to VEnhancer and but does not get forwarded into Cecil it seems.

    To recteate problem:
     - Create three Class Libraries, Lib1, Lib2 and Lib3
     - Create One Persistent Class in each library: Lib1.BaseClass, Lib2.DerivedReferencedClass and Lib3.DerivedClass
     - The persistent classes in Lib2 and Lib3 should extend BaseClass in Lib1
     - Add a reference field in Lib3.DerivedClass to Lib2.DerivedReferencedClass
     - Update Config References
     - Compile solution

    The build goes fine but the enhancer should fail.

    I have created a test solution (VS2010) which will produce the error. If you want me to send it to you (need an email address though) please let me know.

    Regards

    Pål
  2. Pål
    Pål avatar
    53 posts
    Member since:
    Sep 2012

    Posted 19 Sep 2010 Link to this post

    I also found a workaround if enyone else is having the same problem:

    Change the build output path from 'bin\debug' (default) to 'bin\'. Same for release.

    Pål
  3. DevCraft banner
  4. Pål
    Pål avatar
    53 posts
    Member since:
    Sep 2012

    Posted 19 Sep 2010 Link to this post

    Hi.

    Found another one I'm afraid.

    Persistent struct fail enhancement when GetHashCode is overridden.

    This struct will fail:
    [Telerik.OpenAccess.Persistent()]
    public struct MyPersistentStruct {
      
        private decimal m_Value;
      
        public MyPersistentStruct(decimal value) {
            m_Value = value;
        }
      
        public override int GetHashCode() {
            return m_Value.GetHashCode();
        }
    }

    Exception occurs in class CecilValueTypeAwareness.Call(MethodReference, Instruction).

    The Body property returns null, so a null ref exception is thrown. Actual error is in Mono.Cecil.MethodDefinition. It fails to load the method body of the overridden GetHashCode() function.

    Regards.

    Pål
  5. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 24 Sep 2010 Link to this post

    Hello Pål,
    I have fixed the problem, sorry for that, I have updated your Telerik Points.

    The workaround is to use a variable inbetween:
    public override int GetHashCode() 
    {
        var tmp = m_Value;
        return tmp.GetHashCode(); 

    The next build will contain the fix. We are just planning a custom build for next week or the week after.

    Regards,
    Jan Blessenohl
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Pål
    Pål avatar
    53 posts
    Member since:
    Sep 2012

    Posted 24 Sep 2010 Link to this post

    Excellent. :-)

    I have a couple other aswell:

    1.    Nested types get persisted correctly but does not load any fields on retrieve.

    2.    Changes made to fields in the IInstanceCallbacks.PreStore() method does not get persisted.

    E.g
    void IInstanceCallbacks.PreStore() {
        m_Value = 1234;
    }

    These both function well in version 2010.1.312.2

    Also. I uploaded a project in the Support section demonstrating the 'multiple assemblies' problem described above.

    Thanks

    Pål
  7. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 29 Sep 2010 Link to this post

    Hi Pål,
    You have found a bigger problem in the new enhancer. We do not intercept field access inside methods of nested types. We will make a custom build asap. The only workaround is to move your classes into the namespace.

    Best wishes,
    Jan Blessenohl
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
DevCraft banner