It's fairly commonplace for projects to reimplement common .NET types as internal to allow programmers to use modern C# language features while targeting older versions of .NET (e.g. you can use Extension Methods in C# 7.0 while still targeting .NET Framework 2.0 by declaring namespace System.Runtime.CompilerServices { internal class ExtensionAttribute : Attribute { ... } } ).
In a similar vein, I'd like to be able to use your PartialMixins tooling without my project needing to have a reference to PartialMixins.dll by having a private definition of the MixinAttribute.
So I'd be able to do something like this in a single file in my project:
using System;
namespace Mixins {
internal class MixinAttribute : Attribute {
public MixinAttribute( Type mixinType ) { }
}
}
namespace MyProject
{
internal class MyCommon
{
// etc
}
[Mixins.Mixin(typeof(MyCommon))]
public partial class MySubject
{
}
}
Motivation:
Avoids disclosing to consumers that a specific mixin tool is being used.
Allows projects targeting different versions of the PartialMixins NuGet package to work together without needing any <BindingRedirects>.
Smaller and simpler project output (i.e. no Mixin.dll to bundle, and without the Runtime loader/linker complaining about missing references if we don't bundle Mixin.dll with our redistributables).
Alternative solution:
Another possibility is allowing the fully-qualified name of the custom mixin attribute to be specified as an MSBuild property, e.g.:
Overview
It's fairly commonplace for projects to reimplement common .NET types as
internal
to allow programmers to use modern C# language features while targeting older versions of .NET (e.g. you can use Extension Methods in C# 7.0 while still targeting .NET Framework 2.0 by declaringnamespace System.Runtime.CompilerServices { internal class ExtensionAttribute : Attribute { ... } }
).In a similar vein, I'd like to be able to use your PartialMixins tooling without my project needing to have a reference to PartialMixins.dll by having a private definition of the
MixinAttribute
.So I'd be able to do something like this in a single file in my project:
Motivation:
<BindingRedirects>
.Mixin.dll
to bundle, and without the Runtime loader/linker complaining about missing references if we don't bundleMixin.dll
with our redistributables).Alternative solution:
Another possibility is allowing the fully-qualified name of the custom mixin attribute to be specified as an MSBuild property, e.g.:
The only requirement for a custom MixinAttribute is that it has a
Type
argument or property from which the mixin type can be inferred.