Skip to content

Commit 4dbf108

Browse files
committed
Apply feedbacks
1 parent 4c20968 commit 4dbf108

File tree

16 files changed

+49
-52
lines changed

16 files changed

+49
-52
lines changed

src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/ComInterop/ComRuntimeHelpers.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ internal static ComTypes.ITypeInfo GetITypeInfoFromIDispatch(IDispatch dispatch)
166166
return typeInfo;
167167
}
168168

169-
internal static ComTypes.TYPEATTR GetTypeAttrForTypeInfo(ComTypes.ITypeInfo typeInfo)
169+
internal static unsafe ComTypes.TYPEATTR GetTypeAttrForTypeInfo(ComTypes.ITypeInfo typeInfo)
170170
{
171171
IntPtr pAttrs;
172172
typeInfo.GetTypeAttr(out pAttrs);
@@ -179,15 +179,15 @@ internal static ComTypes.TYPEATTR GetTypeAttrForTypeInfo(ComTypes.ITypeInfo type
179179

180180
try
181181
{
182-
return Marshal.PtrToStructure<ComTypes.TYPEATTR>(pAttrs);
182+
return *(ComTypes.TYPEATTR*)pAttrs;
183183
}
184184
finally
185185
{
186186
typeInfo.ReleaseTypeAttr(pAttrs);
187187
}
188188
}
189189

190-
internal static ComTypes.TYPELIBATTR GetTypeAttrForTypeLib(ComTypes.ITypeLib typeLib)
190+
internal static unsafe ComTypes.TYPELIBATTR GetTypeAttrForTypeLib(ComTypes.ITypeLib typeLib)
191191
{
192192
IntPtr pAttrs;
193193
typeLib.GetLibAttr(out pAttrs);
@@ -200,7 +200,7 @@ internal static ComTypes.TYPELIBATTR GetTypeAttrForTypeLib(ComTypes.ITypeLib typ
200200

201201
try
202202
{
203-
return Marshal.PtrToStructure<ComTypes.TYPELIBATTR>(pAttrs);
203+
return *(ComTypes.TYPELIBATTR*)pAttrs;
204204
}
205205
finally
206206
{

src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/ComInterop/IDispatchComObject.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ DynamicMetaObject IDynamicMetaObjectProvider.GetMetaObject(Expression parameter)
328328
return new IDispatchMetaObject(parameter, this);
329329
}
330330

331-
private static void GetFuncDescForDescIndex(ComTypes.ITypeInfo typeInfo, int funcIndex, out ComTypes.FUNCDESC funcDesc, out IntPtr funcDescHandle)
331+
private static unsafe void GetFuncDescForDescIndex(ComTypes.ITypeInfo typeInfo, int funcIndex, out ComTypes.FUNCDESC funcDesc, out IntPtr funcDescHandle)
332332
{
333333
IntPtr pFuncDesc;
334334
typeInfo.GetFuncDesc(funcIndex, out pFuncDesc);
@@ -339,7 +339,7 @@ private static void GetFuncDescForDescIndex(ComTypes.ITypeInfo typeInfo, int fun
339339
throw Error.CannotRetrieveTypeInformation();
340340
}
341341

342-
funcDesc = Marshal.PtrToStructure<ComTypes.FUNCDESC>(pFuncDesc);
342+
funcDesc = *(ComTypes.FUNCDESC*)pFuncDesc;
343343
funcDescHandle = pFuncDesc;
344344
}
345345

src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/Extensions/ServiceCollectionDescriptorExtensions.Keyed.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static void TryAddKeyedTransient(
8686
{
8787
ThrowHelper.ThrowIfNull(collection);
8888

89-
TryAddKeyedTransient<TService, TService>(collection, serviceKey);
89+
TryAddKeyedTransient(collection, typeof(TService), serviceKey, typeof(TService));
9090
}
9191

9292
/// <summary>
@@ -202,7 +202,7 @@ public static void TryAddKeyedScoped(
202202
{
203203
ThrowHelper.ThrowIfNull(collection);
204204

205-
TryAddKeyedScoped<TService, TService>(collection, serviceKey);
205+
TryAddKeyedScoped(collection, typeof(TService), serviceKey, typeof(TService));
206206
}
207207

208208
/// <summary>
@@ -318,7 +318,7 @@ public static void TryAddKeyedSingleton(
318318
{
319319
ThrowHelper.ThrowIfNull(collection);
320320

321-
TryAddKeyedSingleton<TService, TService>(collection, serviceKey);
321+
TryAddKeyedSingleton(collection, typeof(TService), serviceKey, typeof(TService));
322322
}
323323

324324
/// <summary>
@@ -354,7 +354,7 @@ public static void TryAddKeyedSingleton<TService>(this IServiceCollection collec
354354
ThrowHelper.ThrowIfNull(collection);
355355
ThrowHelper.ThrowIfNull(instance);
356356

357-
var descriptor = ServiceDescriptor.KeyedSingleton(serviceKey, implementationInstance: instance);
357+
var descriptor = ServiceDescriptor.KeyedSingleton(serviceType: typeof(TService), serviceKey, implementationInstance: instance);
358358
ServiceCollectionDescriptorExtensions.TryAdd(collection, descriptor);
359359
}
360360

src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/Extensions/ServiceCollectionDescriptorExtensions.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public static void TryAddTransient(
166166
{
167167
ThrowHelper.ThrowIfNull(collection);
168168

169-
TryAddTransient<TService, TService>(collection);
169+
TryAddTransient(collection, typeof(TService), typeof(TService));
170170
}
171171

172172
/// <summary>
@@ -272,7 +272,7 @@ public static void TryAddScoped(
272272
{
273273
ThrowHelper.ThrowIfNull(collection);
274274

275-
TryAddScoped<TService, TService>(collection);
275+
TryAddScoped(collection, typeof(TService), typeof(TService));
276276
}
277277

278278
/// <summary>
@@ -378,7 +378,7 @@ public static void TryAddSingleton(
378378
{
379379
ThrowHelper.ThrowIfNull(collection);
380380

381-
TryAddSingleton<TService, TService>(collection);
381+
TryAddSingleton(collection, typeof(TService), typeof(TService));
382382
}
383383

384384
/// <summary>
@@ -412,7 +412,7 @@ public static void TryAddSingleton<TService>(this IServiceCollection collection,
412412
ThrowHelper.ThrowIfNull(collection);
413413
ThrowHelper.ThrowIfNull(instance);
414414

415-
var descriptor = ServiceDescriptor.Singleton(implementationInstance: instance);
415+
var descriptor = ServiceDescriptor.Singleton(serviceType: typeof(TService), implementationInstance: instance);
416416
TryAdd(collection, descriptor);
417417
}
418418

src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/ServiceCollectionServiceExtensions.Keyed.cs

+4-5
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public static IServiceCollection AddKeyedTransient<TService, TImplementation>(
166166
ThrowHelper.ThrowIfNull(services);
167167
ThrowHelper.ThrowIfNull(implementationFactory);
168168

169-
return services.AddKeyedTransient<TService>(serviceKey, implementationFactory);
169+
return services.AddKeyedTransient(typeof(TService), serviceKey, implementationFactory);
170170
}
171171

172172
/// <summary>
@@ -324,10 +324,9 @@ public static IServiceCollection AddKeyedScoped<TService, TImplementation>(
324324
ThrowHelper.ThrowIfNull(services);
325325
ThrowHelper.ThrowIfNull(implementationFactory);
326326

327-
return services.AddKeyedScoped<TService>(serviceKey, implementationFactory);
327+
return services.AddKeyedScoped(typeof(TService), serviceKey, implementationFactory);
328328
}
329329

330-
331330
/// <summary>
332331
/// Adds a singleton service of the type specified in <paramref name="serviceType"/> with an
333332
/// implementation of the type specified in <paramref name="implementationType"/> to the
@@ -434,7 +433,7 @@ public static IServiceCollection AddKeyedSingleton(
434433
{
435434
ThrowHelper.ThrowIfNull(services);
436435

437-
return services.AddKeyedSingleton<TService, TService>(serviceKey);
436+
return services.AddKeyedSingleton(typeof(TService), serviceKey, typeof(TService));
438437
}
439438

440439
/// <summary>
@@ -483,7 +482,7 @@ public static IServiceCollection AddKeyedSingleton<TService, TImplementation>(
483482
ThrowHelper.ThrowIfNull(services);
484483
ThrowHelper.ThrowIfNull(implementationFactory);
485484

486-
return services.AddKeyedSingleton<TService>(serviceKey, implementationFactory);
485+
return services.AddKeyedSingleton(typeof(TService), serviceKey, implementationFactory);
487486
}
488487

489488
/// <summary>

src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/ServiceCollectionServiceExtensions.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public static IServiceCollection AddTransient<TService, TImplementation>(
150150
ThrowHelper.ThrowIfNull(services);
151151
ThrowHelper.ThrowIfNull(implementationFactory);
152152

153-
return services.AddTransient<TService>(implementationFactory);
153+
return services.AddTransient(typeof(TService), implementationFactory);
154154
}
155155

156156
/// <summary>
@@ -292,7 +292,7 @@ public static IServiceCollection AddScoped<TService, TImplementation>(
292292
ThrowHelper.ThrowIfNull(services);
293293
ThrowHelper.ThrowIfNull(implementationFactory);
294294

295-
return services.AddScoped<TService>(implementationFactory);
295+
return services.AddScoped(typeof(TService), implementationFactory);
296296
}
297297

298298

@@ -435,7 +435,7 @@ public static IServiceCollection AddSingleton<TService, TImplementation>(
435435
ThrowHelper.ThrowIfNull(services);
436436
ThrowHelper.ThrowIfNull(implementationFactory);
437437

438-
return services.AddSingleton<TService>(implementationFactory);
438+
return services.AddSingleton(typeof(TService), implementationFactory);
439439
}
440440

441441
/// <summary>

src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/SidList.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ internal SidList(Interop.SID_AND_ATTRIBUTES[] sidAndAttr)
6262
TranslateSids(null, pSids);
6363
}
6464

65-
private void TranslateSids(string target, IntPtr[] pSids)
65+
private unsafe void TranslateSids(string target, IntPtr[] pSids)
6666
{
6767
GlobalDebug.WriteLineIf(GlobalDebug.Info, "AuthZSet", "SidList: processing {0} SIDs", pSids.Length);
6868

@@ -157,8 +157,8 @@ private void TranslateSids(string target, IntPtr[] pSids)
157157

158158
for (int i = 0; i < domainCount; i++)
159159
{
160-
domains[i] = Marshal.PtrToStructure<Interop.LSA_TRUST_INFORMATION>(pCurrentDomain);
161-
pCurrentDomain = new IntPtr(pCurrentDomain.ToInt64() + Marshal.SizeOf<Interop.LSA_TRUST_INFORMATION>());
160+
domains[i] = *(Interop.LSA_TRUST_INFORMATION*)pCurrentDomain;
161+
pCurrentDomain = new IntPtr(pCurrentDomain.ToInt64() + sizeof(Interop.LSA_TRUST_INFORMATION));
162162
}
163163

164164
GlobalDebug.WriteLineIf(GlobalDebug.Info, "AuthZSet", "SidList: got {0} groups in {1} domains", sidCount, domainCount);

src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AuthZSet.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ out pClientContext
131131

132132
// Extract TOKEN_GROUPS.GroupCount
133133

134-
Interop.TOKEN_GROUPS tokenGroups = Marshal.PtrToStructure<Interop.TOKEN_GROUPS>(pBuffer);
134+
Interop.TOKEN_GROUPS tokenGroups = *(Interop.TOKEN_GROUPS*)pBuffer;
135135

136136
uint groupCount = tokenGroups.GroupCount;
137137

@@ -141,13 +141,13 @@ out pClientContext
141141
// each native SID_AND_ATTRIBUTES into a managed SID_AND_ATTR.
142142
Interop.SID_AND_ATTRIBUTES[] groups = new Interop.SID_AND_ATTRIBUTES[groupCount];
143143

144-
IntPtr currentItem = new IntPtr(pBuffer.ToInt64() + Marshal.SizeOf<Interop.TOKEN_GROUPS>() - sizeof(Interop.SID_AND_ATTRIBUTES));
144+
IntPtr currentItem = new IntPtr(pBuffer.ToInt64() + sizeof(Interop.TOKEN_GROUPS) - sizeof(Interop.SID_AND_ATTRIBUTES));
145145

146146
for (int i = 0; i < groupCount; i++)
147147
{
148-
groups[i] = Marshal.PtrToStructure<Interop.SID_AND_ATTRIBUTES>(currentItem);
148+
groups[i] = *(Interop.SID_AND_ATTRIBUTES*)currentItem;
149149

150-
currentItem = new IntPtr(currentItem.ToInt64() + Marshal.SizeOf<Interop.SID_AND_ATTRIBUTES>());
150+
currentItem += sizeof(Interop.SID_AND_ATTRIBUTES);
151151
}
152152

153153
_groupSidList = new SidList(groups);

src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Utils.cs

+6-7
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,14 @@ internal static SidType ClassifySID(byte[] sid)
198198
}
199199

200200

201-
internal static SidType ClassifySID(IntPtr pSid)
201+
internal static unsafe SidType ClassifySID(IntPtr pSid)
202202
{
203203
Debug.Assert(Interop.Advapi32.IsValidSid(pSid));
204204

205205
// Get the issuing authority and the first RID
206206
IntPtr pIdentAuth = Interop.Advapi32.GetSidIdentifierAuthority(pSid);
207207

208-
Interop.Advapi32.SID_IDENTIFIER_AUTHORITY identAuth =
209-
Marshal.PtrToStructure<Interop.Advapi32.SID_IDENTIFIER_AUTHORITY>(pIdentAuth);
208+
Interop.Advapi32.SID_IDENTIFIER_AUTHORITY identAuth = *(Interop.Advapi32.SID_IDENTIFIER_AUTHORITY*)pIdentAuth;
210209

211210
IntPtr pRid = Interop.Advapi32.GetSidSubAuthority(pSid, 0);
212211
int rid = Marshal.ReadInt32(pRid);
@@ -333,7 +332,7 @@ internal static bool IsSamUser()
333332
}
334333

335334

336-
internal static IntPtr GetCurrentUserSid()
335+
internal static unsafe IntPtr GetCurrentUserSid()
337336
{
338337
SafeTokenHandle tokenHandle = null;
339338
IntPtr pBuffer = IntPtr.Zero;
@@ -425,7 +424,7 @@ out tokenHandle
425424
}
426425

427426
// Retrieve the user's SID from the user info
428-
Interop.TOKEN_USER tokenUser = Marshal.PtrToStructure<Interop.TOKEN_USER>(pBuffer);
427+
Interop.TOKEN_USER tokenUser = *(Interop.TOKEN_USER*)pBuffer;
429428
IntPtr pUserSid = tokenUser.sidAndAttributes.Sid; // this is a reference into the NATIVE memory (into pBuffer)
430429

431430
Debug.Assert(Interop.Advapi32.IsValidSid(pUserSid));
@@ -457,7 +456,7 @@ out tokenHandle
457456
}
458457

459458

460-
internal static IntPtr GetMachineDomainSid()
459+
internal static unsafe IntPtr GetMachineDomainSid()
461460
{
462461
SafeLsaPolicyHandle policyHandle = null;
463462
IntPtr pBuffer = IntPtr.Zero;
@@ -496,7 +495,7 @@ internal static IntPtr GetMachineDomainSid()
496495
}
497496

498497
Debug.Assert(pBuffer != IntPtr.Zero);
499-
UnsafeNativeMethods.POLICY_ACCOUNT_DOMAIN_INFO info = Marshal.PtrToStructure<UnsafeNativeMethods.POLICY_ACCOUNT_DOMAIN_INFO>(pBuffer);
498+
UnsafeNativeMethods.POLICY_ACCOUNT_DOMAIN_INFO info = *(UnsafeNativeMethods.POLICY_ACCOUNT_DOMAIN_INFO*)pBuffer;
500499

501500
Debug.Assert(Interop.Advapi32.IsValidSid(info.DomainSid));
502501

src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapConnection.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -918,12 +918,12 @@ private unsafe Interop.BOOL ProcessClientCertificate(IntPtr ldapHandle, IntPtr C
918918
var list = new ArrayList();
919919
if (CAs != IntPtr.Zero)
920920
{
921-
SecPkgContext_IssuerListInfoEx trustedCAs = Marshal.PtrToStructure<SecPkgContext_IssuerListInfoEx>(CAs);
921+
SecPkgContext_IssuerListInfoEx trustedCAs = *(SecPkgContext_IssuerListInfoEx*)CAs;
922922
int issuerNumber = trustedCAs.cIssuers;
923923
for (int i = 0; i < issuerNumber; i++)
924924
{
925-
IntPtr tempPtr = (IntPtr)((byte*)trustedCAs.aIssuers + Marshal.SizeOf<CRYPTOAPI_BLOB>() * (nint)i);
926-
CRYPTOAPI_BLOB info = Marshal.PtrToStructure<CRYPTOAPI_BLOB>(tempPtr);
925+
IntPtr tempPtr = (IntPtr)((byte*)trustedCAs.aIssuers + sizeof(CRYPTOAPI_BLOB) * (nint)i);
926+
CRYPTOAPI_BLOB info = *(CRYPTOAPI_BLOB*)tempPtr;
927927
int dataLength = info.cbData;
928928

929929
byte[] context = new byte[dataLength];

src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryServer.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,8 @@ private unsafe void FreeReplicaInfo(DS_REPL_INFO_TYPE type, IntPtr value, SafeLi
692692

693693
internal unsafe void SyncReplicaHelper(IntPtr dsHandle, bool isADAM, string partition, string? sourceServer, int option, SafeLibraryHandle libHandle)
694694
{
695-
int structSize = Marshal.SizeOf<Guid>();
696-
IntPtr unmanagedGuid = (IntPtr)0;
695+
int structSize = sizeof(Guid);
696+
IntPtr unmanagedGuid = 0;
697697
Guid guid = Guid.Empty;
698698
AdamInstance? adamServer = null;
699699
DomainController? dcServer = null;

src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ForestTrustRelationshipInformation.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public unsafe void Save()
114114
{
115115
try
116116
{
117-
IntPtr ptr = (IntPtr)0;
117+
IntPtr ptr = 0;
118118
fileTime = Marshal.AllocHGlobal(Marshal.SizeOf<FileTime>());
119119
Interop.Kernel32.GetSystemTimeAsFileTime(fileTime);
120120

src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/TrustHelper.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ internal static unsafe void SetTrustedDomainInfoStatus(DirectoryContext context,
220220
}
221221

222222
// reconstruct the unmanaged structure to set it back
223-
newInfo = Marshal.AllocHGlobal(Marshal.SizeOf<Interop.Advapi32.TRUSTED_DOMAIN_INFORMATION_EX>());
223+
newInfo = Marshal.AllocHGlobal(sizeof(Interop.Advapi32.TRUSTED_DOMAIN_INFORMATION_EX));
224224
Marshal.StructureToPtr(domainInfo, newInfo, false);
225225

226226
result = Interop.Advapi32.LsaSetTrustedDomainInfoByName(handle, trustedDomainName, Interop.Advapi32.TRUSTED_INFORMATION_CLASS.TrustedDomainInformationEx, newInfo);

src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Utils.cs

+6-7
Original file line numberDiff line numberDiff line change
@@ -2038,7 +2038,7 @@ internal static bool IsSamUser()
20382038
}
20392039

20402040

2041-
internal static IntPtr GetCurrentUserSid()
2041+
internal static unsafe IntPtr GetCurrentUserSid()
20422042
{
20432043
SafeTokenHandle? tokenHandle = null;
20442044
IntPtr pBuffer = IntPtr.Zero;
@@ -2120,7 +2120,7 @@ out tokenHandle
21202120
}
21212121

21222122
// Retrieve the user's SID from the user info
2123-
global::Interop.TOKEN_USER tokenUser = Marshal.PtrToStructure<Interop.TOKEN_USER>(pBuffer)!;
2123+
global::Interop.TOKEN_USER tokenUser = *(Interop.TOKEN_USER*)pBuffer;
21242124
IntPtr pUserSid = tokenUser.sidAndAttributes.Sid; // this is a reference into the NATIVE memory (into pBuffer)
21252125

21262126
Debug.Assert(global::Interop.Advapi32.IsValidSid(pUserSid));
@@ -2147,7 +2147,7 @@ out tokenHandle
21472147
}
21482148
}
21492149

2150-
internal static IntPtr GetMachineDomainSid()
2150+
internal static unsafe IntPtr GetMachineDomainSid()
21512151
{
21522152
SafeLsaPolicyHandle? policyHandle = null;
21532153
IntPtr pBuffer = IntPtr.Zero;
@@ -2178,7 +2178,7 @@ internal static IntPtr GetMachineDomainSid()
21782178
}
21792179

21802180
Debug.Assert(pBuffer != IntPtr.Zero);
2181-
POLICY_ACCOUNT_DOMAIN_INFO info = Marshal.PtrToStructure<POLICY_ACCOUNT_DOMAIN_INFO>(pBuffer)!;
2181+
POLICY_ACCOUNT_DOMAIN_INFO info = *(POLICY_ACCOUNT_DOMAIN_INFO*)pBuffer;
21822182

21832183
Debug.Assert(global::Interop.Advapi32.IsValidSid(info.DomainSid));
21842184

@@ -2237,15 +2237,14 @@ internal static bool IsMachineDC(string? computerName)
22372237
}
22382238
}
22392239

2240-
internal static SidType ClassifySID(IntPtr pSid)
2240+
internal static unsafe SidType ClassifySID(IntPtr pSid)
22412241
{
22422242
Debug.Assert(global::Interop.Advapi32.IsValidSid(pSid));
22432243

22442244
// Get the issuing authority and the first RID
22452245
IntPtr pIdentAuth = global::Interop.Advapi32.GetSidIdentifierAuthority(pSid);
22462246

2247-
global::Interop.Advapi32.SID_IDENTIFIER_AUTHORITY identAuth =
2248-
Marshal.PtrToStructure<Interop.Advapi32.SID_IDENTIFIER_AUTHORITY>(pIdentAuth)!;
2247+
global::Interop.Advapi32.SID_IDENTIFIER_AUTHORITY identAuth = *(Interop.Advapi32.SID_IDENTIFIER_AUTHORITY*)pIdentAuth;
22492248

22502249
IntPtr pRid = global::Interop.Advapi32.GetSidSubAuthority(pSid, 0);
22512250
int rid = Marshal.ReadInt32(pRid);

src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Object.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ public unsafe void ToJS(object?[] value)
373373
return;
374374
}
375375
slot.Length = value.Length;
376-
int bytes = value.Length * Marshal.SizeOf<JSMarshalerArgument>();
376+
int bytes = value.Length * sizeof(JSMarshalerArgument);
377377
slot.Type = MarshalerType.Array;
378378
JSMarshalerArgument* payload = (JSMarshalerArgument*)Marshal.AllocHGlobal(bytes);
379379
Unsafe.InitBlock(payload, 0, (uint)bytes);

0 commit comments

Comments
 (0)