1

First of all this issue only happens when I run the db4oTool against an assembly taregeting the Mono For Android profile, targeting a normal .Net class library works fine.

The issue: I am running the following command as a post build event:

Db4oTool.exe -tp -vv -debug -collections -by-attribute:DoNotDb4OEnhance -not $(TargetPath)

This results in the following error printed to the output window: (Full Log here)

Entering method 'System.Int32 Ats.Loto.Model.EnergyTagExtensions::GetNextTagNumber(System.Collections.Generic.IList1<Ats.Loto.Model.EnergyTag>,Ats.Loto.Model.EnergyType)' System.NullReferenceException: Object reference not set to an instance of an object. at Db4oTool.TA.TACollectionsStep.<TAEnabledCollectionInstantiations>b__4(Instruction candidate) at Db4oTool.Core.InstrumentationUtil.<Where>d__0.MoveNext() at Db4oTool.TA.TACollectionsStep.InstrumentCollectionInstantiation(MethodDefinition methodDefinition) at Db4oTool.TA.TACollectionsStep.Process(MethodDefinition method) at Db4oTool.TA.TAInstrumentation.ProcessMethod(MethodDefinition method) at Db4oTool.Core.AbstractAssemblyInstrumentation.ProcessMethods(IEnumerable methods) at Db4oTool.Core.AbstractAssemblyInstrumentation.ProcessTypes(IEnumerable1 types, Predicate1 filter, Action1 action) at Db4oTool.Core.AbstractAssemblyInstrumentation.ProcessAssembly() at Db4oTool.Core.AbstractAssemblyInstrumentation.Run(InstrumentationContext context) at Db4oTool.Core.InstrumentationPipeline.Run() at Db4oTool.Program.RunPipeline(ProgramOptions options) at Db4oTool.Program.Run(ProgramOptions options) at Db4oTool.Program.Main(String[] args)

If I remove the -collections attribute it will work. I try to exclude the "EnergyTagExtensions" class with the

-by-attribute:DoNotDb4OEnhance -not

switches but it either has no effect or I'm doing it wrong.

Below is the class that I think is causing the db4otool to be unhappy based on the log.

[DoNotDb4OEnhance]
public static class EnergyTagExtensions
{
    public static int GetNextTagNumber(this IList<EnergyTag> source, EnergyType activeEnergyType)
    {
        if (source.Count == 0)
            return 1;

        var concernedTags =
            source.Where(c => c.TagId != null && c.TagId.StartsWith(activeEnergyType.Prefix)).OrderBy(
                c => c.TagIndex).ToList();

        if (!concernedTags.Any())
            return 1;

        return (concernedTags.Max(c => c.TagIndex) + 1);
    }
}

Any ideas on how to get this working? Thanks in advance for any insight.

Travis
  • 241
  • 1
  • 10

1 Answers1

1

Regarding Db4oTool not "respecting" the filter, the problem is that you need to enter the attribute's fully qualified name.

Also note that you cannot omit Attribute from the attribute name (I assume that you have followed .Net best practices and named your attribute like DoNotDb4OEnhanceAttribute)

I just filled an issue to improve Db4oTool documentation.

Regarding the NullReferenceException, I'll try to reproduce but if I fail to, can you send me, privately, a small sample assembly that reproduces it?

EDIT - Mar/01/2012

I checked Monodroid documentation and found that Func<T, TResult> is indeed defined in mscorlib (on Monodroid), so probably Db4oTool is looking up types in the wrong assembly

Vagaus
  • 4,174
  • 20
  • 31
  • I renamed my attribute to be suffixed with "Attribute" and included the fully qualified name of the parameter in the call to the db4oTool. The db4oTool still throws the same exception. Here is the assembly I am trying to run the db4oTool against. [link](http://dl.dropbox.com/u/20210444/M4AModel.dll) Let me know if you want the source code as well. – Travis Jan 25 '12 at 14:19
  • strange. You did not have "Attribute" as part of your attribute name before? By "qualified name of the parameter" you mean "fully qualified name of the *attribute*", right? And no, I don't need the source code. I'll take a look in this later today – Vagaus Jan 26 '12 at 10:07
  • Correct, Originally I did not have "Attribute" in the attribute name but I do now. Yes, I meant fully qualified name of the attribute, not parameter, sorry for the confusion. – Travis Jan 26 '12 at 22:19
  • I am using Mono For Android version 4.0.3. I checked for updates to the product and I am using the newest beta build. – Travis Feb 07 '12 at 21:03