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

Implement new API for finding standard extensions #1518

Merged
merged 3 commits into from
Nov 28, 2024
Merged

Conversation

CharliePoole
Copy link
Collaborator

@CharliePoole CharliePoole commented Nov 27, 2024

Fixes #1504 Replaces PR #1506 Part of #488

@manfred-brands I'd appreciate your re-review based on the changes made since you reviewed the original PR (second commit)

Copy link
Member

@manfred-brands manfred-brands left a comment

Choose a reason for hiding this comment

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

@CharliePoole fundamentally code looks good.
A few small remarks/opinions.

/// <param name="hostAssembly">An assembly that supports extensions.</param>
public void FindStandardExtensions(Assembly hostAssembly)
{
bool isChocolateyPackage = System.IO.File.Exists(Path.Combine(hostAssembly.Location, "VERIFICATION.txt"));
Copy link
Member

Choose a reason for hiding this comment

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

Should this use _fileSystem.GetDirectory

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did that for the FindExtensions method, but in this case it seemed unnecessarily complicated. That is, I would convert a path to an IDirectory, get an IFile from that and then convert them back to a path. But since the calling assembly must always exist, there's always a real path to start with.

Copy link
Member

Choose a reason for hiding this comment

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

Would that argument not also cover _startDir which comes from the same host assembly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see your point. But of course startDir is defined in a different method and reused multiple times, so it seems worth the trouble. Probably, it would be better to combine those two methods and just get startDir once. I'll add a TODO to my local copy to remind me to do that next time I'm in it.

? new[] { "nunit-extension-*/**/tools/", "nunit-extension-*/**/tools/*/" }
: new[] { "NUnit.Extension.*/**/tools/", "NUnit.Extension.*/**/tools/*/" };

FindExtensionAssemblies(hostAssembly, extensionPatterns);
Copy link
Member

Choose a reason for hiding this comment

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

Personally I prefer methods returning the set of found assemblies instead of setting a field.
But the approach is pre-existing.

ProcessAddinsFiles(initialDirectory, false);
}

/// <summary>
Copy link
Member

Choose a reason for hiding this comment

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

Should we not use <inheritdoc /> to prevent risking interface and implementation documentation getting out of sync?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In my own code I have always avoided it but I know others use it. For me it's a question of compatibility. If somebody wants to use a different compiler or ide, do you know if will <inhreitdoc> always work? In any case, if we decided to always use it, then I'd do one big PR rather than changing things one at a time. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

The compiler does the copying to the XML file.
See inheritdoc

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The Microsoft compilers do. But maybe I'm beating a dead horse. Currently, I can't find any viable alternatives to the MS compiler, such as we used to have a long time ago. And of course we're using it to build the engine anyway.

I don't like to combine unrelated changes in the same PR, so I'll create an issue.

@CharliePoole CharliePoole merged commit 01294c2 into main Nov 28, 2024
4 checks passed
@CharliePoole CharliePoole deleted the issue-1504 branch November 28, 2024 17:02
@CharliePoole
Copy link
Collaborator Author

@manfred-brands I implemented one of your three suggestions and merged so as to be able to work some issues that depend on this change. Feel free to comment further, particularly wrt <inheritdoc> which may need to be a separate refactoring issue.

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.

Use a programmed search to locate extensions in place of default addins files.
2 participants