Menu

#602 Adhoc Addin Installation is cumbersome

3.0
open-postponed
nobody
framework (182)
5
2009-06-26
2007-04-30
Eli Lopian
No

The addin installation is cumberson and should be done automatically. i.e. When a test method/class has more attributes, these should be installed.
This can be done by parsing the assemblies referenced by the test assembly:

Example fix:
in src\NUnitCore\core\CoreExtensions.cs

public void InstallAdhocExtensions(Assembly assembly)
{
InstallAdhocExtensionsForOneAssembly(assembly);
foreach (AssemblyName name in assembly.GetReferencedAssemblies())
{
try
{
Assembly referencedAssembly = Assembly.Load(name);
// ignore mscorlib and nunit assemblies
if (referencedAssembly != typeof(object).Assembly &&
referencedAssembly != this.GetType().Assembly)
{
InstallAdhocExtensionsForOneAssembly(Assembly.Load(referencedAssembly));
}
}
catch
{
}
}
}
private void InstallAdhocExtensionsForOneAssembly(Assembly assembly)
{
foreach (Type type in assembly.GetExportedTypes())
{
if (type.GetCustomAttributes(typeof(NUnitAddinAttribute), false).Length == 1)
InstallAddin(type);
}
}

Discussion

  • Eli Lopian

    Eli Lopian - 2007-04-30
    • summary: Adhoc Addin Installation in cumberson --> Adhoc Addin Installation is cumbersome
     
  • Charlie Poole

    Charlie Poole - 2007-04-30

    Logged In: YES
    user_id=586918
    Originator: NO

    This fix makes the assumption that the addin is defined in the same assembly as the attribute, which is not the pattern I have been advocating for writing add-ins. Unfortunately, this bug points out to me that all my samples use the same pattern. I'll put the fix in, but I don't think it's a long-term solution - the so-called 'adhoc' extension facility is not documented because it was only intended for temporary use by extension developers.

     
  • Eli Lopian

    Eli Lopian - 2007-04-30

    Logged In: YES
    user_id=1781735
    Originator: YES

    Thanks for explaining this.
    We do need a better long term solution.

     
  • Charlie Poole

    Charlie Poole - 2007-05-03
    • status: open --> open-postponed
     
  • Charlie Poole

    Charlie Poole - 2007-05-03

    Logged In: YES
    user_id=586918
    Originator: NO

    Postponed due to problems that arise when the same addin is referenced by multiple tests.

     
  • Charlie Poole

    Charlie Poole - 2009-06-26
    • milestone: 604480 --> 3.0
     

Log in to post a comment.

MongoDB Logo MongoDB