1
1
// Licensed to the .NET Foundation under one or more agreements.
2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
4
+ using System . ComponentModel ;
4
5
using System . Diagnostics . CodeAnalysis ;
5
6
using System . Reflection ;
6
7
using System . Runtime . CompilerServices ;
@@ -28,6 +29,7 @@ public static partial class Marshal
28
29
29
30
[ UnconditionalSuppressMessage ( "ReflectionAnalysis" , "IL2070:UnrecognizedReflectionPattern" ,
30
31
Justification = "Trimming doesn't affect types eligible for marshalling. Different exception for invalid inputs doesn't matter." ) ]
32
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
31
33
public static IntPtr OffsetOf ( Type t ! ! , string fieldName )
32
34
{
33
35
FieldInfo ? f = t . GetField ( fieldName , BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic ) ;
@@ -48,24 +50,32 @@ public static IntPtr OffsetOf(Type t!!, string fieldName)
48
50
[ MethodImpl ( MethodImplOptions . InternalCall ) ]
49
51
private static extern IntPtr OffsetOfHelper ( IRuntimeFieldInfo f ) ;
50
52
53
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
54
+ [ Obsolete ( "ReadByte(Object, Int32) may be unavailable in future releases." ) ]
51
55
[ RequiresDynamicCode ( "Marshalling code for the object might not be available" ) ]
52
56
public static byte ReadByte ( object ptr , int ofs )
53
57
{
54
58
return ReadValueSlow ( ptr , ofs , ( IntPtr nativeHome , int offset ) => ReadByte ( nativeHome , offset ) ) ;
55
59
}
56
60
61
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
62
+ [ Obsolete ( "ReadInt16(Object, Int32) may be unavailable in future releases." ) ]
57
63
[ RequiresDynamicCode ( "Marshalling code for the object might not be available" ) ]
58
64
public static short ReadInt16 ( object ptr , int ofs )
59
65
{
60
66
return ReadValueSlow ( ptr , ofs , ( IntPtr nativeHome , int offset ) => ReadInt16 ( nativeHome , offset ) ) ;
61
67
}
62
68
69
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
70
+ [ Obsolete ( "ReadInt32(Object, Int32) may be unavailable in future releases." ) ]
63
71
[ RequiresDynamicCode ( "Marshalling code for the object might not be available" ) ]
64
72
public static int ReadInt32 ( object ptr , int ofs )
65
73
{
66
74
return ReadValueSlow ( ptr , ofs , ( IntPtr nativeHome , int offset ) => ReadInt32 ( nativeHome , offset ) ) ;
67
75
}
68
76
77
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
78
+ [ Obsolete ( "ReadInt64(Object, Int32) may be unavailable in future releases." ) ]
69
79
[ RequiresDynamicCode ( "Marshalling code for the object might not be available" ) ]
70
80
public static long ReadInt64 ( [ MarshalAs ( UnmanagedType . AsAny ) , In ] object ptr , int ofs )
71
81
{
@@ -106,24 +116,32 @@ private static unsafe T ReadValueSlow<T>(object ptr, int ofs, Func<IntPtr, int,
106
116
}
107
117
}
108
118
119
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
120
+ [ Obsolete ( "WriteByte(Object, Int32, Byte) may be unavailable in future releases." ) ]
109
121
[ RequiresDynamicCode ( "Marshalling code for the object might not be available" ) ]
110
122
public static void WriteByte ( object ptr , int ofs , byte val )
111
123
{
112
124
WriteValueSlow ( ptr , ofs , val , ( IntPtr nativeHome , int offset , byte value ) => WriteByte ( nativeHome , offset , value ) ) ;
113
125
}
114
126
127
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
128
+ [ Obsolete ( "WriteInt16(Object, Int32, Int16) may be unavailable in future releases." ) ]
115
129
[ RequiresDynamicCode ( "Marshalling code for the object might not be available" ) ]
116
130
public static void WriteInt16 ( object ptr , int ofs , short val )
117
131
{
118
132
WriteValueSlow ( ptr , ofs , val , ( IntPtr nativeHome , int offset , short value ) => Marshal . WriteInt16 ( nativeHome , offset , value ) ) ;
119
133
}
120
134
135
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
136
+ [ Obsolete ( "WriteInt32(Object, Int32, Int32) may be unavailable in future releases." ) ]
121
137
[ RequiresDynamicCode ( "Marshalling code for the object might not be available" ) ]
122
138
public static void WriteInt32 ( object ptr , int ofs , int val )
123
139
{
124
140
WriteValueSlow ( ptr , ofs , val , ( IntPtr nativeHome , int offset , int value ) => Marshal . WriteInt32 ( nativeHome , offset , value ) ) ;
125
141
}
126
142
143
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
144
+ [ Obsolete ( "WriteInt64(Object, Int32, Int64) may be unavailable in future releases." ) ]
127
145
[ RequiresDynamicCode ( "Marshalling code for the object might not be available" ) ]
128
146
public static void WriteInt64 ( object ptr , int ofs , long val )
129
147
{
@@ -201,6 +219,8 @@ private static void PrelinkCore(MethodInfo m)
201
219
[ MethodImpl ( MethodImplOptions . InternalCall ) ]
202
220
public static extern /* struct _EXCEPTION_POINTERS* */ IntPtr GetExceptionPointers ( ) ;
203
221
222
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
223
+ [ Obsolete ( "GetExceptionCode() may be unavailable in future releases." ) ]
204
224
[ MethodImpl ( MethodImplOptions . InternalCall ) ]
205
225
public static extern int GetExceptionCode ( ) ;
206
226
@@ -211,6 +231,7 @@ private static void PrelinkCore(MethodInfo m)
211
231
/// </summary>
212
232
[ RequiresDynamicCode ( "Marshalling code for the object might not be available. Use the StructureToPtr<T> overload instead." ) ]
213
233
[ MethodImpl ( MethodImplOptions . InternalCall ) ]
234
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
214
235
public static extern void StructureToPtr ( object structure , IntPtr ptr , bool fDeleteOld ) ;
215
236
216
237
/// <summary>
@@ -225,6 +246,7 @@ private static void PrelinkCore(MethodInfo m)
225
246
/// </summary>
226
247
[ RequiresDynamicCode ( "Marshalling code for the object might not be available. Use the DestroyStructure<T> overload instead." ) ]
227
248
[ MethodImpl ( MethodImplOptions . InternalCall ) ]
249
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
228
250
public static extern void DestroyStructure ( IntPtr ptr , Type structuretype ) ;
229
251
230
252
[ MethodImpl ( MethodImplOptions . InternalCall ) ]
@@ -327,6 +349,7 @@ public static string GetTypeInfoName(ITypeInfo typeInfo!!)
327
349
/// Object o should support Type T
328
350
/// </summary>
329
351
[ SupportedOSPlatform ( "windows" ) ]
352
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
330
353
public static IntPtr /* IUnknown* */ GetComInterfaceForObject ( object o ! ! , Type T ! ! )
331
354
{
332
355
return GetComInterfaceForObjectNative ( o , T , true ) ;
@@ -341,6 +364,7 @@ public static string GetTypeInfoName(ITypeInfo typeInfo!!)
341
364
/// invoke customized QueryInterface or not.
342
365
/// </summary>
343
366
[ SupportedOSPlatform ( "windows" ) ]
367
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
344
368
public static IntPtr /* IUnknown* */ GetComInterfaceForObject ( object o ! ! , Type T ! ! , CustomQueryInterfaceMode mode )
345
369
{
346
370
bool bEnableCustomizedQueryInterface = ( ( mode == CustomQueryInterfaceMode . Allow ) ? true : false ) ;
@@ -390,6 +414,7 @@ public static object GetUniqueObjectForIUnknown(IntPtr unknown)
390
414
public static extern object GetTypedObjectForIUnknown ( IntPtr /* IUnknown* */ pUnk , Type t ) ;
391
415
392
416
[ SupportedOSPlatform ( "windows" ) ]
417
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
393
418
public static IntPtr CreateAggregatedObject ( IntPtr pOuter , object o )
394
419
{
395
420
if ( ! IsBuiltInComSupported )
@@ -530,6 +555,7 @@ public static bool SetComObjectData(object obj, object key, object? data)
530
555
/// of the specified type. The type must be derived from __ComObject.
531
556
/// </summary>
532
557
[ SupportedOSPlatform ( "windows" ) ]
558
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
533
559
[ return : NotNullIfNotNull ( "o" ) ]
534
560
public static object ? CreateWrapperOfType ( object ? o , Type t )
535
561
{
@@ -603,6 +629,7 @@ public static TWrapper CreateWrapperOfType<T, TWrapper>(T? o)
603
629
public static extern bool IsTypeVisibleFromCom ( Type t ) ;
604
630
605
631
[ SupportedOSPlatform ( "windows" ) ]
632
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
606
633
public static void GetNativeVariantForObject ( object ? obj , /* VARIANT * */ IntPtr pDstNativeVariant )
607
634
{
608
635
if ( ! IsBuiltInComSupported )
@@ -617,6 +644,7 @@ public static void GetNativeVariantForObject(object? obj, /* VARIANT * */ IntPtr
617
644
private static extern void GetNativeVariantForObjectNative ( object ? obj , /* VARIANT * */ IntPtr pDstNativeVariant ) ;
618
645
619
646
[ SupportedOSPlatform ( "windows" ) ]
647
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
620
648
public static void GetNativeVariantForObject < T > ( T ? obj , IntPtr pDstNativeVariant )
621
649
{
622
650
if ( ! IsBuiltInComSupported )
@@ -628,6 +656,7 @@ public static void GetNativeVariantForObject<T>(T? obj, IntPtr pDstNativeVariant
628
656
}
629
657
630
658
[ SupportedOSPlatform ( "windows" ) ]
659
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
631
660
public static object ? GetObjectForNativeVariant ( /* VARIANT * */ IntPtr pSrcNativeVariant )
632
661
{
633
662
if ( ! IsBuiltInComSupported )
@@ -642,6 +671,7 @@ public static void GetNativeVariantForObject<T>(T? obj, IntPtr pDstNativeVariant
642
671
private static extern object ? GetObjectForNativeVariantNative ( /* VARIANT * */ IntPtr pSrcNativeVariant ) ;
643
672
644
673
[ SupportedOSPlatform ( "windows" ) ]
674
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
645
675
public static T ? GetObjectForNativeVariant < T > ( IntPtr pSrcNativeVariant )
646
676
{
647
677
if ( ! IsBuiltInComSupported )
@@ -653,6 +683,7 @@ public static void GetNativeVariantForObject<T>(T? obj, IntPtr pDstNativeVariant
653
683
}
654
684
655
685
[ SupportedOSPlatform ( "windows" ) ]
686
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
656
687
public static object ? [ ] GetObjectsForNativeVariants ( /* VARIANT * */ IntPtr aSrcNativeVariant , int cVars )
657
688
{
658
689
if ( ! IsBuiltInComSupported )
@@ -667,6 +698,7 @@ public static void GetNativeVariantForObject<T>(T? obj, IntPtr pDstNativeVariant
667
698
private static extern object ? [ ] GetObjectsForNativeVariantsNative ( /* VARIANT * */ IntPtr aSrcNativeVariant , int cVars ) ;
668
699
669
700
[ SupportedOSPlatform ( "windows" ) ]
701
+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
670
702
public static T [ ] GetObjectsForNativeVariants < T > ( IntPtr aSrcNativeVariant , int cVars )
671
703
{
672
704
if ( ! IsBuiltInComSupported )
0 commit comments