Skip to content

Commit 5c14064

Browse files
committed
Move to .NET 8
Seeing a new SID authority that I can't find the ID for in a few of the tests.
1 parent ba4be82 commit 5c14064

File tree

159 files changed

+814
-666
lines changed

Some content is hidden

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

159 files changed

+814
-666
lines changed

.editorconfig

+48-8
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ csharp_style_var_when_type_is_apparent = false:silent
9797

9898
# Expression-bodied members
9999
csharp_style_expression_bodied_accessors = true:silent
100-
csharp_style_expression_bodied_constructors =when_on_single_line:silent
100+
csharp_style_expression_bodied_constructors = false:silent
101101
csharp_style_expression_bodied_indexers = true:silent
102102
csharp_style_expression_bodied_lambdas = true:silent
103-
csharp_style_expression_bodied_local_functions =true:silent
104-
csharp_style_expression_bodied_methods =when_on_single_line:silent
105-
csharp_style_expression_bodied_operators =when_on_single_line:silent
106-
csharp_style_expression_bodied_properties = true:suggestion
103+
csharp_style_expression_bodied_local_functions = false:silent
104+
csharp_style_expression_bodied_methods = false:silent
105+
csharp_style_expression_bodied_operators = false:silent
106+
csharp_style_expression_bodied_properties = true:silent
107107

108108
# Pattern matching preferences
109109
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
@@ -133,8 +133,8 @@ csharp_style_unused_value_assignment_preference = discard_variable:suggestion
133133
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
134134

135135
# 'using' directive preferences
136-
csharp_using_directive_placement = outside_namespace:warning
137-
csharp_style_namespace_declarations = file_scoped:warning
136+
csharp_using_directive_placement = outside_namespace:silent
137+
csharp_style_namespace_declarations = block_scoped:none
138138

139139
# New line preferences
140140
csharp_new_line_before_catch = true
@@ -210,7 +210,7 @@ dotnet_naming_style.static_prefix_style.capitalization = camel_case
210210
# internal and private fields should be _camelCase
211211
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = warning
212212
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
213-
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
213+
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
214214
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
215215
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
216216
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
@@ -354,3 +354,43 @@ dotnet_diagnostic.SA1023.severity = silent
354354

355355
# SA1519: Braces should not be omitted from multi-line child statement
356356
dotnet_diagnostic.SA1519.severity = silent
357+
csharp_style_prefer_method_group_conversion = true:silent
358+
csharp_style_prefer_top_level_statements = true:silent
359+
csharp_style_prefer_primary_constructors = true:none
360+
csharp_prefer_system_threading_lock = true:suggestion
361+
362+
# SA1010: Opening square brackets should be spaced correctly
363+
dotnet_diagnostic.SA1010.severity = none
364+
365+
# IDE0290: Use primary constructor
366+
dotnet_diagnostic.IDE0290.severity = none
367+
368+
# xUnit1031: Do not use blocking task operations in test method
369+
dotnet_diagnostic.xUnit1031.severity = none
370+
371+
# CS8981: The type name only contains lower-cased ascii characters. Such names may become reserved for the language.
372+
dotnet_diagnostic.CS8981.severity = none
373+
374+
# IDE0160: Convert to block scoped namespace
375+
dotnet_diagnostic.IDE0160.severity = none
376+
377+
[*.{cs,vb}]
378+
dotnet_style_coalesce_expression = true:suggestion
379+
dotnet_style_null_propagation = true:suggestion
380+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
381+
dotnet_style_prefer_auto_properties = true:silent
382+
dotnet_style_object_initializer = true:suggestion
383+
dotnet_style_collection_initializer = true:suggestion
384+
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
385+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
386+
dotnet_style_prefer_conditional_expression_over_return = true:silent
387+
dotnet_style_explicit_tuple_names = true:suggestion
388+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
389+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
390+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
391+
tab_width = 4
392+
indent_size = 4
393+
end_of_line = crlf
394+
395+
# IDE0130: Namespace does not match folder structure
396+
dotnet_diagnostic.IDE0130.severity = none

