Skip to content

Commit 906b612

Browse files
committed
.NET 9 compilation
1 parent cf4f299 commit 906b612

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+75
-90
lines changed

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
5151
dotnet_style_prefer_auto_properties = true:silent
5252
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
5353
dotnet_style_prefer_conditional_expression_over_return = true:silent
54+
dotnet_style_namespace_match_folder = true:silent
5455
###############################
5556
# Naming Conventions #
5657
###############################
@@ -92,6 +93,8 @@ csharp_style_deconstructed_variable_declaration = true:suggestion
9293
csharp_prefer_simple_default_expression = true:suggestion
9394
csharp_style_pattern_local_over_anonymous_function = true:suggestion
9495
csharp_style_inlined_variable_declaration = true:suggestion
96+
csharp_style_namespace_declarations = file_scoped
97+
csharp_style_prefer_primary_constructors= false:silent
9598
###############################
9699
# C# Formatting Rules #
97100
###############################

codehelp/CodeHelpers.Test/LogGenerator/LogGeneratorTest.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace CodeHelpers.Test.LogGenerator;
22

33
using System.Text;
4-
using Microsoft.CodeAnalysis;
54
using Microsoft.CodeAnalysis.CSharp.Testing;
65
using Microsoft.CodeAnalysis.Testing;
76
using Microsoft.CodeAnalysis.Text;

codehelp/CodeHelpers.Test/LogGenerator/LogGeneratorTestVb.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace CodeHelpers.Test.LogGenerator;
22

33
using System.Text;
4-
using Microsoft.CodeAnalysis;
54
using Microsoft.CodeAnalysis.Testing;
65
using Microsoft.CodeAnalysis.Text;
76
using Microsoft.CodeAnalysis.VisualBasic.Testing;

codehelp/CodeHelpers/IndentedStringBuilder.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Text;
2-
using Microsoft.CodeAnalysis;
32

43
namespace WPILib.CodeHelpers;
54

codehelp/CodeHelpers/LogGenerator/LogAttributeInfo.cs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Text;
33
using Microsoft.CodeAnalysis;
44
using Microsoft.CodeAnalysis.CSharp;
5-
using Microsoft.CodeAnalysis.PooledObjects;
65
using Stereologue;
76

87
namespace WPILib.CodeHelpers.LogGenerator;

codehelp/CodeHelpers/LogGenerator/LoggableType.cs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using Microsoft.CodeAnalysis.Diagnostics;
55
using Microsoft.CodeAnalysis.Text;
66
using WPILib.CodeHelpers.LogGenerator.Analyzer;
7-
using static WPILib.CodeHelpers.IndentedStringBuilder;
87

98
namespace WPILib.CodeHelpers.LogGenerator;
109

codehelp/CodeHelpers/LogGenerator/SourceGenerator/LogGeneratorVb.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Microsoft.CodeAnalysis;
2-
using Microsoft.CodeAnalysis.CSharp.Syntax;
32
using Microsoft.CodeAnalysis.VisualBasic.Syntax;
43

54
namespace WPILib.CodeHelpers.LogGenerator.SourceGenerator;

codehelp/CodeHelpers/ParameterlessStructs/Analyzer/ParameterlessStructDiagnostics.cs

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ namespace WPILib.CodeHelpers.ParameterlessStructs.Analyzer;
33
#pragma warning disable RS2008 // Enable analyzer release tracking
44

55
using Microsoft.CodeAnalysis;
6-
using Microsoft.CodeAnalysis.Diagnostics;
7-
using WPILib.CodeHelpers;
86

97
public static class ParameterlessStructDiagnostics
108
{

codehelp/CodeHelpers/SymbolExtensions.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Microsoft.CodeAnalysis;
2-
using Microsoft.CodeAnalysis.CSharp.Syntax;
32

43
namespace WPILib.CodeHelpers;
54

codehelp/CodeHelpers/TypeDeclarationModel.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Collections.Immutable;
2-
using System.Text;
32
using Microsoft.CodeAnalysis;
43

54
namespace WPILib.CodeHelpers;

dev/desktopDev/Program.cs

-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
using System;
22
using System.IO;
33
using System.Linq;
4-
using System.Runtime.InteropServices;
54
using System.Text.Json;
6-
using CsCore;
7-
using CsCore.Raw;
85
using UnitsNet.NumberExtensions.NumberToAngle;
96
using WPIHal.Natives.Simulation;
107
using WPIMath.Geometry;
11-
using WPIUtil;
12-
using WPIUtil.Natives;
138
using WPIUtil.Serialization.Struct;
149

1510
namespace DesktopDev;

src/hal/CANStreamMessage.cs

+8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ public struct CANStreamMessage
1616
[System.Runtime.CompilerServices.InlineArray(8)]
1717
public struct DataBuffer
1818
{
19+
#pragma warning disable IDE0044 // Add readonly modifier
20+
#pragma warning disable IDE0051 // Remove unused private members
1921
private byte _element0;
22+
#pragma warning restore IDE0051 // Remove unused private members
23+
#pragma warning restore IDE0044 // Add readonly modifier
2024
}
2125
}
2226

