Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Adding attributes to support Native AOT compiling #37734

Merged
merged 90 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
e347a6a
part 1
m-redding Jul 19, 2023
0c247da
Merge branch 'Azure:main' into resolve-aot-warnings-phase1
m-redding Jul 19, 2023
dacab57
additional changes
m-redding Jul 19, 2023
466ef7b
additional attributes
m-redding Jul 20, 2023
07b5ec6
additional attributes
m-redding Jul 20, 2023
2c15eec
Merge branch 'Azure:main' into resolve-aot-warnings-phase1
m-redding Jul 24, 2023
581d888
adding diagnosticscope attributes
m-redding Jul 28, 2023
d1d99e7
Merge branch 'Azure:main' into resolve-aot-warnings-phase1
m-redding Jul 28, 2023
e6fa1e4
Merge branch 'resolve-aot-warnings-phase1' of https://github.com/m-re…
m-redding Jul 28, 2023
9d0ae69
updating messages
m-redding Jul 31, 2023
653623c
more fixes
m-redding Jul 31, 2023
5d9b2dc
additional updates
m-redding Jul 31, 2023
ddf556b
updates
m-redding Aug 3, 2023
44f0da5
PR feedback
m-redding Aug 4, 2023
f17c266
API update
m-redding Aug 4, 2023
540619f
removing unnecessary warnings
m-redding Aug 4, 2023
bf185ec
reverting attribute on HttpPipelineSynchronousPolicy
m-redding Aug 4, 2023
fcb6488
update api
m-redding Aug 4, 2023
7623768
updates
m-redding Aug 8, 2023
bdf71e9
update
m-redding Aug 8, 2023
d95f014
API export
m-redding Aug 9, 2023
032c14f
WIP fix 1
m-redding Aug 9, 2023
47228e8
WIP
m-redding Aug 9, 2023
47981b3
Merge branch 'Azure:main' into resolve-aot-warnings-phase1
m-redding Aug 9, 2023
f00379d
attribute adjustments
m-redding Aug 9, 2023
2b64b23
adding compatibility test
m-redding Aug 10, 2023
ebcd377
WIP adding test
m-redding Aug 14, 2023
ba7bcfe
WIP API
m-redding Aug 14, 2023
b074259
WIP
m-redding Aug 14, 2023
2d53367
WIP
m-redding Aug 14, 2023
d1010d2
Merge branch 'Azure:main' into resolve-aot-warnings-phase1
m-redding Aug 14, 2023
f879d9c
updates
m-redding Aug 14, 2023
e9253a0
add test script and remove #if statements
m-redding Aug 15, 2023
5473799
fixing build
m-redding Aug 15, 2023
f2c2543
Merge branch 'main' into resolve-aot-warnings-phase1
m-redding Aug 15, 2023
93bdee1
Update Program.cs
m-redding Aug 15, 2023
edbe071
adding some compile statements
m-redding Aug 15, 2023
f050d2e
Update AzureCoreEventSource.cs
m-redding Aug 15, 2023
ec1d84e
build fix attempt
m-redding Aug 17, 2023
3579eea
fix built attempt 2
m-redding Aug 17, 2023
5817ccc
Update MutableJsonChange.cs
m-redding Aug 18, 2023
9fa60a5
Update MutableJsonChange.cs
m-redding Aug 18, 2023
1a589df
Update MutableJsonDocument.cs
m-redding Aug 18, 2023
1d6986b
Update HttpPipelineSynchronousPolicy.cs
m-redding Aug 18, 2023
d78b8ef
adding comments
m-redding Aug 18, 2023
176afe6
PR fb 1
m-redding Aug 18, 2023
461c072
test
m-redding Aug 22, 2023
496b809
test2
m-redding Aug 22, 2023
f596df5
test3
m-redding Aug 22, 2023
a1751ce
Merge branch 'main' into resolve-aot-warnings-phase1
m-redding Aug 24, 2023
ebfc02d
attempt
m-redding Aug 28, 2023
553148c
Merge branch 'resolve-aot-warnings-phase1' of https://github.com/m-re…
m-redding Aug 28, 2023
0b83cb8
additional build fixes
m-redding Aug 29, 2023
27085c0
Remove comment
m-redding Aug 29, 2023
44b1bee
PR feedback + fixing impacts of feedback changes
m-redding Sep 7, 2023
9ebbf94
fixes
m-redding Sep 7, 2023
f6fef75
Update GeoRedundantFallbackPolicy.cs
m-redding Sep 7, 2023
8e4b7bb
Update GeoRedundantFallbackPolicy.cs
m-redding Sep 7, 2023
69cf078
Update GeoRedundantFallbackPolicy.cs
m-redding Sep 7, 2023
be791c5
fix
m-redding Sep 7, 2023
917647e
Merge branch 'main' into resolve-aot-warnings-phase1
m-redding Sep 7, 2023
b2a25e2
add tests
m-redding Sep 7, 2023
41040dd
pipeline fixes
m-redding Sep 7, 2023
8c0aa83
update comments
m-redding Sep 7, 2023
e9c06b3
feedback
m-redding Sep 7, 2023
83c118f
adjustments
m-redding Sep 7, 2023
0f6e866
adjustment
m-redding Sep 7, 2023
b677aec
pipeline fix
m-redding Sep 7, 2023
a211515
PR feedback 1
m-redding Sep 8, 2023
1026bc1
Apply suggestions from code review
m-redding Sep 8, 2023
b212d9e
PR feedback updates 2
m-redding Sep 8, 2023
1a12f76
Update sdk/core/Azure.Core/src/Shared/DiagnosticScope.cs
m-redding Sep 8, 2023
6c86362
need one other suppression
m-redding Sep 8, 2023
c25e250
remove 2 annotations + update suppression message
m-redding Sep 11, 2023
83d4650
removing all attributes from RequestContentHelper
m-redding Sep 11, 2023
ac9c480
tweak justification
m-redding Sep 12, 2023
23eea94
removing test project from Azure.Core, will be adding feedback to gen…
m-redding Sep 13, 2023
1969119
WIP
m-redding Sep 14, 2023
cc4a4a8
feedback
m-redding Sep 14, 2023
004ced0
Update sdk/core/Azure.Core/src/Shared/DiagnosticScope.cs
m-redding Sep 14, 2023
af15022
fix attribute and add comments
m-redding Sep 15, 2023
9938471
Merge branch 'resolve-aot-warnings-phase1' of https://github.com/m-re…
m-redding Sep 15, 2023
992ef22
Addressing feedback
m-redding Sep 25, 2023
00d5db1
adding net 5 preprocessor directives
m-redding Sep 26, 2023
d5ac8ee
Update sdk/core/Azure.Core/src/DynamicData/MutableJsonElement.cs
m-redding Sep 27, 2023
12c34f3
remove unused const
m-redding Sep 27, 2023
d2c8865
Merge branch 'resolve-aot-warnings-phase1' of https://github.com/m-re…
m-redding Sep 27, 2023
60e4c86
Merge branch 'Azure:main' into resolve-aot-warnings-phase1
m-redding Sep 27, 2023
9838582
Merge branch 'Azure:main' into resolve-aot-warnings-phase1
m-redding Sep 27, 2023
be02829
pipeline fix
m-redding Sep 27, 2023
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
14 changes: 14 additions & 0 deletions sdk/core/Azure.Core/api/Azure.Core.net6.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,11 @@ protected RequestContent() { }
public static Azure.Core.RequestContent Create(byte[] bytes) { throw null; }
public static Azure.Core.RequestContent Create(byte[] bytes, int index, int length) { throw null; }
public static Azure.Core.RequestContent Create(System.IO.Stream stream) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
m-redding marked this conversation as resolved.
Show resolved Hide resolved
public static Azure.Core.RequestContent Create(object serializable) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
public static Azure.Core.RequestContent Create(object serializable, Azure.Core.Serialization.JsonPropertyNames propertyNameFormat, string dateTimeFormat = "o") { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
public static Azure.Core.RequestContent Create(object serializable, Azure.Core.Serialization.ObjectSerializer? serializer) { throw null; }
public static Azure.Core.RequestContent Create(System.ReadOnlyMemory<byte> bytes) { throw null; }
public static Azure.Core.RequestContent Create(string content) { throw null; }
Expand Down Expand Up @@ -1024,6 +1027,7 @@ protected HttpPipelinePolicy() { }
protected static void ProcessNext(Azure.Core.HttpMessage message, System.ReadOnlyMemory<Azure.Core.Pipeline.HttpPipelinePolicy> pipeline) { }
protected static System.Threading.Tasks.ValueTask ProcessNextAsync(Azure.Core.HttpMessage message, System.ReadOnlyMemory<Azure.Core.Pipeline.HttpPipelinePolicy> pipeline) { throw null; }
}
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods)]
public abstract partial class HttpPipelineSynchronousPolicy : Azure.Core.Pipeline.HttpPipelinePolicy
{
protected HttpPipelineSynchronousPolicy() { }
Expand Down Expand Up @@ -1115,11 +1119,16 @@ public JsonObjectSerializer() { }
public JsonObjectSerializer(System.Text.Json.JsonSerializerOptions options) { }
public static Azure.Core.Serialization.JsonObjectSerializer Default { get { throw null; } }
string? Azure.Core.Serialization.IMemberNameConverter.ConvertMemberName(System.Reflection.MemberInfo member) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Calls JsonSerializer.Deserialize which requires unreferenced code.")]
public override object? Deserialize(System.IO.Stream stream, System.Type returnType, System.Threading.CancellationToken cancellationToken) { throw null; }
public override System.Threading.Tasks.ValueTask<object?> DeserializeAsync(System.IO.Stream stream, System.Type returnType, System.Threading.CancellationToken cancellationToken) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
public override void Serialize(System.IO.Stream stream, object? value, System.Type inputType, System.Threading.CancellationToken cancellationToken) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
public override System.BinaryData Serialize(object? value, System.Type? inputType = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
public override System.Threading.Tasks.ValueTask SerializeAsync(System.IO.Stream stream, object? value, System.Type inputType, System.Threading.CancellationToken cancellationToken) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
public override System.Threading.Tasks.ValueTask<System.BinaryData> SerializeAsync(object? value, System.Type? inputType = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
public enum JsonPropertyNames
Expand All @@ -1130,11 +1139,16 @@ public enum JsonPropertyNames
public abstract partial class ObjectSerializer
{
protected ObjectSerializer() { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Inherited methods require unreferenced code.")]
public abstract object? Deserialize(System.IO.Stream stream, System.Type returnType, System.Threading.CancellationToken cancellationToken);
public abstract System.Threading.Tasks.ValueTask<object?> DeserializeAsync(System.IO.Stream stream, System.Type returnType, System.Threading.CancellationToken cancellationToken);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Inherited methods require unreferenced code.")]
public abstract void Serialize(System.IO.Stream stream, object? value, System.Type inputType, System.Threading.CancellationToken cancellationToken);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Inherited methods require unreferenced code.")]
public virtual System.BinaryData Serialize(object? value, System.Type? inputType = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Inherited methods require unreferenced code.")]
public abstract System.Threading.Tasks.ValueTask SerializeAsync(System.IO.Stream stream, object? value, System.Type inputType, System.Threading.CancellationToken cancellationToken);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Inherited methods require unreferenced code.")]
public virtual System.Threading.Tasks.ValueTask<System.BinaryData> SerializeAsync(object? value, System.Type? inputType = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
}
Expand Down
4 changes: 4 additions & 0 deletions sdk/core/Azure.Core/src/Diagnostics/AzureCoreEventSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Diagnostics.CodeAnalysis; // Needed for NET6.0 attributes
using System.Text;

namespace Azure.Core.Diagnostics
Expand Down Expand Up @@ -231,6 +232,9 @@ public void ErrorResponseContentTextBlock(string requestId, int blockNumber, str
}

[Event(RequestRetryingEvent, Level = EventLevel.Informational, Message = "Request [{0}] attempt number {1} took {2:00.0}s")]
#if NET6_0_OR_GREATER
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026", Justification = "WriteEvent is used with primitive types.")]
#endif
public void RequestRetrying(string requestId, int retryNumber, double seconds)
{
WriteEvent(RequestRetryingEvent, requestId, retryNumber, seconds);
Expand Down
9 changes: 9 additions & 0 deletions sdk/core/Azure.Core/src/DynamicData/DynamicData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ internal DynamicData(MutableJsonElement element, DynamicDataOptions options)
_serializerOptions = DynamicDataOptions.ToSerializerOptions(options);
}

#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
m-redding marked this conversation as resolved.
Show resolved Hide resolved
#endif
internal void WriteTo(Stream stream)
{
using Utf8JsonWriter writer = new(stream);
Expand Down Expand Up @@ -296,6 +299,9 @@ public override bool Equals(object? obj)
};
}

#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
internal bool Equals(DynamicData other)
{
if (other is null)
Expand All @@ -319,6 +325,9 @@ internal bool Equals(DynamicData other)
};
}

#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
private bool NumberEqual(DynamicData other)
{
if (_element.TryGetDouble(out double d))
Expand Down
17 changes: 16 additions & 1 deletion sdk/core/Azure.Core/src/DynamicData/MutableJsonChange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,20 @@ public MutableJsonChange(string path,

public MutableJsonChangeKind ChangeKind { get; }

public JsonValueKind ValueKind => GetSerializedValue().ValueKind;
public JsonValueKind ValueKind
{
#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
get
{
return GetSerializedValue().ValueKind;
}
}

#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
m-redding marked this conversation as resolved.
Show resolved Hide resolved
#endif
internal JsonElement GetSerializedValue()
{
if (_serializedValue != null)
Expand Down Expand Up @@ -85,6 +97,9 @@ internal bool IsDirectDescendant(string path)
return ancestorPathLength == (descendantPathLength - 1);
}

#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
internal string AsString()
{
return GetSerializedValue().ToString() ?? "null";
Expand Down
12 changes: 12 additions & 0 deletions sdk/core/Azure.Core/src/DynamicData/MutableJsonElement.WriteTo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ namespace Azure.Core.Json
{
internal partial struct MutableJsonElement
{
#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
internal void WriteTo(Utf8JsonWriter writer)
{
WriteElement(_path, _highWaterMark, _element, writer);
}

#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
private void WriteElement(string path, int highWaterMark, JsonElement element, Utf8JsonWriter writer)
{
if (Changes.TryGetChange(path, highWaterMark, out MutableJsonChange change))
Expand Down Expand Up @@ -69,6 +75,9 @@ private void WriteElement(string path, int highWaterMark, JsonElement element, U
element.WriteTo(writer);
}

#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
private void WriteObject(string path, int highWaterMark, JsonElement element, Utf8JsonWriter writer)
{
writer.WriteStartObject();
Expand Down Expand Up @@ -96,6 +105,9 @@ private void WriteObject(string path, int highWaterMark, JsonElement element, Ut
writer.WriteEndObject();
}

#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
private void WriteArray(string path, int highWaterMark, JsonElement element, Utf8JsonWriter writer)
{
writer.WriteStartArray();
Expand Down
45 changes: 45 additions & 0 deletions sdk/core/Azure.Core/src/DynamicData/MutableJsonElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ internal MutableJsonElement(MutableJsonDocument root, JsonElement element, strin
/// </summary>
public JsonValueKind? ValueKind
{
#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
m-redding marked this conversation as resolved.
Show resolved Hide resolved
#endif
get
{
if (Changes.TryGetChange(_path, _highWaterMark, out MutableJsonChange change))
Expand Down Expand Up @@ -134,6 +137,9 @@ internal MutableJsonElement GetIndexElement(int index)
/// <see langword="false"/> otherwise.
/// </returns>
/// <exception cref="InvalidOperationException">This value's <see cref="ValueKind"/> is not <see cref="JsonValueKind.Number"/>.</exception>
#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
public bool TryGetDouble(out double value)
{
EnsureValid();
Expand Down Expand Up @@ -187,6 +193,9 @@ private static string GetFormatExceptionText(string path, Type type)
/// <see langword="false"/> otherwise.
/// </returns>
/// <exception cref="InvalidOperationException">This value's <see cref="ValueKind"/> is not <see cref="JsonValueKind.Number"/>.</exception>
#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
public bool TryGetInt32(out int value)
{
EnsureValid();
Expand Down Expand Up @@ -235,6 +244,9 @@ public int GetInt32()
/// <see langword="false"/> otherwise.
/// </returns>
/// <exception cref="InvalidOperationException">This value's <see cref="ValueKind"/> is not <see cref="JsonValueKind.Number"/>.</exception>
#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
public bool TryGetInt64(out long value)
{
EnsureValid();
Expand Down Expand Up @@ -283,6 +295,9 @@ public long GetInt64()
/// <see langword="false"/> otherwise.
/// </returns>
/// <exception cref="InvalidOperationException">This value's <see cref="ValueKind"/> is not <see cref="JsonValueKind.Number"/>.</exception>
#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
public bool TryGetSingle(out float value)
{
EnsureValid();
Expand Down Expand Up @@ -328,6 +343,9 @@ public float GetSingle()
/// </summary>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
public string? GetString()
{
EnsureValid();
Expand Down Expand Up @@ -377,6 +395,9 @@ public bool GetBoolean()
return _element.GetBoolean();
}

#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
public bool TryGetByte(out byte value)
{
EnsureValid();
Expand Down Expand Up @@ -480,6 +501,9 @@ public DateTimeOffset GetDateTimeOffset()
return value;
}

#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
public bool TryGetDecimal(out decimal value)
{
EnsureValid();
Expand Down Expand Up @@ -548,6 +572,9 @@ public Guid GetGuid()
return value;
}

#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
public bool TryGetInt16(out short value)
{
EnsureValid();
Expand Down Expand Up @@ -582,6 +609,9 @@ public short GetInt16()
return value;
}

#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
public bool TryGetSByte(out sbyte value)
{
EnsureValid();
Expand Down Expand Up @@ -616,6 +646,9 @@ public sbyte GetSByte()
return value;
}

#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
public bool TryGetUInt16(out ushort value)
{
EnsureValid();
Expand Down Expand Up @@ -650,6 +683,9 @@ public ushort GetUInt16()
return value;
}

#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
public bool TryGetUInt32(out uint value)
{
EnsureValid();
Expand Down Expand Up @@ -684,6 +720,9 @@ public uint GetUInt32()
return value;
}

#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
public bool TryGetUInt64(out ulong value)
{
EnsureValid();
Expand Down Expand Up @@ -1082,6 +1121,9 @@ public override string ToString()
return _element.ToString() ?? "null";
}

#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
internal JsonElement GetJsonElement()
{
EnsureValid();
Expand All @@ -1101,6 +1143,9 @@ internal JsonElement GetJsonElement()
return _element;
}

#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls JsonSerializer.SerializeToUtf8Bytes which requires unreferenced code.")]
#endif
private byte[] GetRawBytes()
{
using MemoryStream changedElementStream = new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ namespace Azure.Core.Pipeline
/// <summary>
/// Represents a <see cref="HttpPipelinePolicy"/> that doesn't do any asynchronous or synchronously blocking operations.
/// </summary>
#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods)]
#endif
public abstract class HttpPipelineSynchronousPolicy : HttpPipelinePolicy
{
private static Type[] _onReceivedResponseParameters = new[] { typeof(HttpMessage) };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

namespace Azure.Core.Pipeline
{
#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods)]
m-redding marked this conversation as resolved.
Show resolved Hide resolved
#endif
internal class ClientRequestIdPolicy : HttpPipelineSynchronousPolicy
{
internal const string ClientRequestIdHeader = "x-ms-client-request-id";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

namespace Azure.Core.Pipeline
{
#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods)]
#endif
internal class ReadClientRequestIdPolicy : HttpPipelineSynchronousPolicy
{
public const string MessagePropertyKey = "x-ms-client-request-id";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis; // Needed for NET6.0 attributes
m-redding marked this conversation as resolved.
Show resolved Hide resolved
using System.Globalization;
using System.Threading.Tasks;

Expand Down Expand Up @@ -56,6 +57,11 @@ public override void Process(HttpMessage message, ReadOnlyMemory<HttpPipelinePol
}
}

#if NET6_0_OR_GREATER
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(HttpMessage))]
m-redding marked this conversation as resolved.
Show resolved Hide resolved
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026", Justification = "The values being passed into Write have the commonly used properties being preserved with DynamicDependency.")]
m-redding marked this conversation as resolved.
Show resolved Hide resolved
#else
#endif
private async ValueTask ProcessAsync(HttpMessage message, ReadOnlyMemory<HttpPipelinePolicy> pipeline, bool async)
{
#if NETCOREAPP2_1
Expand Down
Loading
Loading