Skip to content

Commit

Permalink
.NET 9 compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
ThadHouse committed Nov 18, 2024
1 parent cf4f299 commit 906b612
Show file tree
Hide file tree
Showing 58 changed files with 75 additions and 90 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_namespace_match_folder = true:silent
###############################
# Naming Conventions #
###############################
Expand Down Expand Up @@ -92,6 +93,8 @@ csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_pattern_local_over_anonymous_function = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_namespace_declarations = file_scoped
csharp_style_prefer_primary_constructors= false:silent
###############################
# C# Formatting Rules #
###############################
Expand Down
1 change: 0 additions & 1 deletion codehelp/CodeHelpers.Test/LogGenerator/LogGeneratorTest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace CodeHelpers.Test.LogGenerator;

using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Testing;
using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.Text;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace CodeHelpers.Test.LogGenerator;

using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.VisualBasic.Testing;
Expand Down
1 change: 0 additions & 1 deletion codehelp/CodeHelpers/IndentedStringBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text;
using Microsoft.CodeAnalysis;

namespace WPILib.CodeHelpers;

Expand Down
1 change: 0 additions & 1 deletion codehelp/CodeHelpers/LogGenerator/LogAttributeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.PooledObjects;
using Stereologue;

namespace WPILib.CodeHelpers.LogGenerator;
Expand Down
1 change: 0 additions & 1 deletion codehelp/CodeHelpers/LogGenerator/LoggableType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Text;
using WPILib.CodeHelpers.LogGenerator.Analyzer;
using static WPILib.CodeHelpers.IndentedStringBuilder;

namespace WPILib.CodeHelpers.LogGenerator;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.VisualBasic.Syntax;

namespace WPILib.CodeHelpers.LogGenerator.SourceGenerator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ namespace WPILib.CodeHelpers.ParameterlessStructs.Analyzer;
#pragma warning disable RS2008 // Enable analyzer release tracking

using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using WPILib.CodeHelpers;

public static class ParameterlessStructDiagnostics
{
Expand Down
1 change: 0 additions & 1 deletion codehelp/CodeHelpers/SymbolExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;

namespace WPILib.CodeHelpers;

Expand Down
1 change: 0 additions & 1 deletion codehelp/CodeHelpers/TypeDeclarationModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Immutable;
using System.Text;
using Microsoft.CodeAnalysis;

namespace WPILib.CodeHelpers;
Expand Down
5 changes: 0 additions & 5 deletions dev/desktopDev/Program.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text.Json;
using CsCore;
using CsCore.Raw;
using UnitsNet.NumberExtensions.NumberToAngle;
using WPIHal.Natives.Simulation;
using WPIMath.Geometry;
using WPIUtil;
using WPIUtil.Natives;
using WPIUtil.Serialization.Struct;

namespace DesktopDev;
Expand Down
8 changes: 8 additions & 0 deletions src/hal/CANStreamMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ public struct CANStreamMessage
[System.Runtime.CompilerServices.InlineArray(8)]
public struct DataBuffer
{
#pragma warning disable IDE0044 // Add readonly modifier
#pragma warning disable IDE0051 // Remove unused private members
private byte _element0;
#pragma warning restore IDE0051 // Remove unused private members
#pragma warning restore IDE0044 // Add readonly modifier
}
}

Expand All @@ -42,6 +46,10 @@ public CANMessage(ReadOnlySpan<byte> buffer, ulong timestamp)
[InlineArray(8)]
public struct DataBuffer
{
#pragma warning disable IDE0044 // Add readonly modifier
#pragma warning disable IDE0051 // Remove unused private members
private byte _element0;
#pragma warning restore IDE0051 // Remove unused private members
#pragma warning restore IDE0044 // Add readonly modifier
}
}
8 changes: 8 additions & 0 deletions src/hal/JoystickAxis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,21 @@ public readonly struct JoystickAxes
[System.Runtime.CompilerServices.InlineArray(NumJoystickAxes)]
public struct AxesBuffer
{
#pragma warning disable IDE0044 // Add readonly modifier
#pragma warning disable IDE0051 // Remove unused private members
private float _element0;
#pragma warning restore IDE0051 // Remove unused private members
#pragma warning restore IDE0044 // Add readonly modifier
}