@@ -42,6 +46,10 @@ public CANMessage(ReadOnlySpan<byte> buffer, ulong timestamp)
4246
[InlineArray(8)]
4347
public struct DataBuffer
4448
{
49+
#pragma warning disable IDE0044 // Add readonly modifier
50+
#pragma warning disable IDE0051 // Remove unused private members
4551
private byte _element0;
52+
#pragma warning restore IDE0051 // Remove unused private members
53+
#pragma warning restore IDE0044 // Add readonly modifier
4654
}
4755
}

src/hal/JoystickAxis.cs

+8
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,21 @@ public readonly struct JoystickAxes
1111
[System.Runtime.CompilerServices.InlineArray(NumJoystickAxes)]
1212
public struct AxesBuffer
1313
{
14+
#pragma warning disable IDE0044 // Add readonly modifier
15+
#pragma warning disable IDE0051 // Remove unused private members
1416
private float _element0;
17+
#pragma warning restore IDE0051 // Remove unused private members
18+
#pragma warning restore IDE0044 // Add readonly modifier
1519
}
1620

1721
[System.Runtime.CompilerServices.InlineArray(NumJoystickAxes)]
1822
public struct RawBuffer
1923
{
24+
#pragma warning disable IDE0044 // Add readonly modifier
25+
#pragma warning disable IDE0051 // Remove unused private members
2026
private byte _element0;
27+
#pragma warning restore IDE0051 // Remove unused private members
28+
#pragma warning restore IDE0044 // Add readonly modifier
2129
}
2230
private readonly short m_count;
2331
private readonly AxesBuffer m_axes;

src/hal/JoystickDescriptor.cs

