public void TestReflectPlugin2() { var plugin = "sql.dll"; if (File.Exists(plugin)) { File.Delete(plugin); } var builder = new PluginBuilder("Simon", "sql", "sql", "SMI", "none of your business", "go away"); builder.ImplementInterface <IFileFormatPlugin>("sql.LogFilePlugin"); builder.Save(); var scanner = new PluginAssemblyLoader(); var description = scanner.ReflectPlugin(plugin); description.Author.Should().Be("SMI"); description.Website.Should().Be(new Uri("none of your business", UriKind.RelativeOrAbsolute)); description.Description.Should().Be("go away"); description.PluginImplementations.Should().HaveCount(1); description.PluginImplementations.Should().Contain(x => x.InterfaceType == typeof(IFileFormatPlugin)); var implementationDescription = description.PluginImplementations[0]; implementationDescription.FullTypeName.Should().Be("sql.LogFilePlugin"); implementationDescription .Version.Should().Be(PluginInterfaceVersionAttribute.GetInterfaceVersion(typeof(IFileFormatPlugin))); }
public static List <PluginError> FindCompatibilityErrors(IPluginPackageIndex index) { var errors = new List <PluginError>(); if (index.PluginArchiveVersion < PluginArchive.MinimumSupportedPluginArchiveVersion) { errors.Add(new PluginError("The plugin targets an older version of Tailviewer and must be compiled against the current version in order to be usable")); } if (index.PluginArchiveVersion > PluginArchive.CurrentPluginArchiveVersion) { errors.Add(new PluginError("The plugin targets a newer version of Tailviewer and must be compiled against the current version in order to be usable")); } if (index.ImplementedPluginInterfaces != null) { foreach (var implementation in index.ImplementedPluginInterfaces) { if (TryResolvePluginInterface(implementation, out var @interface)) { var currentInterfaceVersion = PluginInterfaceVersionAttribute.GetInterfaceVersion(@interface); var implementedInterfaceVersion = new PluginInterfaceVersion(implementation.InterfaceVersion); if (implementedInterfaceVersion < currentInterfaceVersion) { errors.Add(new PluginError($"The plugin implements an older version of '{@interface.FullName}'. It must target the current version in order to be usable!")); } else if (implementedInterfaceVersion > currentInterfaceVersion) { errors.Add(new PluginError($"The plugin implements a newer version of '{@interface.FullName}'. It must target the current version in order to be usable!")); } } else { // If a plugin unfortunately implements an interface that is not known to this tailviewer, // then it is bad news because that means we won't be able to load its assembly! errors.Add(new PluginError($"The plugin implements an unknown interface '{implementation.InterfaceTypename}' which is probably part of a newer tailviewer version. The plugin should target the current version in order to be usable!")); } } } return(errors); }
public void TestFileFormatPluginVersion() { PluginInterfaceVersionAttribute.GetInterfaceVersion(typeof(ILogFileOutlinePlugin)).Should().Be(new PluginInterfaceVersion(2), "because this interface has been broken once"); }
public PluginImplementationDescription(string fullTypeName, Type @interface) { FullTypeName = fullTypeName; Version = PluginInterfaceVersionAttribute.GetInterfaceVersion(@interface); InterfaceType = @interface; }
public void TestGetTestPluginVersionWrongType() { new Action(() => PluginInterfaceVersionAttribute.GetInterfaceVersion(typeof(object))) .ShouldThrow <ArgumentException>(); }
public void TestGetLogAnalyserPluginVersionFromImplementation() { PluginInterfaceVersionAttribute.GetInterfaceVersion(typeof(TestlogAnalyserPlugin)).Should().Be(PluginInterfaceVersion.First); }
public void TestGetTestPluginVersion() { PluginInterfaceVersionAttribute.GetInterfaceVersion(typeof(ITestPlugin)).Should().Be(new PluginInterfaceVersion(42)); }
public void TestGetLogAnalyserPlugin() { PluginInterfaceVersionAttribute.GetInterfaceVersion(typeof(ITestPluginWithoutExplicitVersion)).Should().Be(PluginInterfaceVersion.First); }
public void TestPluginVersion() { PluginInterfaceVersionAttribute.GetInterfaceVersion(typeof(IWidgetPlugin)).Should().Be(PluginInterfaceVersion.First, "because the widget plugin hasn't been changed yet"); }
public void TestFileFormatPluginVersion() { PluginInterfaceVersionAttribute.GetInterfaceVersion(typeof(IFileFormatPlugin)).Should().Be(PluginInterfaceVersion.First); }
public void TestGetDataSourceAnalyserPluginVersion() { PluginInterfaceVersionAttribute.GetInterfaceVersion(typeof(IDataSourceAnalyserPlugin)).Should().Be(new PluginInterfaceVersion(2), "because this interface has been modified once"); }
public void TestFileFormatPluginVersion() { PluginInterfaceVersionAttribute.GetInterfaceVersion(typeof(ILogFileFormatMatcherPlugin)).Should().Be(new PluginInterfaceVersion(1), "because this interface hasn't been modified yet"); }