Skip to content

Commit

Permalink
fix: remove all build warnings (#1334)
Browse files Browse the repository at this point in the history
* fix: remove all non-analyzer warnings
* fix: all remaining build warnings #1333
  • Loading branch information
JohnTasler authored Feb 4, 2025
1 parent bb560af commit c6adc9a
Show file tree
Hide file tree
Showing 41 changed files with 134 additions and 113 deletions.
13 changes: 6 additions & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ dotnet_diagnostic.SA1009.severity = none

# Hide warnings when using the new() expression from C# 9.
dotnet_diagnostic.SA1000.severity = none

dotnet_diagnostic.SA1011.severity = none
dotnet_diagnostic.SA1101.severity = none

Expand Down Expand Up @@ -389,12 +388,16 @@ dotnet_diagnostic.SA1634.severity = none
dotnet_diagnostic.SA1652.severity = none



# Additional Stylecop Analyzers
dotnet_diagnostic.SA1111.severity = none
dotnet_diagnostic.SA1121.severity = none
dotnet_diagnostic.SA1204.severity = none
dotnet_diagnostic.SA1208.severity = none
dotnet_diagnostic.CS1591.severity = none # Missing XML comment for publicly visible type or member
# 15000+ warnings in the solution
dotnet_diagnostic.CA1510.severity = none # Use ArgumentNullException throw helper
# doesn't work with older versions of .NET

dotnet_diagnostic.SA1518.severity = none
dotnet_diagnostic.SA1615.severity = none
dotnet_diagnostic.SA1502.severity = none
Expand All @@ -407,9 +410,5 @@ dotnet_diagnostic.WPF0071.severity = none # Add ValueConversion attribute
dotnet_diagnostic.WPF0070.severity = none # Add default field to converter

# Suppress some IDE warnings
dotnet_diagnostic.IDE0130.severity = none # Hide warnings about namespaces not matching folder structure
dotnet_diagnostic.IDE0290.severity = none # Use primary constructor
dotnet_diagnostic.CS1591.severity = none # Missing XML comment for publicly visible type or member
# 15000+ warnings in the solution
dotnet_diagnostic.CA1510.severity = none # Use ArgumentNullException throw helper
# doesn't work with older versions of .NET

34 changes: 17 additions & 17 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<Project>
<ItemGroup>
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.4.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="Lepo.i18n" Version="2.0.0" />
<PackageVersion Include="Lepo.i18n.DependencyInjection" Version="2.0.0" />
<PackageVersion Include="Lepo.i18n.Wpf" Version="2.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.VisualStudio.CoreUtility" Version="17.2.3194" />
<PackageVersion Include="Microsoft.VisualStudio.SDK" Version="17.10.40171" />
<PackageVersion Include="Microsoft.VSSDK.BuildTools" Version="17.11.414" />
<PackageVersion Include="Microsoft.Web.WebView2" Version="1.0.2592.51" />
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
<PackageVersion Include="Microsoft.VisualStudio.SDK" Version="17.12.4039" ExcludeAssets="runtime" />
<PackageVersion Include="Microsoft.VSSDK.BuildTools" Version="17.12.2069" />
<PackageVersion Include="Microsoft.Web.WebView2" Version="1.0.2957.106" />
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
<PackageVersion Include="NativeMethods" Version="0.0.3" />
<PackageVersion Include="NSubstitute" Version="5.1.0" />
<PackageVersion Include="PolySharp" Version="1.14.1" />
<PackageVersion Include="ReflectionEventing" Version="3.0.1" />
<PackageVersion Include="ReflectionEventing.DependencyInjection" Version="3.0.1" />
<PackageVersion Include="NSubstitute" Version="5.3.0" />
<PackageVersion Include="PolySharp" Version="1.15.0" />
<PackageVersion Include="ReflectionEventing" Version="3.1.0" />
<PackageVersion Include="ReflectionEventing.DependencyInjection" Version="3.1.0" />
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
<PackageVersion Include="System.Drawing.Common" Version="8.0.0" />
<PackageVersion Include="System.Drawing.Common" Version="9.0.1" />
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />
<PackageVersion Include="WpfAnalyzers" Version="4.1.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.4" />
<PackageVersion Include="xunit" Version="2.6.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.1" />
<PackageVersion Include="xunit" Version="2.9.3" />
</ItemGroup>
</Project>
1 change: 0 additions & 1 deletion src/Wpf.Ui.Abstractions/Controls/INavigationAware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public interface INavigationAware
/// Asynchronously handles the event that is fired after the component is navigated to.
/// </summary>
/// <returns>A task that represents the asynchronous operation.</returns>

Task OnNavigatedToAsync();

/// <summary>
Expand Down
5 changes: 3 additions & 2 deletions src/Wpf.Ui.Abstractions/NavigationException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ namespace Wpf.Ui.Abstractions;
public sealed class NavigationException : Exception
{
/// <summary>
/// Initializes a new instance of the NavigationException class with a specified error message.
/// Initializes a new instance of the <see cref="NavigationException"/> class with a specified error message.
/// </summary>
/// <param name="message">The message that describes the error.</param>
public NavigationException(string message)
: base(message) { }

/// <summary>
/// Initializes a new instance of the NavigationException class with a specified error message and a reference to the inner exception that is the cause of this exception.
/// Initializes a new instance of the <see cref="NavigationException"/> class with a specified error message
/// and a reference to the inner exception that is the cause of this exception.
/// </summary>
/// <param name="e">The exception that is the cause of the current exception.</param>
/// <param name="message">The message that describes the error.</param>
Expand Down
1 change: 1 addition & 0 deletions src/Wpf.Ui.Abstractions/Wpf.Ui.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>Abstractions for the WPF UI.</Description>
<CommonTags>$(CommonTags);abstractions;standard</CommonTags>
<_SilenceIsAotCompatibleUnsupportedWarning>true</_SilenceIsAotCompatibleUnsupportedWarning>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public static class ServiceCollectionExtensions
/// </summary>
/// <param name="services">The <see cref="IServiceCollection"/> to add the services to.</param>
/// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns>

public static IServiceCollection AddNavigationViewPageProvider(this IServiceCollection services)
{
_ = services.AddSingleton<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>Dependency injection for the WPF UI.</Description>
<CommonTags>$(CommonTags);dependency;injection;abstractions;standard</CommonTags>
<_SilenceIsAotCompatibleUnsupportedWarning>true</_SilenceIsAotCompatibleUnsupportedWarning>
</PropertyGroup>

<ItemGroup>
Expand Down
6 changes: 0 additions & 6 deletions src/Wpf.Ui.Extension/Wpf.Ui.Extension.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.SDK" ExcludeAssets="runtime">
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VSSDK.BuildTools" />
</ItemGroup>
<ItemGroup>
<Content Include="license.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down
6 changes: 3 additions & 3 deletions src/Wpf.Ui.Gallery/Controllers/MonacoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public async Task SetLanguageAsync(MonacoLanguage monacoLanguage)
var languageId =
monacoLanguage == MonacoLanguage.ObjectiveC ? "objective-c" : monacoLanguage.ToString().ToLower();

await _webView.ExecuteScriptAsync(
_ = await _webView.ExecuteScriptAsync(
"monaco.editor.setModelLanguage(" + EditorObject + $".getModel(), \"{languageId}\");"
);
}
Expand All @@ -65,7 +65,7 @@ public async Task SetContentAsync(string contents)
{
var literalContents = SymbolDisplay.FormatLiteral(contents, false);

await _webView.ExecuteScriptAsync(EditorObject + $".setValue(\"{literalContents}\");");
_ = await _webView.ExecuteScriptAsync(EditorObject + $".setValue(\"{literalContents}\");");
}

public void DispatchScript(string script)
Expand All @@ -75,6 +75,6 @@ public void DispatchScript(string script)
return;
}

Application.Current.Dispatcher.InvokeAsync(async () => await _webView!.ExecuteScriptAsync(script));
_ = Application.Current.Dispatcher.InvokeAsync(async () => await _webView!.ExecuteScriptAsync(script));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private void OnTemplateButtonClick(Type? pageType)

if (pageType is not null)
{
navigationService.Navigate(pageType);
_ = navigationService.Navigate(pageType);
}

System.Diagnostics.Debug.WriteLine(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void OnWebViewNavigationCompleted(
Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs e
)
{
DispatchAsync(InitializeEditorAsync);
_ = DispatchAsync(InitializeEditorAsync);
}

private static DispatcherOperation<TResult> DispatchAsync<TResult>(Func<TResult> callback)
Expand Down
10 changes: 5 additions & 5 deletions src/Wpf.Ui.SyntaxHighlight/Controls/CodeBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ public class CodeBlock : System.Windows.Controls.ContentControl
);

/// <summary>
/// Formatted <see cref="System.Windows.Controls.ContentControl.Content"/>.
/// Gets the formatted <see cref="System.Windows.Controls.ContentControl.Content"/>.
/// </summary>
public object SyntaxContent
public object? SyntaxContent
{
get => GetValue(SyntaxContentProperty);
internal set => SetValue(SyntaxContentProperty, value);
}

/// <summary>
/// Command triggered after clicking the control button.
/// Gets the command triggered after clicking the control button.
/// </summary>
public IRelayCommand ButtonCommand => (IRelayCommand)GetValue(ButtonCommandProperty);

/// <summary>
/// Creates new instance and assigns <see cref="ButtonCommand"/> default action.
/// Initializes a new instance of the <see cref="CodeBlock"/> class, and assigns <see cref="ButtonCommand"/> default action.
/// </summary>
public CodeBlock()
{
Expand Down Expand Up @@ -94,7 +94,7 @@ protected virtual void UpdateSyntax()
richTextBox.Document.Blocks.Clear();
richTextBox.Document.Blocks.Add(Highlighter.FormatAsParagraph(_sourceCode));

SyntaxContent = richTextBox;
SetCurrentValue(SyntaxContentProperty, richTextBox);
}

private void OnTemplateButtonClick(string? _)
Expand Down
13 changes: 7 additions & 6 deletions src/Wpf.Ui.SyntaxHighlight/Highlighter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// All Rights Reserved.

// TODO: This class is work in progress.

//
using System;
using System.Linq;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -38,17 +38,18 @@ internal static class Highlighter
private const string EntityPattern = /* language=regex */
@"(&[a-zA-Z0-9#]+;)";

//private const string PunctuationPattern = /* language=regex */
// private const string PunctuationPattern = /* language=regex */
// @"(!==?|(?:[[\\] ()\{\}.:;,+\\-?=!]|&lt;|&gt;)+|&&|\\|\\|)";

//private const string NumberPattern = /* language=regex */
// private const string NumberPattern = /* language=regex */
// @"(-? (?:\.\d+|\d+(?:\.\d+)?))";

//private const string BooleanPattern = /* language=regex */
// private const string BooleanPattern = /* language=regex */
// "\b(true|false)\b";

//private const string AttributePattern = /* language=regex */
// "(\\s*)([a-zA-Z\\d\\-:]+)=(\" | ')(.*?)\\3";
// private const string AttributePattern = /* language=regex */
// "(\\s*)([a-zA-Z\\d\\-:]+)=(\" | ')(.*?)\\3";
////

public static Paragraph FormatAsParagraph(
string code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public class SyntaxHighlightDictionary : ResourceDictionary
"pack://application:,,,/Wpf.Ui.SyntaxHighlight;component/SyntaxHighlight.xaml";

/// <summary>
/// Default constructor defining <see cref="ResourceDictionary.Source"/> of the <c>WPF UI</c> syntax highlight dictionary.
/// Initializes a new instance of the <see cref="SyntaxHighlightDictionary"/> class.
/// It sets the <see cref="ResourceDictionary.Source"/> of the <c>WPF UI</c> syntax highlight dictionary.
/// </summary>
public SyntaxHighlightDictionary() => Source = new Uri(DictionaryUri, UriKind.Absolute);
}
2 changes: 1 addition & 1 deletion src/Wpf.Ui.Tray/Hicon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// TODO: This class is the only reason for using System.Drawing.Common.
// It is worth looking for a way to get hIcon without using it.

//
using System.Drawing;
using System.Windows.Media;
using System.Windows.Media.Imaging;
Expand Down
4 changes: 2 additions & 2 deletions src/Wpf.Ui.Tray/Internal/InternalNotifyIconManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ protected virtual void OpenMenu()
}

// Without setting the handler window at the front, menu may appear behind the taskbar
Interop.User32.SetForegroundWindow(HookWindow.Handle);
_ = Interop.User32.SetForegroundWindow(HookWindow.Handle);
ContextMenuService.SetPlacement(ContextMenu, PlacementMode.MousePoint);

// ContextMenu.ApplyMica();
Expand Down Expand Up @@ -259,7 +259,7 @@ protected virtual void Dispose(bool disposing)
"Wpf.Ui.NotifyIcon"
);

