Skip to content

Conversation

retailcoder
Copy link
Member

Extracted Rubberduck.Inspections namespace into its own assembly, moved things around to keep code compilable (e.g. VariableNameValidator is now under Rubberduck.Common).

With this PR Rubberduck runs any IInspection implementation located in any assembly under a \Plug-ins folder (under the Rubberduck.dll directory).

using Ninject.Extensions.Interception.Infrastructure.Language;
using Ninject.Extensions.NamedScope;
using Rubberduck.Inspections.Abstract;
using NLog;
Copy link
Member Author

Choose a reason for hiding this comment

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

oops, this shouldn't be here

private IEnumerable<Assembly> FindPlugins()
{
var basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
yield return Assembly.LoadFile(Path.Combine(basePath, "Rubberduck.Inspections.dll"));
Copy link
Member Author

@retailcoder retailcoder Mar 29, 2017

Choose a reason for hiding this comment

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

Rubberduck.Inspections.dll has dependencies on Rubberduck.dll, Rubberduck.Parsing.dll, Rubberduck.VBEditor.dll, Rubberduck.SmartIndenter.dll, and Rubberduck.SettingsProvider.dll; so Rubberduck.Inspections.dll is essentially a plug-in... but since it's the "core inspections package" we're loading it from the main assembly path.

.Where(type => type.BaseType == typeof (InspectionBase));
var inspections = assemblies
.SelectMany(a => a.GetTypes().Where(type => type.IsClass && !type.IsAbstract && type.GetInterfaces().Contains(typeof (IInspection))))
.ToList();
Copy link
Member Author

Choose a reason for hiding this comment

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

This means any .dll under the \Plug-ins folder can contain IInspection implementations, we'll load them, and bind them.


var items = filteredResults
.Where(result => !(result is AggregateInspectionResult))
.Where(result => result.GetType().Name != "AggregateInspectionResult")
Copy link
Member

Choose a reason for hiding this comment

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

makes stuff funny when renaming the type ...
We can't get the dependency in here and making this a special case smells, because we're violating LSP by special-casing this IInspectionResult...

This logic should be encapsulated into Inspection results in the first place:

 var items = filteredResults
     .Select(item => item.DefaultQuickFix)
     .OrderByDescending(fix = fix.Selection);

also a good moment to rename items to something like defaultQuickFixes

Copy link
Member

Choose a reason for hiding this comment

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

This is especially clean, since InspectionResultBase already implements this for us...

Copy link
Member Author

Choose a reason for hiding this comment

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

@Vogel612 well spotted - I forgot to get back to that hack after moving AggregateInspectionResult to the Rubberduck.UI.Inspections namespace, which makes the aggregate results nothing more than a presentation concern (which it really is after all) - I disagree that individual inspections should be responsible for aggregating their own results.

Copy link
Member

Choose a reason for hiding this comment

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

First of all, use nameof--that'll fix the type-renaming issue. Second, why not use the is?

Copy link
Member Author

Choose a reason for hiding this comment

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

@Hosch250 because Rubberduck.dll doesn't even know Rubberduck.Inspections.dll exists.

{40CC03E3-756C-4674-AF07-384115DEAEE2}.Release64|x64.Build.0 = Release|Any CPU
{40CC03E3-756C-4674-AF07-384115DEAEE2}.Release64|x86.ActiveCfg = Release|Any CPU
{40CC03E3-756C-4674-AF07-384115DEAEE2}.Release64|x86.Build.0 = Release|Any CPU
{AC4F1D22-D74B-45FF-AB0C-CC2A104FE023}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Copy link
Member Author

Choose a reason for hiding this comment

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

I believe we can kill all legacy configurations. I've only ever used Debug and Release for over a year; the xxxx64 configs have been useless since the unification of x86 and x64 installers IIRC.

@ThunderFrame is DebugAccess of any use?

I'll make this PR clean up these noisy configurations.

public interface IInspectionResult : IComparable<IInspectionResult>, IComparable
{
IEnumerable<IQuickFix> QuickFixes { get; }
bool HasQuickFixes { get; }
Copy link
Member

Choose a reason for hiding this comment

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

Not sure what you added this for, but I'm going to kill it when I make the quick fixes specify which inspections they can fix and take an inspection result for the specific details.

Copy link
Member Author

Choose a reason for hiding this comment

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

The ViewModel was working off InspectionResultBase, now IInspectionResult - I didn't want to change any functionality, just keep the code compilable... so the property had to get onto the interface.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, sure.

@retailcoder retailcoder merged commit cd0a83f into rubberduck-vba:next Mar 30, 2017
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