public static RoslynExportProfile Load(TextReader reader) { XmlSerializer serializer = new XmlSerializer(typeof(RoslynExportProfile)); RoslynExportProfile profile = serializer.Deserialize(reader) as RoslynExportProfile; return(profile); }
private static async Task <RoslynExportProfile> DownloadQualityProfileExport(HttpClient client, QualityProfile profile, Language language, CancellationToken token) { var roslynExporterName = CreateRoslynExporterName(language); string api = CreateQualityProfileExportUrl(profile, language, roslynExporterName); HttpResponseMessage response = await InvokeGetRequest(client, api, token); using (Stream stream = await response.Content.ReadAsStreamAsync()) using (var reader = new StreamReader(stream)) { return(RoslynExportProfile.Load(reader)); } }
public static RoslynExportProfile CreateExport(RuleSet ruleSet, IEnumerable<PackageName> packages, IEnumerable<AdditionalFile> additionalFiles) { string xml = TestRuleSetHelper.RuleSetToXml(ruleSet); var ruleSetXmlDoc = new XmlDocument(); ruleSetXmlDoc.LoadXml(xml); var export = new RoslynExportProfile { Configuration = new Configuration { RuleSet = ruleSetXmlDoc.DocumentElement, AdditionalFiles = additionalFiles.ToList() }, Deployment = new Deployment { NuGetPackages = packages.Select(x => new NuGetPackageInfo { Id = x.Id, Version = x.Version.ToNormalizedString() }).ToList() } }; return export; }
private QualityProfile ConfigureProfileExport(RoslynExportProfile export, Language language) { var profile = new QualityProfile { Language = SonarQubeServiceWrapper.GetServerLanguageKey(language) }; this.sonarQubeService.ReturnProfile[language] = profile; this.sonarQubeService.ReturnExport[profile] = export; return profile; }
bool ISonarQubeServiceWrapper.TryGetExportProfile(ConnectionInformation serverConnection, QualityProfile profile, Language language, CancellationToken token, out RoslynExportProfile export) { this.AssertExpectedConnection(serverConnection); Assert.IsNotNull(profile, "QualityProfile is expected"); this.GetExportAction?.Invoke(); export = null; this.ReturnExport.TryGetValue(profile, out export); QualityProfile profile2; this.ReturnProfile.TryGetValue(language, out profile2); Assert.AreSame(profile2, profile, "Unexpected profile for language"); return export != null; }
public static void AssertAreEqual(RoslynExportProfile expected, RoslynExportProfile actual) { Assert.AreEqual(expected.Version, actual.Version, "Unexpected export version"); AssertConfigSectionEqual(expected.Configuration, actual.Configuration); AssertDeploymentSectionEqual(expected.Deployment, actual.Deployment); }
public bool TryGetExportProfile(ConnectionInformation connectionInformation, QualityProfile profile, Language language, CancellationToken token, out RoslynExportProfile export) { if (connectionInformation == null) { throw new ArgumentNullException(nameof(connectionInformation)); } if (profile == null) { throw new ArgumentNullException(nameof(profile)); } if (!language.IsSupported) { throw new ArgumentOutOfRangeException(nameof(language)); } export = this.SafeUseHttpClient <RoslynExportProfile>(connectionInformation, client => DownloadQualityProfileExport(client, profile, language, token)); return(export != null); }