+6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public struct NativeJoystickDescriptor
3434
[System.Runtime.CompilerServices.InlineArray(256)]
3535
public struct NameBuffer
3636
{
37+
#pragma warning disable IDE0044 // Add readonly modifier
3738
private byte _element0;
39+
#pragma warning restore IDE0044 // Add readonly modifier
3840

3941
public readonly unsafe string FromNullTerminatedString()
4042
{
@@ -49,7 +51,11 @@ public readonly unsafe string FromNullTerminatedString()
4951
[System.Runtime.CompilerServices.InlineArray(12)]
5052
public struct AxesTypeBuffer
5153
{
54+
#pragma warning disable IDE0044 // Add readonly modifier
55+
#pragma warning disable IDE0051 // Remove unused private members
5256
private byte _element0;
57+
#pragma warning restore IDE0051 // Remove unused private members
58+
#pragma warning restore IDE0044 // Add readonly modifier
5359

5460
public readonly unsafe int[] FromRawBytes(int length)
5561
{

src/hal/JoystickPOVs.cs

+4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ public readonly struct JoystickPOVs
1111
[System.Runtime.CompilerServices.InlineArray(NumJoystickPOVs)]
1212
public struct PovsBuffer
1313
{
14+
#pragma warning disable IDE0044 // Add readonly modifier
15+
#pragma warning disable IDE0051 // Remove unused private members
1416
private short _element0;
17+
#pragma warning restore IDE0051 // Remove unused private members
18+
#pragma warning restore IDE0044 // Add readonly modifier
1519
}
1620

1721
private readonly short m_count;

src/hal/Natives/Simulation/HalAccelerometerData.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
43
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;
54

65
namespace WPIHal.Natives.Simulation;

src/hal/Natives/Simulation/HalAddressableLEDData.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
43
using unsafe HAL_ConstBufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
54
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;
65

src/hal/Natives/Simulation/HalAnalogGyroData.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
43
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;
54

65
namespace WPIHal.Natives.Simulation;

src/hal/Natives/Simulation/HalAnalogInData.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
43
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;
54

65
namespace WPIHal.Natives.Simulation;

src/hal/Natives/Simulation/HalAnalogOutData.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
43
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;
54

65
namespace WPIHal.Natives.Simulation;

src/hal/Natives/Simulation/HalAnalogTriggerData.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
43
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;
54

65
namespace WPIHal.Natives.Simulation;

src/hal/Natives/Simulation/HalCTREPCMData.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
43
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;
54

65
namespace WPIHal.Natives.Simulation;

src/hal/Natives/Simulation/HalDIOData.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
43
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;
54

65
namespace WPIHal.Natives.Simulation;

src/hal/Natives/Simulation/HalDigitalPWMData.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
43
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;
54

65
namespace WPIHal.Natives.Simulation;

src/hal/Natives/Simulation/HalDutyCycleData.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
43
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;
54

65
namespace WPIHal.Natives.Simulation;

src/hal/Natives/Simulation/HalEncoderData.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
43
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;
54

65
namespace WPIHal.Natives.Simulation;

src/hal/Natives/Simulation/HalNotifierData.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
4-
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;
53

64
namespace WPIHal.Natives.Simulation;
75

src/hal/Natives/Simulation/HalPWMData.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
43
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;
54

65
namespace WPIHal.Natives.Simulation;

src/hal/Natives/Simulation/HalPowerDistributionData.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
43
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;
54

65
namespace WPIHal.Natives.Simulation;

src/hal/Natives/Simulation/HalREVPHData.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
43
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;
54

65
namespace WPIHal.Natives.Simulation;

src/hal/Natives/Simulation/HalRelayData.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
43
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;
54

65
namespace WPIHal.Natives.Simulation;

src/hal/Natives/Simulation/HalSPIAccelerometerData.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
43
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;
54

65
namespace WPIHal.Natives.Simulation;

src/hal/Natives/Simulation/NotifyListener.cs

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
using System.Runtime.CompilerServices;
2-
using System.Runtime.InteropServices;
3-
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
4-
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;
5-
61
namespace WPIHal.Natives.Simulation;
72

83
public static unsafe partial class HalNotifyListener

src/hal/Natives/Simulation/Reset.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]<byte*, void*, byte*, uint, void>;
4-
using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]<byte*, void*, WPIHal.HalValue*, void>;
53

64
namespace WPIHal.Natives.Simulation;
75

src/newcommands/Command.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System;
2-
using System.Collections.Generic;
31
using CommunityToolkit.Diagnostics;
42
using WPIUtil.Sendable;
53

src/newcommands/ConditionalCommand.cs

+2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ public class ConditionalCommand : Command
66
{
77
private readonly Command m_onTrue;
88
private readonly Command m_onFalse;
9+
#pragma warning disable IDE0052 // Remove unread private members
910
private readonly Func<bool> m_condition;
11+
#pragma warning restore IDE0052 // Remove unread private members
1012

1113
public ConditionalCommand(Command onTrue, Command onFalse, Func<bool> condition)
1214
{

src/newcommands/DeferredCommand.cs

+2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ public class DeferredCommand : Command
66
{
77
private readonly Command m_nullCommand = new PrintCommand("[DeferredCommand] Supplied command was null!");
88

9+
#pragma warning disable IDE0052 // Remove unread private members
910
private readonly Func<Command> m_supplier;
1011
private Command m_command;
12+
#pragma warning restore IDE0052 // Remove unread private members
1113

1214
public DeferredCommand(Func<Command> supplier, HashSet<ISubsystem> requirements)
1315
{

src/ntcore/ConnectionInfo.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
using System.Runtime.InteropServices;
22
using System.Runtime.InteropServices.Marshalling;
3+
using NetworkTables.Natives;
34
using WPIUtil.Marshal;
45

5-
namespace NetworkTables.Natives;
6+
namespace NetworkTables;
67

78
[NativeMarshalling(typeof(ConnectionInfoMarshaller))]
89
[StructLayout(LayoutKind.Auto)]

src/ntcore/NetworkTable.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Collections.Concurrent;
22
using NetworkTables.Handles;
3-
using NetworkTables.Natives;
43

54
namespace NetworkTables;
65

src/ntcore/TopicInfo.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
using System.Runtime.InteropServices;
22
using System.Runtime.InteropServices.Marshalling;
33
using NetworkTables.Handles;
4+
using NetworkTables.Natives;
45
using WPIUtil.Marshal;
56

6-
namespace NetworkTables.Natives;
7+
namespace NetworkTables;
78

89
[NativeMarshalling(typeof(TopicInfoMarshaller))]
910
[StructLayout(LayoutKind.Auto)]

src/stereologue/Attributes.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System;
2-
31
namespace Stereologue;
42

53
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Field, Inherited = false, AllowMultiple = false)]

src/stereologue/LogType.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System;
2-
31
namespace Stereologue;
42

53
[Flags]

src/stereologue/Stereologuer.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using Google.Protobuf.WellKnownTypes;
43
using NetworkTables;
54
using WPIUtil.Logging;
65
using WPIUtil.Serialization.Protobuf;
@@ -18,7 +17,9 @@ private Stereologuer() { }
1817

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

20+
#pragma warning disable IDE0060 // Remove unused parameter
2121
public void Setup(string name, bool fileOnly, bool lazyLogging)
22+
#pragma warning restore IDE0060 // Remove unused parameter
2223
{
2324
rootPath = name;
2425
FileOnly = fileOnly;

0 commit comments

Comments
 (0)