Skip to content

Commit 448d80d

Browse files
authored
Update System.Memory.Data (#46134)
* link fixes * Revert "link fixes" This reverts commit 61d9eaa. * update * AOT updates * SCM test fix * update API * Another storage fix * fixes for communication / openai * update snippets * fix * fixes
1 parent 34c4cb5 commit 448d80d

File tree

15 files changed

+62
-24
lines changed

15 files changed

+62
-24
lines changed

eng/Packages.Data.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
<PackageReference Update="System.ClientModel" Version="1.1.0" />
9090
<PackageReference Update="System.IO.Hashing" Version="6.0.0" />
9191
<PackageReference Update="System.Memory" Version="4.5.5" />
92-
<PackageReference Update="System.Memory.Data" Version="1.0.2" />
92+
<PackageReference Update="System.Memory.Data" Version="6.0.0" />
9393
<PackageReference Update="System.Numerics.Vectors" Version="4.5.0" />
9494
<PackageReference Update="System.Net.Http" Version="4.3.4" />
9595
<PackageReference Update="System.Diagnostics.DiagnosticSource" Version="6.0.1" />

sdk/communication/Azure.Communication.JobRouter/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ foreach (EventGridEvent egEvent in egEvents)
157157
switch (egEvent.EventType)
158158
{
159159
case "Microsoft.Communication.WorkerOfferIssued":
160-
AcsRouterWorkerOfferIssuedEventData deserializedEventData =
160+
AcsRouterWorkerOfferIssuedEventData? deserializedEventData =
161161
egEvent.Data.ToObjectFromJson<AcsRouterWorkerOfferIssuedEventData>();
162-
Console.Write(deserializedEventData.OfferId); // Offer Id
163-
offerId = deserializedEventData.OfferId;
162+
Console.Write(deserializedEventData?.OfferId); // Offer Id
163+
offerId = deserializedEventData?.OfferId ?? string.Empty;
164164
break;
165165
// Handle any other custom event type
166166
default:

sdk/communication/Azure.Communication.JobRouter/samples/Sample1_HelloWorld.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ foreach (EventGridEvent egEvent in egEvents)
102102
switch (egEvent.EventType)
103103
{
104104
case "Microsoft.Communication.WorkerOfferIssued":
105-
AcsRouterWorkerOfferIssuedEventData deserializedEventData =
105+
AcsRouterWorkerOfferIssuedEventData? deserializedEventData =
106106
egEvent.Data.ToObjectFromJson<AcsRouterWorkerOfferIssuedEventData>();
107-
Console.Write(deserializedEventData.OfferId); // Offer Id
108-
offerId = deserializedEventData.OfferId;
107+
Console.Write(deserializedEventData?.OfferId); // Offer Id
108+
offerId = deserializedEventData?.OfferId ?? string.Empty;
109109
break;
110110
// Handle any other custom event type
111111
default:

sdk/communication/Azure.Communication.JobRouter/samples/Sample1_HelloWorldAsync.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ foreach (EventGridEvent egEvent in egEvents)
102102
switch (egEvent.EventType)
103103
{
104104
case "Microsoft.Communication.WorkerOfferIssued":
105-
AcsRouterWorkerOfferIssuedEventData deserializedEventData =
105+
AcsRouterWorkerOfferIssuedEventData? deserializedEventData =
106106
egEvent.Data.ToObjectFromJson<AcsRouterWorkerOfferIssuedEventData>();
107-
Console.Write(deserializedEventData.OfferId); // Offer Id
108-
offerId = deserializedEventData.OfferId;
107+
Console.Write(deserializedEventData?.OfferId); // Offer Id
108+
offerId = deserializedEventData?.OfferId ?? string.Empty;
109109
break;
110110
// Handle any other custom event type
111111
default:

sdk/communication/Azure.Communication.JobRouter/tests/Samples/JobRouterChangeNotification.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ public void ReceivedChangeNotification()
6262
switch (egEvent.EventType)
6363
{
6464
case "Microsoft.Communication.WorkerOfferIssued":
65-
AcsRouterWorkerOfferIssuedEventData deserializedEventData =
65+
AcsRouterWorkerOfferIssuedEventData? deserializedEventData =
6666
egEvent.Data.ToObjectFromJson<AcsRouterWorkerOfferIssuedEventData>();
67-
Console.Write(deserializedEventData.OfferId); // Offer Id
68-
offerId = deserializedEventData.OfferId;
67+
Console.Write(deserializedEventData?.OfferId); // Offer Id
68+
offerId = deserializedEventData?.OfferId ?? string.Empty;
6969
break;
7070
// Handle any other custom event type
7171
default:

sdk/core/Azure.Core/api/Azure.Core.net6.0.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public static partial class AzureCoreExtensions
2222
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("This utilizes reflection-based JSON serialization and deserialization which is not compatible with trimming.")]
2323
public static dynamic ToDynamicFromJson(this System.BinaryData utf8Json, Azure.Core.Serialization.JsonPropertyNames propertyNameFormat, string dateTimeFormat = "o") { throw null; }
2424
public static System.Threading.Tasks.ValueTask<T?> ToObjectAsync<T>(this System.BinaryData data, Azure.Core.Serialization.ObjectSerializer serializer, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
25+
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("This utilizes reflection-based JSON serialization and deserialization which is not compatible with trimming.")]
2526
public static object? ToObjectFromJson(this System.BinaryData data) { throw null; }
2627
public static T? ToObject<T>(this System.BinaryData data, Azure.Core.Serialization.ObjectSerializer serializer, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
2728
}
@@ -1189,6 +1190,7 @@ protected ObjectSerializer() { }
11891190
}
11901191
namespace Azure.Messaging
11911192
{
1193+
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("This utilizes reflection-based JSON serialization and deserialization which is not compatible with trimming.")]
11921194
public partial class CloudEvent
11931195
{
11941196
public CloudEvent(string source, string type, System.BinaryData? data, string? dataContentType, Azure.Messaging.CloudEventDataFormat dataFormat = Azure.Messaging.CloudEventDataFormat.Binary) { }

sdk/core/Azure.Core/src/Messaging/CloudEvent.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using System.Diagnostics.CodeAnalysis;
67
using System.Text.Json;
78
using System.Text.Json.Serialization;
89
using Azure.Core;
10+
using Azure.Core.Serialization;
911

1012
namespace Azure.Messaging
1113
{
1214
/// <summary> Represents a CloudEvent conforming to the 1.0 schema. This type has built-in serialization using System.Text.Json.</summary>
1315
[JsonConverter(typeof(CloudEventConverter))]
16+
[RequiresUnreferencedCode(DynamicData.SerializationRequiresUnreferencedCode)]
17+
[RequiresDynamicCode(DynamicData.SerializationRequiresUnreferencedCode)]
1418
public class CloudEvent
1519
{
1620
/// <summary> Initializes a new instance of the <see cref="CloudEvent"/> class. </summary>

sdk/core/Azure.Core/src/Messaging/CloudEventConverter.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using System.Diagnostics.CodeAnalysis;
67
using System.Text.Json;
78
using System.Text.Json.Serialization;
89
using Azure.Core;
10+
using Azure.Core.Serialization;
911

1012
namespace Azure.Messaging
1113
{
1214
/// <summary>
1315
/// A custom converter that attributes the <see cref="CloudEvent"/> type.
1416
/// This allows System.Text.Json to serialize and deserialize CloudEvents by default.
1517
/// </summary>
18+
[RequiresUnreferencedCode(DynamicData.SerializationRequiresUnreferencedCode)]
19+
[RequiresDynamicCode(DynamicData.SerializationRequiresUnreferencedCode)]
1620
internal class CloudEventConverter : JsonConverter<CloudEvent>
1721
{
1822
/// <summary>

sdk/core/Azure.Core/src/Serialization/AzureCoreExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ public static class AzureCoreExtensions
5454
/// Otherwise, it returns either an object[] or Dictionary&lt;string, object&gt;.
5555
/// Each value in the key value pair or list will also be converted into a primitive or another complex type recursively.
5656
/// </returns>
57+
[RequiresUnreferencedCode(DynamicData.SerializationRequiresUnreferencedCode)]
58+
[RequiresDynamicCode(DynamicData.SerializationRequiresUnreferencedCode)]
5759
public static object? ToObjectFromJson(this BinaryData data)
5860
{
5961
JsonElement element = data.ToObjectFromJson<JsonElement>();

sdk/core/Azure.Core/tests/compatibility/ExpectedAotWarnings.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ILC : AOT analysis warning IL3050: Azure\.Core\.Json\.MutableJsonDocument: Using
1010
.*Azure\.Core.src.DynamicData.DynamicData\.ObjectEnumerator\.cs\(\d*\): Trim analysis warning IL2026: Azure\.Core\.Serialization\.DynamicData\.ObjectEnumerator\.Current\.get: Using member 'Azure\.Core\.Serialization\.DynamicData\.DynamicData\(MutableJsonElement,DynamicDataOptions\)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code\. This class utilizes reflection-based JSON serialization and deserialization which is not compatible with trimming
1111
.*Azure\.Core.src.DynamicData.DynamicData\.ObjectEnumerator\.cs\(\d*\): AOT analysis warning IL3050: Azure\.Core\.Serialization\.DynamicData\.ObjectEnumerator\.Current\.get: Using member 'Azure\.Core\.Serialization\.DynamicData\.DynamicData\(MutableJsonElement,DynamicDataOptions\)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling\. This class utilizes reflection-based JSON serialization and deserialization which is not compatible with trimming
1212
.*Azure\.Core.src.DynamicData.DynamicDataProperty\.cs\(\d*\): Trim analysis warning IL2026: Azure\.Core\.Serialization\.DynamicDataProperty\.System\.Dynamic\.IDynamicMetaObjectProvider\.GetMetaObject\(Expression\): Using member 'Azure\.Core\.Serialization\.DynamicDataProperty\.MetaObject\.MetaObject\(Expression,IDynamicMetaObjectProvider\)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code
13-
ILC : Trim analysis warning IL2026: System\.BinaryData\.BinaryData\(Object,JsonSerializerOptions,Type\): Using member 'System\.Text\.Json\.JsonSerializer\.SerializeToUtf8Bytes\(Object,Type,JsonSerializerOptions\)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code\. JSON serialization and deserialization might require types that cannot be statically analyzed\. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved
13+
ILC : Trim analysis warning IL2026: Azure\.Messaging\.CloudEvent: Using member 'Azure\.Messaging\.CloudEventConverter\.CloudEventConverter\(\)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code\. This utilizes reflection-based JSON serialization and deserialization which is not compatible with trimming
14+
ILC : AOT analysis warning IL3050: Azure\.Messaging\.CloudEvent: Using member 'Azure\.Messaging\.CloudEventConverter\.CloudEventConverter\(\)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling\. This utilizes reflection-based JSON serialization and deserialization which is not compatible with trimming
1415
ILC : AOT analysis warning IL3050: System\.BinaryData\.BinaryData\(Object,JsonSerializerOptions,Type\): Using member 'System\.Text\.Json\.JsonSerializer\.SerializeToUtf8Bytes\(Object,Type,JsonSerializerOptions\)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling\. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation\. Use System\.Text\.Json source generation for native AOT applications
15-
ILC : Trim analysis warning IL2026: System\.BinaryData\.ToObjectFromJson<T>\(JsonSerializerOptions\): Using member 'System\.Text\.Json\.JsonSerializer\.Deserialize\(ReadOnlySpan`1<Byte>,Type,JsonSerializerOptions\)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code\. JSON serialization and deserialization might require types that cannot be statically analyzed\. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved
16-
ILC : AOT analysis warning IL3050: System\.BinaryData\.ToObjectFromJson<T>\(JsonSerializerOptions\): Using member 'System\.Text\.Json\.JsonSerializer\.Deserialize\(ReadOnlySpan`1<Byte>,Type,JsonSerializerOptions\)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling\. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation\. Use System\.Text\.Json source generation for native AOT applications
16+
ILC : AOT analysis warning IL3050: System\.BinaryData\.ToObjectFromJson<T>\(JsonSerializerOptions\): Using member 'System\.Text\.Json\.JsonSerializer\.Deserialize<T>\(ReadOnlySpan`1<Byte>,JsonSerializerOptions\)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling\. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation\. Use System\.Text\.Json source generation for native AOT applications

0 commit comments

Comments
 (0)