Directory.Build.props

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<!-- Input Directories -->
1818
<PackagesDir Condition="'$(PackagesDir)'==''">$(RepoDir)packages\</PackagesDir>
1919

20-
<TargetFramework>net6.0-windows</TargetFramework>
20+
<TargetFramework>net8.0-windows</TargetFramework>
2121
<ImplicitUsings>enable</ImplicitUsings>
2222

2323
<GenerateDocumentationFile>true</GenerateDocumentationFile>
@@ -69,7 +69,7 @@
6969
<!-- We're generating our own assembly info in our common project -->
7070
<GenerateAssemblyInfo Condition="'$(GenerateAssemblyInfo)' == ''">false</GenerateAssemblyInfo>
7171

72-
<LangVersion>10.0</LangVersion>
72+
<LangVersion>12.0</LangVersion>
7373

7474
</PropertyGroup>
7575

src/AutoGenerated/AutoGenerated.csproj

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
4-
<TargetFramework>netstandard1.6</TargetFramework>
4+
<TargetFramework>netstandard2.0</TargetFramework>
55
<TransformOnBuild>true</TransformOnBuild>
66
</PropertyGroup>
7+
<ItemGroup>
8+
<PackageReference Include="System.Net.Http" Version="4.3.4" />
9+
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
10+
</ItemGroup>
711
<ItemGroup>
812
<EmbeddedResource Update="WInteropStrings.resx">
913
<Generator>ResXFileCodeGenerator</Generator>

src/Performance/Performance.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
10-
<PackageReference Include="Microsoft.Win32.SystemEvents" Version="6.0.0" />
9+
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
10+
<PackageReference Include="Microsoft.Win32.SystemEvents" Version="8.0.0" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

src/Tests/WInterop.Tests/Compression/LzTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,13 @@ public void CreateFile_OverMaxPathLongPath()
232232
private const string CompressedContent1 = "This is a test file that will test file compression. \r\n";
233233

234234
private static readonly byte[] CompressedFile1 =
235-
{
235+
[
236236
0x53, 0x5A, 0x44, 0x44, 0x88, 0xF0, 0x27, 0x33, 0x41, 0x00, 0x37, 0x00, 0x00, 0x00, 0xDF, 0x54,
237237
0x68, 0x69, 0x73, 0x20, 0xF2, 0xF0, 0x61, 0x20, 0xFF, 0x74, 0x65, 0x73, 0x74, 0x20, 0x66, 0x69,
238238
0x6C, 0xFF, 0x65, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x77, 0xF7, 0x69, 0x6C, 0x6C, 0xF9, 0xF8,
239239
0x63, 0x6F, 0x6D, 0x70, 0xFF, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6F, 0x6E, 0x2E, 0x07, 0x20, 0x0D,
240240
0x0A
241-
};
241+
];
242242

243243
private const string CompressedContent2 =
244244
"Four score and seven years ago our fathers brought forth upon this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal."
@@ -249,7 +249,7 @@ public void CreateFile_OverMaxPathLongPath()
249249
+ "It is altogether fitting and proper that we should do this.";
250250

251251
private static readonly byte[] CompressedFile2 =
252-
{
252+
[
253253
0x53, 0x5A, 0x44, 0x44, 0x88, 0xF0, 0x27, 0x33, 0x41, 0x00, 0x33, 0x02, 0x00, 0x00, 0xFF, 0x46,
254254
0x6F, 0x75, 0x72, 0x20, 0x73, 0x63, 0x6F, 0xFF, 0x72, 0x65, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x73,
255255
0xFF, 0x65, 0x76, 0x65, 0x6E, 0x20, 0x79, 0x65, 0x61, 0x7F, 0x72, 0x73, 0x20, 0x61, 0x67, 0x6F,
@@ -279,5 +279,5 @@ public void CreateFile_OverMaxPathLongPath()
279279
0x20, 0x49, 0x74, 0x20, 0x30, 0x00, 0x61, 0x6C, 0x77, 0x74, 0x6F, 0x67, 0xD9, 0x03, 0x66, 0x69,
280280
0x74, 0xD2, 0x02, 0xF0, 0xFB, 0xF1, 0x77, 0x01, 0xDC, 0x05, 0xAA, 0x00, 0x73, 0x68, 0x6F, 0x75,
281281
0x3A, 0x4B, 0x10, 0x64, 0x71, 0x01, 0x69, 0x73, 0x2E
282-
};
282+
];
283283
}

