Esempio n. 1
0
        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)));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 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;
 }
Esempio n. 5
0
 public void TestGetTestPluginVersionWrongType()
 {
     new Action(() => PluginInterfaceVersionAttribute.GetInterfaceVersion(typeof(object)))
     .ShouldThrow <ArgumentException>();
 }
Esempio n. 6
0
 public void TestGetLogAnalyserPluginVersionFromImplementation()
 {
     PluginInterfaceVersionAttribute.GetInterfaceVersion(typeof(TestlogAnalyserPlugin)).Should().Be(PluginInterfaceVersion.First);
 }
Esempio n. 7
0
 public void TestGetTestPluginVersion()
 {
     PluginInterfaceVersionAttribute.GetInterfaceVersion(typeof(ITestPlugin)).Should().Be(new PluginInterfaceVersion(42));
 }
Esempio n. 8
0
 public void TestGetLogAnalyserPlugin()
 {
     PluginInterfaceVersionAttribute.GetInterfaceVersion(typeof(ITestPluginWithoutExplicitVersion)).Should().Be(PluginInterfaceVersion.First);
 }
Esempio n. 9
0
 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");
 }
Esempio n. 12
0
 public void TestFileFormatPluginVersion()
 {
     PluginInterfaceVersionAttribute.GetInterfaceVersion(typeof(ILogFileFormatMatcherPlugin)).Should().Be(new PluginInterfaceVersion(1), "because this interface hasn't been modified yet");
 }