From 5ed7db7c362cb90754f02dc3e7b7ed12960bfff0 Mon Sep 17 00:00:00 2001 From: Georgii Borovinskikh <117642191+georgii-borovinskikh-sonarsource@users.noreply.github.com> Date: Fri, 9 Feb 2024 15:01:02 +0100 Subject: [PATCH] Create IVisualNodeProducer & RuleSplitDescription models for new rule descriptions (#5211) Fixes #5209 --- .../Layout/Logical/IVisualNodeProducer.cs | 38 +++++++ .../Layout/Logical/RuleSplitDescription.cs | 103 ++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 src/Education/Layout/Logical/IVisualNodeProducer.cs create mode 100644 src/Education/Layout/Logical/RuleSplitDescription.cs diff --git a/src/Education/Layout/Logical/IVisualNodeProducer.cs b/src/Education/Layout/Logical/IVisualNodeProducer.cs new file mode 100644 index 0000000000..b688335201 --- /dev/null +++ b/src/Education/Layout/Logical/IVisualNodeProducer.cs @@ -0,0 +1,38 @@ +/* + * SonarLint for Visual Studio + * Copyright (C) 2016-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +using System.Diagnostics.CodeAnalysis; +using SonarLint.VisualStudio.Education.Layout.Visual; +using SonarLint.VisualStudio.Education.XamlGenerator; + +namespace SonarLint.VisualStudio.Education.Layout.Logical +{ + [ExcludeFromCodeCoverage] + internal class VisualizationParameters + { + public IRuleHelpXamlTranslator HtmlToXamlTranslator { get; } + public string RelevantContext { get; } + } + + internal interface IVisualNodeProducer + { + IAbstractVisualizationTreeNode ProduceVisualNode(VisualizationParameters parameters); + } +} diff --git a/src/Education/Layout/Logical/RuleSplitDescription.cs b/src/Education/Layout/Logical/RuleSplitDescription.cs new file mode 100644 index 0000000000..83abe469f9 --- /dev/null +++ b/src/Education/Layout/Logical/RuleSplitDescription.cs @@ -0,0 +1,103 @@ +/* + * SonarLint for Visual Studio + * Copyright (C) 2016-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using SonarLint.VisualStudio.Education.Layout.Visual; + +namespace SonarLint.VisualStudio.Education.Layout.Logical +{ + [ExcludeFromCodeCoverage] + internal class RuleSplitDescription : IVisualNodeProducer + { + private readonly string introductionHtml; + private readonly List tabs; + + public RuleSplitDescription(string introductionHtml, List tabs) + { + this.introductionHtml = introductionHtml; + this.tabs = tabs; + } + + public IAbstractVisualizationTreeNode ProduceVisualNode(VisualizationParameters parameters) + { + throw new System.NotImplementedException(); + } + } + + internal interface IRuleDescriptionTab : IVisualNodeProducer + { + string Title { get; } + } + + [ExcludeFromCodeCoverage] + internal class NonContextualRuleDescriptionTab : IRuleDescriptionTab + { + private readonly string htmlContent; + + public NonContextualRuleDescriptionTab(string title, string htmlContent) + { + Title = title; + this.htmlContent = htmlContent; + } + + public string Title { get; } + + public IAbstractVisualizationTreeNode ProduceVisualNode(VisualizationParameters parameters) + { + throw new System.NotImplementedException(); + } + } + + [ExcludeFromCodeCoverage] + internal class ContextualRuleDescriptionTab : IRuleDescriptionTab + { + private readonly List contexts; + private readonly string defaultContext; + + public ContextualRuleDescriptionTab(string title, string defaultContext, List contexts) + { + Title = title; + this.contexts = contexts; + this.defaultContext = defaultContext; + } + + public string Title { get; set; } + + public IAbstractVisualizationTreeNode ProduceVisualNode(VisualizationParameters parameters) + { + throw new System.NotImplementedException(); + } + + internal class ContextContentTab + { + public ContextContentTab(string title, string contextKey, string htmlContent) + { + Title = title; + ContextKey = contextKey; + HtmlContent = htmlContent; + } + + public string Title { get; } + public string ContextKey { get; } + public string HtmlContent { get; } + } + } +}