src/Tests/WInterop.Tests/Cryptography/CryptographyTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ public void BasicEnumerateStores()
4343
[Fact]
4444
public void BasicEnumerateLocations()
4545
{
46-
string[] knownLocations = { "CurrentUser", "LocalMachine", "CurrentService", "Services", "Users", "CurrentUserGroupPolicy", "LocalMachineGroupPolicy", "LocalMachineEnterprise" };
46+
string[] knownLocations = ["CurrentUser", "LocalMachine", "CurrentService", "Services", "Users", "CurrentUserGroupPolicy", "LocalMachineGroupPolicy", "LocalMachineEnterprise"];
4747
var locations = WInterop.Cryptography.Cryptography.EnumerateSystemStoreLocations();
4848
knownLocations.Should().BeSubsetOf(locations);
4949
}
5050

5151
[Fact]
5252
public void BasicEnumeratePhysical()
5353
{
54-
string[] knownPhysical = { ".Default", ".AuthRoot", ".GroupPolicy", ".Enterprise" };
54+
string[] knownPhysical = [".Default", ".AuthRoot", ".GroupPolicy", ".Enterprise"];
5555
var physical = WInterop.Cryptography.Cryptography.EnumeratePhysicalStores(SystemStoreLocation.LocalMachine, "Root");
5656
knownPhysical.Should().BeSubsetOf(physical.Select(p => p.PhysicalStoreName));
5757
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) Jeremy W. Kuhne. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using FluentAssertions.Equivalency;
5+
using System.Runtime.CompilerServices;
6+
7+
namespace WInterop.Tests;
8+
9+
internal static class ModuleInitializer
10+
{
11+
[ModuleInitializer]
12+
public static void Initialize()
13+
{
14+
AssertionOptions.AssertEquivalencyUsing(e => e.ExcludingRefStructs());
15+
}
16+
17+
public static TSelf ExcludingRefStructs<TSelf>(this SelfReferenceEquivalencyAssertionOptions<TSelf> options)
18+
where TSelf : SelfReferenceEquivalencyAssertionOptions<TSelf>
19+
{
20+
return options.Excluding(e => e.Type.IsByRefLike);
21+
}
22+
}

