Skip to content

Commit

Permalink
Merge pull request #746 from dorssel/implicit_usings
Browse files Browse the repository at this point in the history
Implicit usings
  • Loading branch information
dorssel committed Oct 28, 2023
2 parents ad585a9 + 96bde59 commit 141b482
Show file tree
Hide file tree
Showing 42 changed files with 24 additions and 152 deletions.
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ SPDX-License-Identifier: GPL-3.0-only

<!-- Use the latest C# language standard -->
<LangVersion>11.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>

<!-- Be very strict -->
<WarningLevel>5</WarningLevel>
Expand Down
1 change: 0 additions & 1 deletion UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ SPDX-License-Identifier: GPL-3.0-only
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand Down
3 changes: 0 additions & 3 deletions UsbIds/UsbIdsSourceGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.CodeAnalysis;
Expand Down
2 changes: 0 additions & 2 deletions Usbipd.Automation/AssemblySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;

[assembly: CLSCompliant(false)]
1 change: 0 additions & 1 deletion Usbipd.Automation/BusId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;

Expand Down
1 change: 0 additions & 1 deletion Usbipd.Automation/Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Net;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
Expand Down
1 change: 0 additions & 1 deletion Usbipd.Automation/NullableBusIdJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Text.Json;
using System.Text.Json.Serialization;

Expand Down
1 change: 0 additions & 1 deletion Usbipd.Automation/NullableIPAddressJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Net;
using System.Text.Json;
using System.Text.Json.Serialization;
Expand Down
2 changes: 0 additions & 2 deletions Usbipd.Automation/State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;

Expand Down
47 changes: 22 additions & 25 deletions Usbipd.Automation/UsbIds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,35 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
namespace Usbipd.Automation;

namespace Usbipd.Automation
public static partial class UsbIds
{
public static partial class UsbIds
static string? FindString(ulong[] array, ulong value)
{
static string? FindString(ulong[] array, ulong value)
var index = Array.BinarySearch(array, value);
if (index < 0)
{
var index = Array.BinarySearch(array, value);
if (index < 0)
// Negative means the bitwise complement of the first item greater.
index = ~index;
if (index >= array.Length)
{
// Negative means the bitwise complement of the first item greater.
index = ~index;
if (index >= array.Length)
{
return null;
}
if ((array[index] & 0xffffffff00000000) != value)
{
return null;
}
return null;
}
if ((array[index] & 0xffffffff00000000) != value)
{
return null;
}
var start = (int)(array[index] & 0xffffffff);
var end = Strings.IndexOf('\0', start);
return Strings.Substring(start, end - start);
}
var start = (int)(array[index] & 0xffffffff);
var end = Strings.IndexOf('\0', start);
return Strings.Substring(start, end - start);
}

public static (string? Vendor, string? Product) GetNames(VidPid vidPid)
{
var vendor = FindString(VendorLookup, (ulong)vidPid.Vid << 48);
var product = vendor is not null ? FindString(ProductLookup, ((ulong)vidPid.Vid << 48) | ((ulong)vidPid.Pid << 32)) : null;
return (vendor, product);
}
public static (string? Vendor, string? Product) GetNames(VidPid vidPid)
{
var vendor = FindString(VendorLookup, (ulong)vidPid.Vid << 48);
var product = vendor is not null ? FindString(ProductLookup, ((ulong)vidPid.Vid << 48) | ((ulong)vidPid.Pid << 32)) : null;
return (vendor, product);
}
}
1 change: 0 additions & 1 deletion Usbipd.Automation/VidPid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Globalization;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
Expand Down
2 changes: 0 additions & 2 deletions Usbipd.PowerShell/AssemblySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;

[assembly: CLSCompliant(false)]
2 changes: 0 additions & 2 deletions Usbipd.PowerShell/GetUsbipdDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
// SPDX-License-Identifier: GPL-3.0-only

using System.Diagnostics;
using System.IO;
using System.Management.Automation;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;
using Usbipd.Automation;

namespace Usbipd.PowerShell;
Expand Down
3 changes: 0 additions & 3 deletions Usbipd.PowerShell/Installation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Diagnostics;
using System.IO;
using System.Management.Automation;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace Usbipd.PowerShell;

Expand Down
1 change: 0 additions & 1 deletion Usbipd/AssemblySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Runtime.CompilerServices;

[assembly: CLSCompliant(false)]
Expand Down
5 changes: 0 additions & 5 deletions Usbipd/AttachedClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Usbipd.Automation;
using static Usbipd.Interop.Linux;
using static Usbipd.Interop.UsbIp;
Expand Down
7 changes: 0 additions & 7 deletions Usbipd/AttachedEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Windows.Win32;
using Windows.Win32.Devices.Usb;

Expand Down
1 change: 0 additions & 1 deletion Usbipd/ClientContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Net;
using System.Net.Sockets;
using Usbipd.Automation;
Expand Down
10 changes: 0 additions & 10 deletions Usbipd/CommandHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,15 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Collections.Generic;
using System.CommandLine;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Hosting.WindowsServices;
using Microsoft.Extensions.Logging;
using Usbipd.Automation;
using Windows.Win32.Security;
using static Usbipd.ConsoleTools;
Expand Down
5 changes: 0 additions & 5 deletions Usbipd/ConfigurationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using Usbipd.Automation;
using Windows.Win32;
using Windows.Win32.Devices.DeviceAndDriverInstallation;
Expand Down
1 change: 0 additions & 1 deletion Usbipd/ConfigurationManagerException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.ComponentModel;
using Windows.Win32;
using Windows.Win32.Devices.DeviceAndDriverInstallation;
Expand Down
8 changes: 0 additions & 8 deletions Usbipd/ConnectedClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,13 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Buffers.Binary;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Usbipd.Automation;
using Windows.Win32;
using Windows.Win32.Devices.DeviceAndDriverInstallation;
Expand Down
3 changes: 0 additions & 3 deletions Usbipd/ConsoleTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Collections.Generic;
using System.CommandLine;
using System.Linq;
using System.Text;
using Microsoft.Win32;
using Usbipd.Automation;
Expand Down
3 changes: 0 additions & 3 deletions Usbipd/DeviceFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.ComponentModel;
using System.Net;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Win32.SafeHandles;
using Windows.Win32;
using Windows.Win32.Foundation;
Expand Down
5 changes: 0 additions & 5 deletions Usbipd/ExportedDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Buffers.Binary;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Usbipd.Automation;
using Usbipd.Interop;
using Windows.Win32;
Expand Down
4 changes: 0 additions & 4 deletions Usbipd/Interop/UsbIp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Buffers.Binary;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Windows.Win32.Devices.Usb;

namespace Usbipd.Interop;
Expand Down
1 change: 0 additions & 1 deletion Usbipd/Interop/VBoxUsb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Runtime.InteropServices;
using Windows.Win32;

Expand Down
1 change: 0 additions & 1 deletion Usbipd/Interop/WinSDK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Runtime.InteropServices;
using Windows.Win32;
using Windows.Win32.Devices.Usb;
Expand Down
2 changes: 0 additions & 2 deletions Usbipd/LogEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.Net;
using Microsoft.Extensions.Logging;
using Usbipd.Automation;

namespace Usbipd;
Expand Down
2 changes: 0 additions & 2 deletions Usbipd/NewDev.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
//
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Threading;
using Windows.Win32;
using Windows.Win32.Devices.DeviceAndDriverInstallation;
using Windows.Win32.Foundation;
Expand Down
Loading

0 comments on commit 141b482

Please sign in to comment.