Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CFamily.UnitTests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,7 @@
"SonarLint.VisualStudio.ConnectedMode": "[1.0.0, )",
"SonarLint.VisualStudio.Core": "[1.0.0, )",
"SonarLint.VisualStudio.Infrastructure.VS": "[1.0.0, )",
"SonarLint.VisualStudio.SLCore": "[1.0.0, )",
"StreamJsonRpc": "[2.8.28, )",
"StrongNamer": "[0.0.8, )",
"System.IO.Abstractions": "[9.0.4, )"
Expand Down
1 change: 1 addition & 0 deletions src/ConnectedMode.UnitTests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,7 @@
"SonarLint.VisualStudio.ConnectedMode": "[1.0.0, )",
"SonarLint.VisualStudio.Core": "[1.0.0, )",
"SonarLint.VisualStudio.Infrastructure.VS": "[1.0.0, )",
"SonarLint.VisualStudio.SLCore": "[1.0.0, )",
"StreamJsonRpc": "[2.8.28, )",
"StrongNamer": "[0.0.8, )",
"System.IO.Abstractions": "[9.0.4, )"
Expand Down
145 changes: 145 additions & 0 deletions src/ConnectedMode/UI/Resources/Styles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,149 @@
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>

<Style x:Key="ScrollBarArrowButton" TargetType="RepeatButton">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Focusable" Value="False" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RepeatButton">
<Border Background="{DynamicResource {x:Static vsShell:VsBrushes.ScrollBarBackgroundKey}}">
<Path x:Name="Arrow"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Fill="{DynamicResource {x:Static vsShell:VsBrushes.ScrollBarThumbBackgroundKey}}"
Data="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Arrow" Property="Fill"
Value="{DynamicResource {x:Static vsShell:VsBrushes.ScrollBarThumbMouseOverBackgroundKey}}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="Arrow" Property="Fill"
Value="{DynamicResource {x:Static vsShell:VsBrushes.ScrollBarThumbPressedBackgroundKey}}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style x:Key="ScrollBarPageButton" TargetType="RepeatButton">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Focusable" Value="False" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RepeatButton">
<Border Background="Transparent" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style x:Key="ScrollBarThumb" TargetType="Thumb">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Focusable" Value="False" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Thumb">
<Border x:Name="ThumbBorder"
Background="{DynamicResource {x:Static vsShell:VsBrushes.ScrollBarThumbBackgroundKey}}" />
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="ThumbBorder" Property="Background"
Value="{DynamicResource {x:Static vsShell:VsBrushes.ScrollBarThumbMouseOverBackgroundKey}}" />
</Trigger>
<Trigger Property="IsDragging" Value="True">
<Setter TargetName="ThumbBorder" Property="Background"
Value="{DynamicResource {x:Static vsShell:VsBrushes.ScrollBarThumbPressedBackgroundKey}}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<ControlTemplate x:Key="VerticalScrollBar" TargetType="ScrollBar">
<Grid Background="{DynamicResource {x:Static vsShell:VsBrushes.ScrollBarBackgroundKey}}">
<Grid.RowDefinitions>
<RowDefinition MaxHeight="14" />
<RowDefinition Height="*" />
<RowDefinition MaxHeight="14" />
</Grid.RowDefinitions>
<RepeatButton Grid.Row="0"
Style="{StaticResource ScrollBarArrowButton}"
Command="ScrollBar.LineUpCommand"
Content="M 0 4 L 4 0 L 8 4 Z" />
<Track Grid.Row="1" x:Name="PART_Track" IsDirectionReversed="True">
<Track.DecreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButton}"
Command="ScrollBar.PageUpCommand" />
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource ScrollBarThumb}" MinHeight="20" />
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButton}"
Command="ScrollBar.PageDownCommand" />
</Track.IncreaseRepeatButton>
</Track>
<RepeatButton Grid.Row="2"
Style="{StaticResource ScrollBarArrowButton}"
Command="ScrollBar.LineDownCommand"
Content="M 0 0 L 4 4 L 8 0 Z" />
</Grid>
</ControlTemplate>

<ControlTemplate x:Key="HorizontalScrollBar" TargetType="ScrollBar">
<Grid Background="{DynamicResource {x:Static vsShell:VsBrushes.ScrollBarBackgroundKey}}">
<Grid.ColumnDefinitions>
<ColumnDefinition MaxWidth="14" />
<ColumnDefinition Width="*" />
<ColumnDefinition MaxWidth="14" />
</Grid.ColumnDefinitions>
<RepeatButton Grid.Column="0"
Style="{StaticResource ScrollBarArrowButton}"
Command="ScrollBar.LineLeftCommand"
Content="M 4 0 L 0 4 L 4 8 Z" />
<Track Grid.Column="1" x:Name="PART_Track" IsDirectionReversed="False">
<Track.DecreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButton}"
Command="ScrollBar.PageLeftCommand" />
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource ScrollBarThumb}" MinWidth="20" />
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButton}"
Command="ScrollBar.PageRightCommand" />
</Track.IncreaseRepeatButton>
</Track>
<RepeatButton Grid.Column="2"
Style="{StaticResource ScrollBarArrowButton}"
Command="ScrollBar.LineRightCommand"
Content="M 0 0 L 4 4 L 0 8 Z" />
</Grid>
</ControlTemplate>