[System.Runtime.CompilerServices.InlineArray(NumJoystickAxes)]
public struct RawBuffer
{
#pragma warning disable IDE0044 // Add readonly modifier
#pragma warning disable IDE0051 // Remove unused private members
private byte _element0;
#pragma warning restore IDE0051 // Remove unused private members
#pragma warning restore IDE0044 // Add readonly modifier
}
private readonly short m_count;
private readonly AxesBuffer m_axes;
Expand Down
6 changes: 6 additions & 0 deletions src/hal/JoystickDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public struct NativeJoystickDescriptor
[System.Runtime.CompilerServices.InlineArray(256)]
public struct NameBuffer
{
#pragma warning disable IDE0044 // Add readonly modifier
private byte _element0;
#pragma warning restore IDE0044 // Add readonly modifier

public readonly unsafe string FromNullTerminatedString()
{
Expand All @@ -49,7 +51,11 @@ public readonly unsafe string FromNullTerminatedString()
[System.Runtime.CompilerServices.InlineArray(12)]
public struct AxesTypeBuffer
{
#pragma warning disable IDE0044 // Add readonly modifier
#pragma warning disable IDE0051 // Remove unused private members
private byte _element0;
#pragma warning restore IDE0051 // Remove unused private members
#pragma warning restore IDE0044 // Add readonly modifier

public readonly unsafe int[] FromRawBytes(int length)
{
Expand Down
4 changes: 4 additions & 0 deletions src/hal/JoystickPOVs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ public readonly struct JoystickPOVs
[System.Runtime.CompilerServices.InlineArray(NumJoystickPOVs)]
public struct PovsBuffer
{
#pragma warning disable IDE0044 // Add readonly modifier
#pragma warning disable IDE0051 // Remove unused private members
private short _element0;
#pragma warning restore IDE0051 // Remove unused private members
#pragma warning restore IDE0044 // Add readonly modifier
}

private readonly short m_count;
Expand Down
1 change: 0 additions & 1 deletion src/hal/Natives/Simulation/HalAccelerometerData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;

namespace WPIHal.Natives.Simulation;
Expand Down
1 change: 0 additions & 1 deletion src/hal/Natives/Simulation/HalAddressableLEDData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_ConstBufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;

Expand Down
1 change: 0 additions & 1 deletion src/hal/Natives/Simulation/HalAnalogGyroData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;

namespace WPIHal.Natives.Simulation;
Expand Down
1 change: 0 additions & 1 deletion src/hal/Natives/Simulation/HalAnalogInData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;

namespace WPIHal.Natives.Simulation;
Expand Down
1 change: 0 additions & 1 deletion src/hal/Natives/Simulation/HalAnalogOutData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;

namespace WPIHal.Natives.Simulation;
Expand Down
1 change: 0 additions & 1 deletion src/hal/Natives/Simulation/HalAnalogTriggerData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;

namespace WPIHal.Natives.Simulation;
Expand Down
1 change: 0 additions & 1 deletion src/hal/Natives/Simulation/HalCTREPCMData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;

namespace WPIHal.Natives.Simulation;
Expand Down
1 change: 0 additions & 1 deletion src/hal/Natives/Simulation/HalDIOData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;

namespace WPIHal.Natives.Simulation;
Expand Down
1 change: 0 additions & 1 deletion src/hal/Natives/Simulation/HalDigitalPWMData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;

namespace WPIHal.Natives.Simulation;
Expand Down
1 change: 0 additions & 1 deletion src/hal/Natives/Simulation/HalDutyCycleData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;

namespace WPIHal.Natives.Simulation;
Expand Down
1 change: 0 additions & 1 deletion src/hal/Natives/Simulation/HalEncoderData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;

namespace WPIHal.Natives.Simulation;
Expand Down
2 changes: 0 additions & 2 deletions src/hal/Natives/Simulation/HalNotifierData.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;

namespace WPIHal.Natives.Simulation;

Expand Down
1 change: 0 additions & 1 deletion src/hal/Natives/Simulation/HalPWMData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;

namespace WPIHal.Natives.Simulation;
Expand Down
1 change: 0 additions & 1 deletion src/hal/Natives/Simulation/HalPowerDistributionData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;

namespace WPIHal.Natives.Simulation;
Expand Down
1 change: 0 additions & 1 deletion src/hal/Natives/Simulation/HalREVPHData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;

namespace WPIHal.Natives.Simulation;
Expand Down
1 change: 0 additions & 1 deletion src/hal/Natives/Simulation/HalRelayData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;

namespace WPIHal.Natives.Simulation;
Expand Down
1 change: 0 additions & 1 deletion src/hal/Natives/Simulation/HalSPIAccelerometerData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;

namespace WPIHal.Natives.Simulation;
Expand Down
5 changes: 0 additions & 5 deletions src/hal/Natives/Simulation/NotifyListener.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;

namespace WPIHal.Natives.Simulation;

public static unsafe partial class HalNotifyListener
Expand Down
2 changes: 0 additions & 2 deletions src/hal/Natives/Simulation/Reset.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;

namespace WPIHal.Natives.Simulation;

Expand Down
2 changes: 0 additions & 2 deletions src/newcommands/Command.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using CommunityToolkit.Diagnostics;
using WPIUtil.Sendable;

Expand Down
2 changes: 2 additions & 0 deletions src/newcommands/ConditionalCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ public class ConditionalCommand : Command
{
private readonly Command m_onTrue;
private readonly Command m_onFalse;
#pragma warning disable IDE0052 // Remove unread private members
private readonly Func<bool> m_condition;
#pragma warning restore IDE0052 // Remove unread private members

public ConditionalCommand(Command onTrue, Command onFalse, Func<bool> condition)
{
Expand Down
2 changes: 2 additions & 0 deletions src/newcommands/DeferredCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ public class DeferredCommand : Command
{
private readonly Command m_nullCommand = new PrintCommand("[DeferredCommand] Supplied command was null!");

#pragma warning disable IDE0052 // Remove unread private members
private readonly Func<Command> m_supplier;
private Command m_command;
#pragma warning restore IDE0052 // Remove unread private members

public DeferredCommand(Func<Command> supplier, HashSet<ISubsystem> requirements)
{
Expand Down
3 changes: 2 additions & 1 deletion src/ntcore/ConnectionInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
using NetworkTables.Natives;
using WPIUtil.Marshal;

namespace NetworkTables.Natives;
namespace NetworkTables;

[NativeMarshalling(typeof(ConnectionInfoMarshaller))]
[StructLayout(LayoutKind.Auto)]
Expand Down
1 change: 0 additions & 1 deletion src/ntcore/NetworkTable.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Concurrent;
using NetworkTables.Handles;
using NetworkTables.Natives;

namespace NetworkTables;

Expand Down
3 changes: 2 additions & 1 deletion src/ntcore/TopicInfo.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
using NetworkTables.Handles;
using NetworkTables.Natives;
using WPIUtil.Marshal;

namespace NetworkTables.Natives;
namespace NetworkTables;

[NativeMarshalling(typeof(TopicInfoMarshaller))]
[StructLayout(LayoutKind.Auto)]
Expand Down
2 changes: 0 additions & 2 deletions src/stereologue/Attributes.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Stereologue;

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
Expand Down
2 changes: 0 additions & 2 deletions src/stereologue/LogType.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Stereologue;

[Flags]
Expand Down
3 changes: 2 additions & 1 deletion src/stereologue/Stereologuer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Google.Protobuf.WellKnownTypes;
using NetworkTables;
using WPIUtil.Logging;
using WPIUtil.Serialization.Protobuf;
Expand All @@ -18,7 +17,9 @@ private Stereologuer() { }

public static Stereologuer Logger { get; } = new();

#pragma warning disable IDE0060 // Remove unused parameter
public void Setup(string name, bool fileOnly, bool lazyLogging)
#pragma warning restore IDE0060 // Remove unused parameter
{
rootPath = name;
FileOnly = fileOnly;
Expand Down
Loading

0 comments on commit 906b612

Please sign in to comment.