Example #1
0
        private string BuildConfigFile(string workingDirectory)
        {
            string configFilePath = Path.Combine(workingDirectory, "config.xml");

            RoslynSdkConfiguration config = new RoslynSdkConfiguration();

            config.PluginKeyDifferentiator = this.FindPluginKey();

            config.RepositoryKey        = this.repositoryKey;
            config.RepositoryName       = this.repositoryName;
            config.RepositoryLanguage   = this.language;
            config.RulesXmlResourcePath = GetAbsoluteResourcePath(RelativeRulesXmlResourcePath);

            if (!string.IsNullOrWhiteSpace(this.sqaleFilePath))
            {
                config.SqaleXmlResourcePath = GetAbsoluteResourcePath(RelativeSqaleXmlResourcePath);
            }

            foreach (KeyValuePair <string, string> kvp in this.pluginProperties)
            {
                config.Properties[kvp.Key] = kvp.Value;
            }

            config.Save(configFilePath);
            return(configFilePath);
        }
        /// <summary>
        /// Loads and returns rules from the specified XML file
        /// </summary>
        public static RoslynSdkConfiguration Load(string fileName)
        {
            if (string.IsNullOrWhiteSpace(fileName))
            {
                throw new ArgumentNullException("fileName");
            }

            RoslynSdkConfiguration model = Serializer.LoadModel <RoslynSdkConfiguration>(fileName);

            model.FileName = fileName;
            return(model);
        }
        private string BuildConfigFile(string workingDirectory)
        {
            string configFilePath = Path.Combine(workingDirectory, "config.xml");

            RoslynSdkConfiguration config = new RoslynSdkConfiguration
            {
                PluginKeyDifferentiator = FindPluginKey(),

                RepositoryKey        = repositoryKey,
                RepositoryName       = repositoryName,
                RepositoryLanguage   = language,
                RulesXmlResourcePath = GetAbsoluteResourcePath(RelativeRulesXmlResourcePath)
            };

            foreach (KeyValuePair <string, string> kvp in pluginProperties)
            {
                config.Properties[kvp.Key] = kvp.Value;
            }

            config.Save(configFilePath);
            return(configFilePath);
        }
        private static void AssertExpectedPropertyDefinitionValue(string propertyName, string expectedValue, RoslynSdkConfiguration actualConfig)
        {
            Assert.IsNotNull(actualConfig.Properties, "Configuration Properties should not be null");

            Assert.IsTrue(actualConfig.Properties.ContainsKey(propertyName), "Expected property is not set: {0}", propertyName);

            Assert.AreEqual(expectedValue, actualConfig.Properties[propertyName], "Property does not have the expected value. Property: {0}", propertyName);
        }
        private string BuildConfigFile(string workingDirectory)
        {
            string configFilePath = Path.Combine(workingDirectory, "config.xml");

            RoslynSdkConfiguration config = new RoslynSdkConfiguration();

            config.PluginKeyDifferentiator = this.FindPluginKey();

            config.RepositoryKey = this.repositoryKey;
            config.RepositoryName = this.repositoryName;
            config.RepositoryLanguage = this.language;
            config.RulesXmlResourcePath = GetAbsoluteResourcePath(RelativeRulesXmlResourcePath);

            if (!string.IsNullOrWhiteSpace(this.sqaleFilePath))
            {
                config.SqaleXmlResourcePath = GetAbsoluteResourcePath(RelativeSqaleXmlResourcePath);
            }

            foreach(KeyValuePair<string,string> kvp in this.pluginProperties)
            {
                config.Properties[kvp.Key] = kvp.Value;
            }

            config.Save(configFilePath);
            return configFilePath;
        }