<Style TargetType="ScrollBar">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Style.Triggers>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="Width" Value="14" />
<Setter Property="Height" Value="Auto" />
<Setter Property="Template" Value="{StaticResource VerticalScrollBar}" />
</Trigger>
<Trigger Property="Orientation" Value="Horizontal">
<Setter Property="Height" Value="14" />
<Setter Property="Width" Value="Auto" />
<Setter Property="Template" Value="{StaticResource HorizontalScrollBar}" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
1 change: 1 addition & 0 deletions src/Core.UnitTests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,7 @@
"SonarLint.VisualStudio.ConnectedMode": "[1.0.0, )",
"SonarLint.VisualStudio.Core": "[1.0.0, )",
"SonarLint.VisualStudio.Infrastructure.VS": "[1.0.0, )",
"SonarLint.VisualStudio.SLCore": "[1.0.0, )",
"StreamJsonRpc": "[2.8.28, )",
"StrongNamer": "[0.0.8, )",
"System.IO.Abstractions": "[9.0.4, )"
Expand Down
6 changes: 5 additions & 1 deletion src/Core/Telemetry/ITelemetryManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* SonarLint for Visual Studio
* Copyright (C) 2016-2025 SonarSource Sàrl
* mailto:info AT sonarsource DOT com
Expand Down Expand Up @@ -47,4 +47,8 @@ public interface ITelemetryManager
void HotspotInvestigatedLocally();

void HotspotInvestigatedRemotely();

void SupportedLanguagesPanelOpened();

void SupportedLanguagesPanelCtaClicked();
}
1 change: 1 addition & 0 deletions src/Education.UnitTests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,7 @@
"SonarLint.VisualStudio.ConnectedMode": "[1.0.0, )",
"SonarLint.VisualStudio.Core": "[1.0.0, )",
"SonarLint.VisualStudio.Infrastructure.VS": "[1.0.0, )",
"SonarLint.VisualStudio.SLCore": "[1.0.0, )",
"StreamJsonRpc": "[2.8.28, )",
"StrongNamer": "[0.0.8, )",
"System.IO.Abstractions": "[9.0.4, )"
Expand Down
2 changes: 1 addition & 1 deletion src/EmbeddedSonarAnalyzer.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
<!-- sonarqube-ide-visualstudio-roslyn -->
<EmbeddedSonarSqvsRoslynJarVersion>1.2.0.364</EmbeddedSonarSqvsRoslynJarVersion>
<!-- SLOOP: Binaries for SonarLint Out Of Process -->
<EmbeddedSloopVersion>10.47.0.84936</EmbeddedSloopVersion>
<EmbeddedSloopVersion>10.48.0.85117</EmbeddedSloopVersion>
</PropertyGroup>
</Project>
1 change: 1 addition & 0 deletions src/Infrastructure.VS.UnitTests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,7 @@
"SonarLint.VisualStudio.ConnectedMode": "[1.0.0, )",
"SonarLint.VisualStudio.Core": "[1.0.0, )",
"SonarLint.VisualStudio.Infrastructure.VS": "[1.0.0, )",
"SonarLint.VisualStudio.SLCore": "[1.0.0, )",
"StreamJsonRpc": "[2.8.28, )",
"StrongNamer": "[0.0.8, )",
"System.IO.Abstractions": "[9.0.4, )"
Expand Down
1 change: 1 addition & 0 deletions src/Integration.UnitTests/Integration.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

<ItemGroup>
<ProjectReference Include="..\Integration\Integration.csproj" />
<ProjectReference Include="..\SLCore\SLCore.csproj" />
<ProjectReference Include="..\TestInfrastructure\TestInfrastructure.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/*
* SonarLint for Visual Studio
* Copyright (C) 2016-2025 SonarSource Sàrl
* 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 SonarLint.VisualStudio.Core.Notifications;
using SonarLint.VisualStudio.Integration.Resources;
using SonarLint.VisualStudio.Integration.SupportedLanguages;
using SonarLint.VisualStudio.SLCore;
using SonarLint.VisualStudio.SLCore.Service.Plugin.Models;
using SonarLint.VisualStudio.TestInfrastructure;

namespace SonarLint.VisualStudio.Integration.UnitTests.SupportedLanguages;

