Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ private unsafe bool IsValueOfElementType(object value)
// if this is an array of value classes and that value class has a default constructor
// then this calls this default constructor on every element in the value class array.
// otherwise this is a no-op. Generally this method is called automatically by the compiler
[RequiresUnreferencedCode("The default constructor of the array's element type may be trimmed if not referenced elsewhere.")]
public unsafe void Initialize()
{
MethodTable* pArrayMT = RuntimeHelpers.GetMethodTable(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ internal static unsafe Array CtorRare(MethodTable* pEEType, int nDimensions, int
}
}

[RequiresUnreferencedCode("The default constructor of the array's element type may be trimmed if not referenced elsewhere.")]
public unsafe void Initialize()
{
MethodTable* pElementEEType = ElementMethodTable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ internal NMTOKENSDataContract() : base(DictionaryGlobals.NMTOKENSLocalName, Dict

internal sealed class ByteArrayDataContract : PrimitiveDataContract
{
[RequiresUnreferencedCode("The default constructor of the array's element type may be trimmed if not referenced elsewhere.")]
public ByteArrayDataContract() : base(typeof(byte[]), DictionaryGlobals.ByteArrayLocalName, DictionaryGlobals.SchemaNamespace)
{
}
Expand Down
1 change: 1 addition & 0 deletions src/libraries/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ public static void ForEach<T>(T[] array, System.Action<T> action) { }
public static int IndexOf<T>(T[] array, T value) { throw null; }
public static int IndexOf<T>(T[] array, T value, int startIndex) { throw null; }
public static int IndexOf<T>(T[] array, T value, int startIndex, int count) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The default constructor of the array's element type may be trimmed if not referenced elsewhere.")]
public void Initialize() { }
public static int LastIndexOf(System.Array array, object? value) { throw null; }
public static int LastIndexOf(System.Array array, object? value, int startIndex) { throw null; }
Expand Down
1 change: 1 addition & 0 deletions src/mono/System.Private.CoreLib/src/System/Array.Mono.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ internal void InternalSetValue(object? value, nint index)
SetValueImpl(ObjectHandleOnStack.Create(ref self), ObjectHandleOnStack.Create(ref value), (int)index);
}

[RequiresUnreferencedCode("The default constructor of the array's element type may be trimmed if not referenced elsewhere.")]
public void Initialize()
{
object arr = this;
Expand Down
Loading