This is a migrated thread and some comments may be shown as answers.

Enhancer Bug

5 Answers 70 Views
Design Time (Visual Designer & Tools)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Pål
Top achievements
Rank 1
Pål asked on 19 Sep 2010, 05:52 PM
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

5 Answers, 1 is accepted

Sort by
0
Pål
Top achievements
Rank 1
answered on 19 Sep 2010, 06:38 PM
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
0
Pål
Top achievements
Rank 1
answered on 19 Sep 2010, 09:39 PM
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
0
Jan Blessenohl
Telerik team
answered on 24 Sep 2010, 02:15 PM
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
0
Pål
Top achievements
Rank 1
answered on 24 Sep 2010, 02:38 PM
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
0
Jan Blessenohl
Telerik team
answered on 29 Sep 2010, 04:46 PM
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
Tags
Design Time (Visual Designer & Tools)
Asked by
Pål
Top achievements
Rank 1
Answers by
Pål
Top achievements
Rank 1
Jan Blessenohl
Telerik team
Share this question
or