From cd093d8746ec170b89b11727c2a3ed65ad001ee2 Mon Sep 17 00:00:00 2001
From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Date: Fri, 2 Dec 2022 13:29:12 -0800
Subject: [PATCH] Make typed property bag methods public (#32851)
---
sdk/core/Azure.Core/api/Azure.Core.net461.cs | 2 ++
sdk/core/Azure.Core/api/Azure.Core.net5.0.cs | 2 ++
sdk/core/Azure.Core/api/Azure.Core.net6.0.cs | 2 ++
sdk/core/Azure.Core/api/Azure.Core.netcoreapp2.1.cs | 2 ++
sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs | 2 ++
sdk/core/Azure.Core/src/HttpMessage.cs | 4 ++--
sdk/core/Azure.Core/src/Pipeline/Internal/TelemetryPolicy.cs | 2 +-
sdk/core/Azure.Core/src/TelemetryDetails.cs | 2 +-
sdk/core/Azure.Core/tests/TelemetryDetailsTests.cs | 2 +-
9 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/sdk/core/Azure.Core/api/Azure.Core.net461.cs b/sdk/core/Azure.Core/api/Azure.Core.net461.cs
index 45c61dabd973a..9e89df433b517 100644
--- a/sdk/core/Azure.Core/api/Azure.Core.net461.cs
+++ b/sdk/core/Azure.Core/api/Azure.Core.net461.cs
@@ -470,7 +470,9 @@ public HttpMessage(Azure.Core.Request request, Azure.Core.ResponseClassifier res
public void Dispose() { }
public System.IO.Stream? ExtractResponseContent() { throw null; }
public void SetProperty(string name, object value) { }
+ public void SetProperty(System.Type type, object value) { }
public bool TryGetProperty(string name, out object? value) { throw null; }
+ public bool TryGetProperty(System.Type type, out object? value) { throw null; }
}
public enum HttpPipelinePosition
{
diff --git a/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs b/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs
index 158b2c417e7b6..393bb05237a2a 100644
--- a/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs
+++ b/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs
@@ -470,7 +470,9 @@ public HttpMessage(Azure.Core.Request request, Azure.Core.ResponseClassifier res
public void Dispose() { }
public System.IO.Stream? ExtractResponseContent() { throw null; }
public void SetProperty(string name, object value) { }
+ public void SetProperty(System.Type type, object value) { }
public bool TryGetProperty(string name, out object? value) { throw null; }
+ public bool TryGetProperty(System.Type type, out object? value) { throw null; }
}
public enum HttpPipelinePosition
{
diff --git a/sdk/core/Azure.Core/api/Azure.Core.net6.0.cs b/sdk/core/Azure.Core/api/Azure.Core.net6.0.cs
index 158b2c417e7b6..393bb05237a2a 100644
--- a/sdk/core/Azure.Core/api/Azure.Core.net6.0.cs
+++ b/sdk/core/Azure.Core/api/Azure.Core.net6.0.cs
@@ -470,7 +470,9 @@ public HttpMessage(Azure.Core.Request request, Azure.Core.ResponseClassifier res
public void Dispose() { }
public System.IO.Stream? ExtractResponseContent() { throw null; }
public void SetProperty(string name, object value) { }
+ public void SetProperty(System.Type type, object value) { }
public bool TryGetProperty(string name, out object? value) { throw null; }
+ public bool TryGetProperty(System.Type type, out object? value) { throw null; }
}
public enum HttpPipelinePosition
{
diff --git a/sdk/core/Azure.Core/api/Azure.Core.netcoreapp2.1.cs b/sdk/core/Azure.Core/api/Azure.Core.netcoreapp2.1.cs
index 45c61dabd973a..9e89df433b517 100644
--- a/sdk/core/Azure.Core/api/Azure.Core.netcoreapp2.1.cs
+++ b/sdk/core/Azure.Core/api/Azure.Core.netcoreapp2.1.cs
@@ -470,7 +470,9 @@ public HttpMessage(Azure.Core.Request request, Azure.Core.ResponseClassifier res
public void Dispose() { }
public System.IO.Stream? ExtractResponseContent() { throw null; }
public void SetProperty(string name, object value) { }
+ public void SetProperty(System.Type type, object value) { }
public bool TryGetProperty(string name, out object? value) { throw null; }
+ public bool TryGetProperty(System.Type type, out object? value) { throw null; }
}
public enum HttpPipelinePosition
{
diff --git a/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs b/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs
index 45c61dabd973a..9e89df433b517 100644
--- a/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs
+++ b/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs
@@ -470,7 +470,9 @@ public HttpMessage(Azure.Core.Request request, Azure.Core.ResponseClassifier res
public void Dispose() { }
public System.IO.Stream? ExtractResponseContent() { throw null; }
public void SetProperty(string name, object value) { }
+ public void SetProperty(System.Type type, object value) { }
public bool TryGetProperty(string name, out object? value) { throw null; }
+ public bool TryGetProperty(System.Type type, out object? value) { throw null; }
}
public enum HttpPipelinePosition
{
diff --git a/sdk/core/Azure.Core/src/HttpMessage.cs b/sdk/core/Azure.Core/src/HttpMessage.cs
index d948f0f85bbee..738d37265e5e8 100644
--- a/sdk/core/Azure.Core/src/HttpMessage.cs
+++ b/sdk/core/Azure.Core/src/HttpMessage.cs
@@ -161,7 +161,7 @@ public void SetProperty(string name, object value)
/// The property type.
/// The property value.
/// true if property exists, otherwise. false.
- internal bool TryGetInternalProperty(Type type, out object? value)
+ public bool TryGetProperty(Type type, out object? value)
{
value = null;
return _typeProperties?.TryGetValue(type, out value) == true;
@@ -173,7 +173,7 @@ internal bool TryGetInternalProperty(Type type, out object? value)
///
/// The key for the value.
/// The property value.
- internal void SetInternalProperty(Type type, object value)
+ public void SetProperty(Type type, object value)
{
_typeProperties ??= new Dictionary();
_typeProperties[type] = value;
diff --git a/sdk/core/Azure.Core/src/Pipeline/Internal/TelemetryPolicy.cs b/sdk/core/Azure.Core/src/Pipeline/Internal/TelemetryPolicy.cs
index 2b36d02ce8e03..ff86f62ceb935 100644
--- a/sdk/core/Azure.Core/src/Pipeline/Internal/TelemetryPolicy.cs
+++ b/sdk/core/Azure.Core/src/Pipeline/Internal/TelemetryPolicy.cs
@@ -14,7 +14,7 @@ public TelemetryPolicy(TelemetryDetails telemetryDetails)
public override void OnSendingRequest(HttpMessage message)
{
- if (message.TryGetInternalProperty(typeof(UserAgentValueKey), out var userAgent))
+ if (message.TryGetProperty(typeof(UserAgentValueKey), out var userAgent))
{
message.Request.Headers.Add(HttpHeader.Names.UserAgent, ((string)userAgent!));
}
diff --git a/sdk/core/Azure.Core/src/TelemetryDetails.cs b/sdk/core/Azure.Core/src/TelemetryDetails.cs
index 74fbe5c7b0f17..8c019bee2aa47 100644
--- a/sdk/core/Azure.Core/src/TelemetryDetails.cs
+++ b/sdk/core/Azure.Core/src/TelemetryDetails.cs
@@ -53,7 +53,7 @@ public TelemetryDetails(Assembly assembly, string? applicationId = null)
/// The that will use this .
public void Apply(HttpMessage message)
{
- message.SetInternalProperty(typeof(UserAgentValueKey), ToString());
+ message.SetProperty(typeof(UserAgentValueKey), ToString());
}
internal static string GenerateUserAgentString(Assembly clientAssembly, string? applicationId = null)
diff --git a/sdk/core/Azure.Core/tests/TelemetryDetailsTests.cs b/sdk/core/Azure.Core/tests/TelemetryDetailsTests.cs
index d09d1f5b18dfb..9183c724bac46 100644
--- a/sdk/core/Azure.Core/tests/TelemetryDetailsTests.cs
+++ b/sdk/core/Azure.Core/tests/TelemetryDetailsTests.cs
@@ -57,7 +57,7 @@ public void AppliesToMessage()
target.Apply(message);
- message.TryGetInternalProperty(typeof(UserAgentValueKey), out var obj);
+ message.TryGetProperty(typeof(UserAgentValueKey), out var obj);
string actualValue = obj as string;
Assert.AreEqual(target.ToString(), actualValue);