Skip to content

Commit 351f040

Browse files
authored
Update shared source to use new overload (Azure#49866)
* Bump analyzer version in packages.data.props * revert analyzer bump
1 parent 0f8d812 commit 351f040

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

sdk/core/Azure.Core/src/Internal/GenericOperationSource.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ ValueTask<T> IOperationSource<T>.CreateResultAsync(Response response, Cancellati
1717
=> new ValueTask<T>(CreateResult(response));
1818

1919
private T CreateResult(Response response)
20+
// This call will never be invoked with a collection of models, so we can safely disable the warning
21+
#pragma warning disable AZC0150 // Use ModelReaderWriter overloads with ModelReaderWriterContext
2022
=> ModelReaderWriter.Read<T>(response.Content)!;
23+
#pragma warning restore AZC0150 // Use ModelReaderWriter overloads with ModelReaderWriterContext
2124
}
2225
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ BinaryData IPersistableModel<RehydrationToken>.Write(ModelReaderWriterOptions op
140140
switch (format)
141141
{
142142
case "J":
143-
return ModelReaderWriter.Write(this, options);
143+
return ModelReaderWriter.Write(this, options, AzureCoreContext.Default);
144144
default:
145145
throw new FormatException($"The model {nameof(RehydrationToken)} does not support '{options.Format}' format.");
146146
}

sdk/core/Azure.Core/src/Shared/NextLinkOperationImplementation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public static IOperation Create(
9999

100100
// TODO: Once we remove NextLinkOperationImplementation from internal shared and make it internal to Azure.Core only in https://github.com/Azure/azure-sdk-for-net/issues/43260
101101
// We can access the internal members from RehydrationToken directly
102-
var data = ModelReaderWriter.Write(rehydrationToken!, ModelReaderWriterOptions.Json);
102+
var data = ModelReaderWriter.Write(rehydrationToken!, ModelReaderWriterOptions.Json, AzureCoreContext.Default);
103103
using var document = JsonDocument.Parse(data);
104104
var lroDetails = document.RootElement;
105105

@@ -228,7 +228,7 @@ public static RehydrationToken GetRehydrationToken(
228228
{"version":"{{RehydrationTokenVersion}}","id":{{ConstructStringValue(operationId)}},"requestMethod":"{{requestMethod}}","initialUri":"{{startRequestUri.AbsoluteUri}}","nextRequestUri":"{{nextRequestUri}}","headerSource":"{{headerSource}}","finalStateVia":"{{finalStateVia}}","lastKnownLocation":{{ConstructStringValue(lastKnownLocation)}}}
229229
""";
230230
var data = new BinaryData(json);
231-
return ModelReaderWriter.Read<RehydrationToken>(data);
231+
return ModelReaderWriter.Read<RehydrationToken>(data, ModelReaderWriterOptions.Json, AzureCoreContext.Default);
232232
}
233233

234234
private static string? ConstructStringValue(string? value) => value is null ? "null" : $"\"{value}\"";

0 commit comments

Comments
 (0)