[TestClass]
public class FailedPluginNotificationTests
{
private IPluginStatusesStore pluginStatusesStore = null!;
private INotificationService notificationService = null!;
private ISLCoreHandler slCoreHandler = null!;
private ISupportedLanguagesWindowService supportedLanguagesWindowService = null!;
private FailedPluginNotification testSubject = null!;

[TestInitialize]
public void TestInitialize()
{
pluginStatusesStore = Substitute.For<IPluginStatusesStore>();
notificationService = Substitute.For<INotificationService>();
slCoreHandler = Substitute.For<ISLCoreHandler>();
supportedLanguagesWindowService = Substitute.For<ISupportedLanguagesWindowService>();

testSubject = new FailedPluginNotification(pluginStatusesStore, notificationService, slCoreHandler, supportedLanguagesWindowService);
}

[TestMethod]
public void MefCtor_CheckIsExported() =>
MefTestHelpers.CheckTypeCanBeImported<FailedPluginNotification, IFailedPluginNotification>(
MefTestHelpers.CreateExport<IPluginStatusesStore>(),
MefTestHelpers.CreateExport<INotificationService>(),
MefTestHelpers.CreateExport<ISLCoreHandler>(),
MefTestHelpers.CreateExport<ISupportedLanguagesWindowService>());

[TestMethod]
public void MefCtor_CheckIsSingleton() => MefTestHelpers.CheckIsSingletonMefComponent<FailedPluginNotification>();

[TestMethod]
public void PluginStatusesChanged_NoFailedPlugins_DoesNotShowNotification()
{
pluginStatusesStore.GetAll().Returns([
new PluginStatusDisplay("Java", PluginStateDto.ACTIVE, null, string.Empty),
new PluginStatusDisplay("C#", PluginStateDto.ACTIVE, null, string.Empty)
]);

RaisePluginStatusesChanged();

notificationService.DidNotReceive().ShowNotification(Arg.Any<INotification>());
notificationService.Received(1).CloseNotification();
}

[TestMethod]
public void PluginStatusesChanged_HasFailedPlugins_ShowsNotificationWithCorrectMessage()
{
pluginStatusesStore.GetAll().Returns([
new PluginStatusDisplay("Java", PluginStateDto.FAILED, null, string.Empty),
new PluginStatusDisplay("C#", PluginStateDto.ACTIVE, null, string.Empty),
new PluginStatusDisplay("C++", PluginStateDto.FAILED, null, string.Empty)
]);

RaisePluginStatusesChanged();

notificationService.Received(1).ShowNotification(Arg.Is<Notification>(n =>
n.Message.StartsWith(Strings.PluginStatusesFailedNotificationText) && n.Message.EndsWith("Java, C++")
&& n.Id == "PluginStatuses.FailedNotification"
&& n.ShowOncePerSession == false));
}

[TestMethod]
public void PluginStatusesChanged_HasFailedPlugins_NotificationHasTwoActions()
{
SetupFailedPlugins();

RaisePluginStatusesChanged();

GetNotification().Actions.Should().HaveCount(2);
}

[TestMethod]
public void PluginStatusesChanged_HasFailedPlugins_RestartActionRestartsBackend()
{
SetupFailedPlugins();

RaisePluginStatusesChanged();

var notification = GetNotification();
var restartAction = notification.Actions.ToList()[0];

restartAction.CommandText.Should().Be(SLCoreStrings.SloopRestartFailedNotificationService_Restart);
restartAction.ShouldDismissAfterAction.Should().BeTrue();
restartAction.Action(notification);
slCoreHandler.Received(1).ForceRestartSloop();
}

[TestMethod]
public void PluginStatusesChanged_HasFailedPlugins_SeeDetailsActionOpensWindow()
{
SetupFailedPlugins();

RaisePluginStatusesChanged();

var notification = GetNotification();
var seeDetailsAction = notification.Actions.ToList()[1];

seeDetailsAction.CommandText.Should().Be(Strings.PluginStatusesFailedNotificationSeeDetailsButton);
seeDetailsAction.ShouldDismissAfterAction.Should().BeTrue();
seeDetailsAction.Action(notification);
supportedLanguagesWindowService.Received(1).Show();
}

[TestMethod]
public void Dispose_UnsubscribesFromEvent()
{
testSubject.Dispose();

pluginStatusesStore.Received(1).PluginStatusesChanged -= Arg.Any<EventHandler>();
}

private void SetupFailedPlugins()
{
pluginStatusesStore.GetAll().Returns([
new PluginStatusDisplay("Java", PluginStateDto.FAILED, null, string.Empty)
]);
}

private Notification GetNotification()
{
return (Notification)notificationService.ReceivedCalls()
.Single(c => c.GetMethodInfo().Name == nameof(INotificationService.ShowNotification))
.GetArguments()[0]!;
}

private void RaisePluginStatusesChanged()
{
pluginStatusesStore.PluginStatusesChanged += Raise.EventWith(EventArgs.Empty);
}
}
Loading