Skip to content
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

Merged
merged 7 commits into from
Mar 12, 2018
Merged

Implements #215 #221

merged 7 commits into from
Mar 12, 2018

Conversation

wmjordan
Copy link
Contributor

@wmjordan wmjordan commented Mar 2, 2018

This implements #215 by allowing users to annotate members with RepackDropAttribute (customizable via /repackdrop:AttributeName).

@@ -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) {
Copy link
Collaborator

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

Copy link
Contributor Author

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?

@@ -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);
Copy link
Collaborator

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

Copy link
Contributor Author

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?

/// 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 {
Copy link
Collaborator

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?

Copy link
Contributor Author

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

InputAssemblies = cmd.OtherAguments;
RepackDropAttribute = cmd.Option("repackdrop");
if (String.IsNullOrWhiteSpace(RepackDropAttribute)) {
RepackDropAttribute = "RepackDropAttribute";
Copy link
Collaborator

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)

Copy link
Contributor Author

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.

@wmjordan
Copy link
Contributor Author

wmjordan commented Mar 5, 2018

Could anyone tell me why the AppVeyor build failed?

@timotei
Copy link
Collaborator

timotei commented Mar 5, 2018

@wmjordan Yes, it seems that the tests failed:

8139  Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0
8140
8141Errors and Failures:
81421) Test Failure : ILRepack.IntegrationTests.Scenarios.GivenDotNet462AppReferencingMicrosoftBclAsyncAndSystemRuntime_MergedApplicationRunsSuccessfully
8143     Process has not ended.
8144  Expected: True
8145  But was:  False
8146
8147at ILRepack.IntegrationTests.Scenarios.RunScenario(String scenarioName) in C:\projects\il-repack\ILRepack.IntegrationTests\Scenarios.cs:line 69```

@wmjordan
Copy link
Contributor Author

wmjordan commented Mar 5, 2018

Thank you for replying and spotting it out.
I did not have DotNet 4.6.2 SDK on my VS. I unloaded the project. Could it be the reason which leaded to the failure of the test?

Copy link
Owner

@gluck gluck left a 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.

@@ -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))
Copy link
Owner

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

Copy link
Contributor Author

@wmjordan wmjordan Mar 8, 2018

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?

Copy link
Contributor Author

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?

Copy link
Owner

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)

Copy link
Contributor Author

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

@@ -97,6 +97,8 @@ public List<string> AllowedDuplicateNameSpaces
get { return allowedDuplicateNameSpaces; }
}

public string RepackDropAttribute { get; set; }
Copy link
Owner

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

Copy link
Contributor Author

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.

@@ -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")) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here as well

@wmjordan
Copy link
Contributor Author

wmjordan commented Mar 10, 2018

The new commit managed to pass the checks.
The test failure might not be related to this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants