-
Notifications
You must be signed in to change notification settings - Fork 217
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
Implements #215 #221
Implements #215 #221
Conversation
…ing." This reverts commit 29a3793.
…le via "repackdrop")
ILRepack/RepackImporter.cs
Outdated
@@ -119,7 +119,11 @@ public MethodReference Import(MethodReference reference, IGenericParameterProvid | |||
|
|||
public TypeDefinition Import(TypeDefinition type, Collection<TypeDefinition> col, bool internalize) | |||
{ | |||
_logger.Verbose("- Importing " + type); | |||
if (CanInclude(type) == false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current code uses spaces (4 spaces) instead of tab, let's keep consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer tabs in all my projects.
Can you upload an editor config file to ensure that spacing consistency (as well as others) so I can follow it?
ILRepack/RepackImporter.cs
Outdated
@@ -119,7 +119,11 @@ public MethodReference Import(MethodReference reference, IGenericParameterProvid | |||
|
|||
public TypeDefinition Import(TypeDefinition type, Collection<TypeDefinition> col, bool internalize) | |||
{ | |||
_logger.Verbose("- Importing " + type); | |||
if (CanInclude(type) == false) { | |||
_logger.Log("Repack dropped " + type.FullName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also logged in the CanInclude
method, I'd say we only log once here, and rewrite it as; Type <X> dropped as it was marked with the drop attribute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. I forgot that CanInclude also logged that. Shall I simply remove the log here?
ILRepack/RepackImporter.cs
Outdated
/// Clones a field to a newly created type | ||
/// </summary> | ||
private void CloneTo(FieldDefinition field, TypeDefinition nt) | ||
private bool CanInclude<TMember>(TMember member) where TMember : ICustomAttributeProvider, IMemberDefinition { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be renamed to ShouldDropForRepacking
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I renamed that method and use an if
in each place to filter the result where CloneTo
was called
ILRepack/RepackOptions.cs
Outdated
InputAssemblies = cmd.OtherAguments; | ||
RepackDropAttribute = cmd.Option("repackdrop"); | ||
if (String.IsNullOrWhiteSpace(RepackDropAttribute)) { | ||
RepackDropAttribute = "RepackDropAttribute"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will always drop the types flagged with the attribute, I think we want to only do this if the option is enabled. (/repackdrop or /repackdrop:attribute)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I agree with that.
…option. Performance tweak for the RepackDrop support.
Could anyone tell me why the AppVeyor build failed? |
@wmjordan Yes, it seems that the tests failed:
|
Thank you for replying and spotting it out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor remarks but LGTM overall.
Would have to check by the test fails though, but I fear it might be unrelated.
ILRepack/RepackImporter.cs
Outdated
@@ -120,6 +120,11 @@ public MethodReference Import(MethodReference reference, IGenericParameterProvid | |||
public TypeDefinition Import(TypeDefinition type, Collection<TypeDefinition> col, bool internalize) | |||
{ | |||
_logger.Verbose("- Importing " + type); | |||
bool hasFilter = String.IsNullOrEmpty(_options.RepackDropAttribute) == false; | |||
if (hasFilter && ShouldDrop(type)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
considering moving hasFilter
check inside ShouldDrop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought placing the result (hasFilter) outside of ShouldDrop
can save some calculations since it would not change during merging.
For performance considerations, maybe it is better to promote it to a read-only field.
For code clearance, placing it into ShouldDrop
might be reasonable.
What kind of approach would you prefer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or shall I refactor both hasFilter
and ShouldDrop
into a new type, for instance RepackFilter
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appreciate the concern for performance, but I prefer code clarity over performance speculation (IMO perf difference won't be noticeable, partly because inlining and partly because it's negligible compared to the rest of the processing here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, moved hasFilter
check into ShouldDrop
ILRepack/RepackOptions.cs
Outdated
@@ -97,6 +97,8 @@ public List<string> AllowedDuplicateNameSpaces | |||
get { return allowedDuplicateNameSpaces; } | |||
} | |||
|
|||
public string RepackDropAttribute { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent is off by 1 here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, you are right. That file needs reformatting.
ILRepack/RepackOptions.cs
Outdated
@@ -224,8 +226,15 @@ void Parse() | |||
LogVerbose = cmd.Modifier("verbose"); | |||
LineIndexation = cmd.Modifier("index"); | |||
|
|||
// everything that doesn't start with a '/' must be a file to merge (verify when loading the files) | |||
InputAssemblies = cmd.OtherAguments; | |||
if (cmd.HasOption("repackdrop")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here as well
The new commit managed to pass the checks. |
This implements #215 by allowing users to annotate members with
RepackDropAttribute
(customizable via /repackdrop:AttributeName).