src/Tests/WInterop.Tests/Modules/Methods.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public void StdCallViaDllImport()
186186
[Fact]
187187
public unsafe void AsIntArrayInvoke()
188188
{
189-
int[] values = { 3, 4 };
189+
int[] values = [3, 4];
190190

191191
fixed (int* v = values)
192192
{
@@ -205,7 +205,7 @@ public unsafe void AsIntArrayInvoke()
205205
[Fact]
206206
public unsafe void AsRefIntInvoke()
207207
{
208-
int[] values = { 5, 6 };
208+
int[] values = [5, 6];
209209

210210
fixed (int* v = values)
211211
{
@@ -227,7 +227,7 @@ public unsafe void AsRefIntInvoke()
227227
[Fact]
228228
public unsafe void EmptyArrayBehavior()
229229
{
230-
int[] values = new int[0];
230+
int[] values = [];
231231

232232
fixed (int* v = values)
233233
{
@@ -251,7 +251,7 @@ public unsafe void EmptyArrayBehavior()
251251
[Fact]
252252
public unsafe void AsArrayInvoke()
253253
{
254-
Point[] points = { new Point(1, 2), new Point(3, 4) };
254+
Point[] points = [new Point(1, 2), new Point(3, 4)];
255255

256256
fixed (void* p = &points[0])
257257
{
@@ -271,7 +271,7 @@ public unsafe void AsArrayInvoke()
271271
[Fact]
272272
public unsafe void AsInOutArrayInvoke()
273273
{
274-
Point[] points = { new Point(1, 2), new Point(3, 4) };
274+
Point[] points = [new Point(1, 2), new Point(3, 4)];
275275

276276
fixed (void* p = &points[0])
277277
{
@@ -291,7 +291,7 @@ public unsafe void AsInOutArrayInvoke()
291291
[Fact]
292292
public unsafe void AsPointerArrayInvoke()
293293
{
294-
Point[] points = { new Point(1, 2), new Point(3, 4) };
294+
Point[] points = [new Point(1, 2), new Point(3, 4)];
295295

296296
fixed (Point* p = &points[0])
297297
{

src/Tests/WInterop.Tests/NetworkManagementTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public partial class Basic
1010
[Fact]
1111
public void BasicGetLocalGroupNames()
1212
{
13-
string[] knownLocalGroups = { "Administrators", "Guests", "Users" };
13+
string[] knownLocalGroups = ["Administrators", "Guests", "Users"];
1414
var localGroups = Network.EnumerateLocalGroups();
1515
localGroups.Should().Contain(knownLocalGroups);
1616
knownLocalGroups.Should().BeSubsetOf(localGroups);
@@ -19,7 +19,7 @@ public void BasicGetLocalGroupNames()
1919
[Fact]
2020
public void BasicGetLocalGroupMembers()
2121
{
22-
string[] knownMembers = { "Authenticated Users", "INTERACTIVE" };
22+
string[] knownMembers = ["Authenticated Users", "INTERACTIVE"];
2323
var members = Network.EnumerateGroupUsers("Users");
2424
members.Select(m => m.Name).Should().Contain(knownMembers);
2525
knownMembers.Should().BeSubsetOf(members.Select(m => m.Name));

src/Tests/WInterop.Tests/Shell/AssociationTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void GetTextAssociation_OpenCommandExecutable()
3939
{
4040
string value = ShellMethods.AssocQueryString(AssociationFlags.None, AssociationString.Executable, ".txt", "open");
4141
// Example: C:\Program Files (x86)\Notepad++\notepad++.exe
42-
value.Should().EndWithEquivalent(".exe");
42+
value.Should().EndWithEquivalentOf(".exe");
4343
}
4444

4545
[Fact]

src/Tests/WInterop.Tests/Shell/ShellTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class Basic
1212
public void GetKnownFolderPath_Basic()
1313
{
1414
string windowsFolder = ShellMethods.GetKnownFolderPath(KnownFolderIds.Windows);
15-
windowsFolder.Should().EndWithEquivalent("Windows");
15+
windowsFolder.Should().EndWithEquivalentOf("Windows");
1616
}
1717

1818
[Fact]

src/Tests/WInterop.Tests/Storage/FileSecurityTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void GetGroupSidForCreatedFile()
3131
using var handle = Storage.CreateFile(cleaner.GetTestPath(), CreationDisposition.CreateNew);
3232
handle.IsInvalid.Should().BeFalse();
3333
SecurityIdentifier sid = Storage.GetPrimaryGroup(handle);
34-
sid.Authority.Should().Be(IdentifierAuthority.NT);
34+
sid.Authority.Should().BeEquivalentTo(IdentifierAuthority.NT);
3535
string sidString = sid.ConvertSidToString();
3636
AccountSidInformation info = sid.LookupAccountSid();
3737
info.Usage.Should().Be(SidNameUse.User);

src/Tests/WInterop.Tests/Storage/StorageBehaviors.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public unsafe void FindFirstFileBehaviors()
177177
WIN32_FIND_DATAW findData;
178178
fixed (char* p = cleaner.TempFolder)
179179
{
180-
handle = TerraFXWindows.FindFirstFileW((ushort*)p, &findData);
180+
handle = TerraFXWindows.FindFirstFileW(p, &findData);
181181
}
182182

183183
try
@@ -194,7 +194,7 @@ public unsafe void FindFirstFileBehaviors()
194194

195195
fixed (char* p = cleaner.GetTestPath())
196196
{
197-
handle = TerraFXWindows.FindFirstFileW((ushort*)p, &findData);
197+
handle = TerraFXWindows.FindFirstFileW(p, &findData);
198198
}
199199
WindowsError error = Error.GetLastError();
200200

@@ -212,7 +212,7 @@ public unsafe void FindFirstFileBehaviors()
212212
}
213213

214214
fixed (char* p = Path.Join(cleaner.GetTestPath(), "NotHere"))
215-
handle = TerraFXWindows.FindFirstFileW((ushort*)p, &findData);
215+
handle = TerraFXWindows.FindFirstFileW(p, &findData);
216216
error = Error.GetLastError();
217217

218218
try
@@ -245,7 +245,7 @@ public unsafe void GetFileAttributesBehavior_Basic()
245245
{
246246

247247
bool success = TerraFXWindows.GetFileAttributesExW(
248-
(ushort*)p,
248+
p,
249249
GET_FILEEX_INFO_LEVELS.GetFileExInfoStandard,
250250
&attributeData);
251251
success.Should().BeTrue("root location exists");
@@ -254,7 +254,7 @@ public unsafe void GetFileAttributesBehavior_Basic()
254254
fixed (char* p = cleaner.GetTestPath())
255255
{
256256
bool success = TerraFXWindows.GetFileAttributesExW(
257-
(ushort*)p,
257+
p,
258258
GET_FILEEX_INFO_LEVELS.GetFileExInfoStandard,
259259
&attributeData);
260260
WindowsError error = Error.GetLastError();
@@ -265,7 +265,7 @@ public unsafe void GetFileAttributesBehavior_Basic()
265265
fixed (char* p = Path.Join(cleaner.GetTestPath(), "NotHere"))
266266
{
267267
bool success = TerraFXWindows.GetFileAttributesExW(
268-
(ushort*)p,
268+
p,
269269
GET_FILEEX_INFO_LEVELS.GetFileExInfoStandard,
270270
&attributeData);
271271

@@ -285,7 +285,7 @@ public unsafe void GetFileAttributesBehavior_BadCharactersOnNonExistantPath()
285285
fixed (char* p = tempPath)
286286
{
287287
success = TerraFXWindows.GetFileAttributesExW(
288-
(ushort*)p,
288+
p,
289289
GET_FILEEX_INFO_LEVELS.GetFileExInfoStandard,
290290
&attributeData);
291291
}
@@ -296,7 +296,7 @@ public unsafe void GetFileAttributesBehavior_BadCharactersOnNonExistantPath()
296296
fixed (char* p = Path.Join(tempPath, @"""*"""))
297297
{
298298
success = TerraFXWindows.GetFileAttributesExW(
299-
(ushort*)p,
299+
p,
300300
GET_FILEEX_INFO_LEVELS.GetFileExInfoStandard,
301301
&attributeData);
302302
}
@@ -309,7 +309,7 @@ public unsafe void GetFileAttributesBehavior_BadCharactersOnNonExistantPath()
309309
fixed (char* p = Path.Join(tempPath, Path.GetRandomFileName(), @"""*"""))
310310
{
311311
success = TerraFXWindows.GetFileAttributesExW(
312-
(ushort*)p,
312+
p,
313313
GET_FILEEX_INFO_LEVELS.GetFileExInfoStandard,
314314
&attributeData);
315315
}
@@ -344,7 +344,7 @@ public unsafe void GetFileAttributesBehavior_DeletedFile()
344344
fixed (char* p = path)
345345
{
346346
// Find file will work at this point.
347-
findHandle = TerraFXWindows.FindFirstFileW((ushort*)p, (WIN32_FIND_DATAW*)&findData);
347+
findHandle = TerraFXWindows.FindFirstFileW(p, (WIN32_FIND_DATAW*)&findData);
348348
findHandle.Should().NotBe(HANDLE.NULL);
349349
}
350350

0 commit comments

Comments
 (0)