From 28064514e3b1ca1125e8f9ab41ea60a46ab61467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?U=C4=9Fra=C5=9F=20Erg=C3=BCn?= <96827714+ugras-ergun-sonarsource@users.noreply.github.com> Date: Tue, 23 Jan 2024 11:00:34 +0100 Subject: [PATCH] Implement ConnectionConfigurationListener (#5159) Fixes #5158 --------- Co-authored-by: Georgii Borovinskikh --- .../ConnectionConfigurationListenerTests.cs | 56 +++++++++++++++++++ .../ConnectionConfigurationListener.cs | 36 ++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 src/SLCore.UnitTests/Listener/ConnectionConfigurationListenerTests.cs create mode 100644 src/SLCore/Listener/ConnectionConfigurationListener.cs diff --git a/src/SLCore.UnitTests/Listener/ConnectionConfigurationListenerTests.cs b/src/SLCore.UnitTests/Listener/ConnectionConfigurationListenerTests.cs new file mode 100644 index 0000000000..bb178379e3 --- /dev/null +++ b/src/SLCore.UnitTests/Listener/ConnectionConfigurationListenerTests.cs @@ -0,0 +1,56 @@ +/* + * 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.Threading.Tasks; +using SonarLint.VisualStudio.SLCore.Core; +using SonarLint.VisualStudio.SLCore.Listener; +using SonarLint.VisualStudio.TestInfrastructure; + +namespace SonarLint.VisualStudio.SLCore.UnitTests.Listener +{ + [TestClass] + public class ConnectionConfigurationListenerTests + { + [TestMethod] + public void MefCtor_CheckIsExported() + { + MefTestHelpers.CheckTypeCanBeImported(); + } + + [TestMethod] + public void Mef_CheckIsSingleton() + { + MefTestHelpers.CheckIsSingletonMefComponent(); + } + + [TestMethod] + [DataRow(null)] + [DataRow(5)] + [DataRow("something")] + public void DidSynchronizeConfigurationScopesAsync_ReturnsTaskCompleted(object parameter) + { + var testSubject = new ConnectionConfigurationListener(); + + var result = testSubject.DidSynchronizeConfigurationScopesAsync(parameter); + + result.Should().Be(Task.CompletedTask); + } + } +} diff --git a/src/SLCore/Listener/ConnectionConfigurationListener.cs b/src/SLCore/Listener/ConnectionConfigurationListener.cs new file mode 100644 index 0000000000..ffa543a9a9 --- /dev/null +++ b/src/SLCore/Listener/ConnectionConfigurationListener.cs @@ -0,0 +1,36 @@ +/* + * 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.ComponentModel.Composition; +using System.Threading.Tasks; +using SonarLint.VisualStudio.SLCore.Core; + +namespace SonarLint.VisualStudio.SLCore.Listener +{ + [Export(typeof(ISLCoreListener))] + [PartCreationPolicy(CreationPolicy.Shared)] + public class ConnectionConfigurationListener : ISLCoreListener + { + public Task DidSynchronizeConfigurationScopesAsync(object parameters) + { + return Task.CompletedTask; + } + } +}