Unregister();
_ = Unregister();
}

/// <inheritdoc />
Expand Down
2 changes: 2 additions & 0 deletions src/Wpf.Ui.Tray/Interop/Shell32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Wpf.Ui.Tray.Interop;
// ReSharper disable InconsistentNaming
#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter
#pragma warning disable SA1401 // Fields should be private
#pragma warning disable CA1060 // Move pinvokes to native methods class

/// <summary>
/// The Windows UI provides users with access to a wide variety of objects necessary to run applications and manage the operating system.
Expand Down Expand Up @@ -178,3 +179,4 @@ public static extern int GetCurrentProcessExplicitAppUserModelID(

#pragma warning restore SA1307 // Accessible fields should begin with upper-case letter
#pragma warning restore SA1401 // Fields should be private
#pragma warning restore CA1060 // Move pinvokes to native methods class
2 changes: 2 additions & 0 deletions src/Wpf.Ui.Tray/Interop/User32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Wpf.Ui.Tray.Interop;
// ReSharper disable InconsistentNaming
#pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter
#pragma warning disable CA1060 // Move pinvokes to native methods class

/// <summary>
/// USER procedure declarations, constant definitions and macros.
Expand Down Expand Up @@ -1546,3 +1547,4 @@ public static extern int GetWindowCompositionAttribute(

#pragma warning restore SA1300 // Element should begin with upper-case letter
#pragma warning restore SA1307 // Accessible fields should begin with upper-case letter
#pragma warning restore CA1060 // Move pinvokes to native methods class
4 changes: 4 additions & 0 deletions src/Wpf.Ui.Tray/NotifyIconService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using System.Windows.Controls;
using System.Windows.Media;

#pragma warning disable CA1001 // Types that own disposable fields should be disposable

namespace Wpf.Ui.Tray;

/// <summary>
Expand Down Expand Up @@ -119,3 +121,5 @@ private void RegisterHandlers()
internalNotifyIconManager.MiddleDoubleClick += OnMiddleDoubleClick;
}
}

