-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better support for dropping attributes #345
Comments
To clarify, are you looking to drop the members marked with an attribute or the attribute itself? Ideally if you could provide a tiny C# console app that demonstrates what you want and what your desired behavior is. |
I'm thinking of this: [Attribute1] //drop these
class A { }
[Attribute2] //also drop these
class B { } If I want to drop both of these attributes, I need to run ILRepack twice with each configuration set to drop one of these two attributes. The bottleneck is in public string RepackDropAttribute { get; set; } And in // skip members marked with a custom attribute named as /repackdrop:RepackDropAttribute
var shouldDrop = member.HasCustomAttributes
&& member.CustomAttributes.FirstOrDefault(attr => attr.AttributeType.Name == _options.RepackDropAttribute) != null; If there was, say, RepackDropAttribute = cmd.Option("repackdrop"); would be changed to this: RepackDropAttribute = cmd.Option("repackdrop").Split(';'); Since semicolons are prohibited in C# namings, there would be no name conflicts in the process. As far as I'm aware there is nothing else stopping this from being implemented. |
Thanks, your answer doesn't clearly answer my question: To clarify, are you looking to drop the members marked with an attribute or the attribute itself? In other words, for
do you expect just the attribute to be deleted, or class A as well? |
I want to drop the members marked with the attribute, which is exactly what ILRepack does. But it only drops one attribute per run, so I need to create multiple configurations and them run them all in succession before building. I'm proposing a way to drop all members marked with at least one of the attributes provided. So, to drop both classes A and B, I would be able to write: <ILRepack Internalize="false" InputAssemblies="$(OutputPath)DLL.dll" TargetKind="Dll" DebugInfo="true" OutputFile="$(OutputPath)DLL.dll" RepackDropAttribute="Attribute1;Attribute2"/> instead of running ILRepack twice: <ILRepack Internalize="false" InputAssemblies="$(OutputPath)DLL.dll" TargetKind="Dll" DebugInfo="true" OutputFile="$(OutputPath)DLL.dll" RepackDropAttribute="Attribute1"/>
<ILRepack Internalize="false" InputAssemblies="$(OutputPath)DLL.dll" TargetKind="Dll" DebugInfo="true" OutputFile="$(OutputPath)DLL.dll" RepackDropAttribute="Attribute2"/> |
Here you go: |
I need to drop multiple types with different attributes and I've noticed that due to
RepackImporter.ShouldDrop<TMerge>()
, ILMerge supports only one attribute. Why? I suggest supporting multiple attributes separated by a semicolon (this won't collide with any naming conventions and complement MSBuild item collections).Also, I noticed that the code checks only for fields, methods, types, events and properties. Hence I suggest including module and assembly attributes as well.
The text was updated successfully, but these errors were encountered: