Skip to content

Commit 4cc76a8

Browse files
committed
Remove redundant CharSet from StructLayout attributes
Remove explicit `CharSet` values from `[StructLayout]` attributes applied to structs that do not contain `char`, `string`, or `StringBuilder` fields.
1 parent 506869c commit 4cc76a8

File tree

7 files changed

+24
-24
lines changed

7 files changed

+24
-24
lines changed

src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/UnsafeNativeMethods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ internal struct SystemTime
263263
public short Milliseconds;
264264
}
265265

266-
[StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode)]
266+
[StructLayout(LayoutKind.Explicit)]
267267
[SecurityCritical]
268268
internal struct EvtVariant
269269
{

src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ private struct WSManDWordDataInternal
928928
/// sequencing of data. Because of this the following structure will
929929
/// have only one string to hold stream information.
930930
/// </summary>
931-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
931+
[StructLayout(LayoutKind.Sequential)]
932932
internal struct WSManStreamIDSetStruct
933933
{
934934
internal int streamIDsCount;
@@ -1078,7 +1078,7 @@ internal struct WSManOption
10781078
/// <summary>
10791079
/// Unmanaged to Managed: WSMAN_OPERATION_INFO includes the struct directly, so this cannot be made internal to WsmanOptionSet.
10801080
/// </summary>
1081-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
1081+
[StructLayout(LayoutKind.Sequential)]
10821082
internal struct WSManOptionSetStruct
10831083
{
10841084
internal int optionsCount;
@@ -1326,7 +1326,7 @@ internal static WSManCommandArgSet UnMarshal(IntPtr unmanagedData)
13261326

13271327
internal struct WSManShellDisconnectInfo : IDisposable
13281328
{
1329-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
1329+
[StructLayout(LayoutKind.Sequential)]
13301330
private struct WSManShellDisconnectInfoInternal
13311331
{
13321332
/// <summary>
@@ -1544,7 +1544,7 @@ internal static WSManEnvironmentVariableSet UnMarshal(IntPtr unmanagedData)
15441544
return result;
15451545
}
15461546

1547-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
1547+
[StructLayout(LayoutKind.Sequential)]
15481548
private struct WSManEnvironmentVariableSetInternal
15491549
{
15501550
internal uint varsCount;
@@ -1567,7 +1567,7 @@ internal struct WSManEnvironmentVariableInternal
15671567
/// </summary>
15681568
internal class WSManProxyInfo : IDisposable
15691569
{
1570-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
1570+
[StructLayout(LayoutKind.Sequential)]
15711571
private struct WSManProxyInfoInternal
15721572
{
15731573
public int proxyAccessType;
@@ -2232,7 +2232,7 @@ internal static WSManOperationInfo UnMarshal(IntPtr unmanagedData)
22322232
/// selectorSet and optionSet are handled differently because they are structs that contain pointers to arrays of structs.
22332233
/// Most other data structures in the API point to structures using IntPtr rather than including the actual structure.
22342234
/// </summary>
2235-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
2235+
[StructLayout(LayoutKind.Sequential)]
22362236
private struct WSManOperationInfoInternal
22372237
{
22382238
internal WSManFragmentInternal fragment;
@@ -2304,7 +2304,7 @@ internal static WSManSelectorSet UnMarshal(WSManSelectorSetStruct resultInternal
23042304
/// <summary>
23052305
/// Managed representation of WSMAN_SELECTOR_SET.
23062306
/// </summary>
2307-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
2307+
[StructLayout(LayoutKind.Sequential)]
23082308
internal struct WSManSelectorSetStruct
23092309
{
23102310
internal int numberKeys;

src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ internal enum WSManPluginErrorCodes : int
8989
/// Explicit destruction and release of the IntPtrs is not required because
9090
/// their lifetime is managed by WinRM.
9191
/// </summary>
92-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
92+
[StructLayout(LayoutKind.Sequential)]
9393
internal class WSManPluginOperationShutdownContext // TODO: Rename to OperationShutdownContext when removing the MC++ module.
9494
{
9595
#region Internal Members

src/System.Management.Automation/namespaces/Win32Native.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ internal enum SID_NAME_USE
7676

7777
#region Struct
7878

79-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
79+
[StructLayout(LayoutKind.Sequential)]
8080
internal struct SID_AND_ATTRIBUTES
8181
{
8282
internal IntPtr Sid;
8383
internal uint Attributes;
8484
}
8585

86-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
86+
[StructLayout(LayoutKind.Sequential)]
8787
internal struct TOKEN_USER
8888
{
8989
internal SID_AND_ATTRIBUTES User;

src/System.Management.Automation/security/SecureStringHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ internal static class CAPI
594594
internal const int E_FILENOTFOUND = unchecked((int)0x80070002); // File not found
595595
internal const int ERROR_FILE_NOT_FOUND = 2; // File not found
596596

597-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
597+
[StructLayout(LayoutKind.Sequential)]
598598
internal struct CRYPTOAPI_BLOB
599599
{
600600
internal uint cbData;

src/System.Management.Automation/security/nativeMethods.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,28 +1287,28 @@ internal enum SecurityInformation : uint
12871287
UNPROTECTED_SACL_SECURITY_INFORMATION = 0x10000000
12881288
}
12891289

1290-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
1290+
[StructLayout(LayoutKind.Sequential)]
12911291
internal struct LUID
12921292
{
12931293
internal uint LowPart;
12941294
internal uint HighPart;
12951295
}
12961296

1297-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
1297+
[StructLayout(LayoutKind.Sequential)]
12981298
internal struct LUID_AND_ATTRIBUTES
12991299
{
13001300
internal LUID Luid;
13011301
internal uint Attributes;
13021302
}
13031303

1304-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
1304+
[StructLayout(LayoutKind.Sequential)]
13051305
internal struct TOKEN_PRIVILEGE
13061306
{
13071307
internal uint PrivilegeCount;
13081308
internal LUID_AND_ATTRIBUTES Privilege;
13091309
}
13101310

1311-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
1311+
[StructLayout(LayoutKind.Sequential)]
13121312
internal struct ACL
13131313
{
13141314
internal byte AclRevision;
@@ -1318,31 +1318,31 @@ internal struct ACL
13181318
internal ushort Sbz2;
13191319
}
13201320

1321-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
1321+
[StructLayout(LayoutKind.Sequential)]
13221322
internal struct ACE_HEADER
13231323
{
13241324
internal byte AceType;
13251325
internal byte AceFlags;
13261326
internal ushort AceSize;
13271327
}
13281328

1329-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
1329+
[StructLayout(LayoutKind.Sequential)]
13301330
internal struct SYSTEM_AUDIT_ACE
13311331
{
13321332
internal ACE_HEADER Header;
13331333
internal uint Mask;
13341334
internal uint SidStart;
13351335
}
13361336

1337-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
1337+
[StructLayout(LayoutKind.Sequential)]
13381338
internal struct LSA_UNICODE_STRING
13391339
{
13401340
internal ushort Length;
13411341
internal ushort MaximumLength;
13421342
internal IntPtr Buffer;
13431343
}
13441344

1345-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
1345+
[StructLayout(LayoutKind.Sequential)]
13461346
internal struct CENTRAL_ACCESS_POLICY
13471347
{
13481348
internal IntPtr CAPID;

src/System.Management.Automation/utils/PlatformInvokes.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,28 +444,28 @@ internal static extern bool AdjustTokenPrivileges(IntPtr tokenHandler, bool disa
444444
out TOKEN_PRIVILEGE previousPrivilegeState,
445445
ref int returnLength);
446446

447-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
447+
[StructLayout(LayoutKind.Sequential)]
448448
internal struct TOKEN_PRIVILEGE
449449
{
450450
internal uint PrivilegeCount;
451451
internal LUID_AND_ATTRIBUTES Privilege;
452452
}
453453

454-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
454+
[StructLayout(LayoutKind.Sequential)]
455455
internal struct LUID
456456
{
457457
internal uint LowPart;
458458
internal uint HighPart;
459459
}
460460

461-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
461+
[StructLayout(LayoutKind.Sequential)]
462462
internal struct LUID_AND_ATTRIBUTES
463463
{
464464
internal LUID Luid;
465465
internal uint Attributes;
466466
}
467467

468-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
468+
[StructLayout(LayoutKind.Sequential)]
469469
internal struct PRIVILEGE_SET
470470
{
471471
internal uint PrivilegeCount;

0 commit comments

Comments
 (0)