#pragma warning restore CA1001 // Types that own disposable fields should be disposable
2 changes: 1 addition & 1 deletion src/Wpf.Ui/Appearance/ObservedWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal class ObservedWindow
private readonly HwndSource _source;

/// <summary>
/// Initializes a new instance of the ObservedWindow class.
/// Initializes a new instance of the <see cref="ObservedWindow"/> class.
/// </summary>
/// <param name="handle">The handle of the window.</param>
/// <param name="backdrop">The backdrop type of the window.</param>
Expand Down
21 changes: 7 additions & 14 deletions src/Wpf.Ui/Controls/Arc/Arc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ public class Arc : Shape
new PropertyMetadata(SweepDirection.Clockwise, PropertyChangedCallback)
);

/// <summary>Identifies the <see cref="StrokeStartLineCap"/> dependency property.</summary>
public static readonly DependencyProperty StrokeStartLineCapProperty = DependencyProperty.Register(
nameof(StrokeStartLineCap),
typeof(PenLineCap),
typeof(Arc),
new PropertyMetadata(PenLineCap.Round, PropertyChangedCallback)
);
static Arc()
{
// Modify the metadata of the StrokeStartLineCap dependency property.
StrokeStartLineCapProperty.OverrideMetadata(
typeof(Arc),
new PropertyMetadata(PenLineCap.Round, PropertyChangedCallback));
}

/// <summary>
/// Gets or sets the initial angle from which the arc will be drawn.
Expand Down Expand Up @@ -87,13 +87,6 @@ public SweepDirection SweepDirection
set => SetValue(SweepDirectionProperty, value);
}

// TODO: Should we?
public new PenLineCap StrokeStartLineCap
{
get { return (PenLineCap)GetValue(StrokeStartLineCapProperty); }
set { SetValue(StrokeStartLineCapProperty, value); }
}

/// <summary>
/// Gets a value indicating whether one of the two larger arc sweeps is chosen; otherwise, if is <see langword="false"/>, one of the smaller arc sweeps is chosen.
/// </summary>
Expand Down
2 changes: 0 additions & 2 deletions src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

/* Based on Windows UI Library */



// ReSharper disable once CheckNamespace
namespace Wpf.Ui.Controls;

Expand Down
Loading

0 comments on commit c6adc9a

Please sign in to comment.