Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
8d9dd93
initial draft
m-redding Jun 14, 2024
74c77c4
WIP test stubs pt 1
m-redding Jun 18, 2024
4192f6c
WIP test stubs 2
m-redding Jun 19, 2024
7f5c7cf
tweaks
m-redding Jun 20, 2024
edccce7
changes
m-redding Jun 24, 2024
b08f2c5
p1 of adding Event Source
m-redding Jun 26, 2024
291365d
tests p1
m-redding Jun 26, 2024
107abf0
test updates
m-redding Jun 27, 2024
207b215
Tests2
m-redding Jun 28, 2024
3747094
updates
m-redding Jul 17, 2024
c986aed
API
m-redding Jul 17, 2024
d802bc3
try slimming methods and adding retry policy log
m-redding Jul 18, 2024
fc17694
test
m-redding Jul 22, 2024
7253073
conflicts
m-redding Aug 13, 2024
205ef71
refactory + add abstraction
m-redding Aug 13, 2024
1c2f4dc
add tests and update api
m-redding Aug 13, 2024
cb53622
more tests
m-redding Aug 13, 2024
8f98aec
fix functional tests
m-redding Aug 15, 2024
06126f2
static -> instance
m-redding Aug 15, 2024
6f51ac6
updates
m-redding Aug 19, 2024
69ced27
tweaks
m-redding Aug 19, 2024
e445a1b
tweaks
m-redding Aug 19, 2024
dec45fd
fix
m-redding Aug 19, 2024
524edc9
Merge branch 'Azure:main' into loggingpolicy2
m-redding Sep 4, 2024
469aeb7
little refactorings
m-redding Sep 9, 2024
ecf0a26
tweaks
m-redding Sep 11, 2024
373fb99
tweaks
m-redding Sep 11, 2024
441ee3e
WIP feedback
m-redding Sep 13, 2024
49a3bcd
reformat
m-redding Sep 17, 2024
da1b7f8
WIP more feedback
m-redding Sep 17, 2024
86dc327
WIP
m-redding Sep 17, 2024
672390a
Merge branch 'Azure:main' into loggingpolicy2
m-redding Sep 18, 2024
ef183ef
Merge branch 'loggingpolicy2' of https://github.com/m-redding/azure-s…
m-redding Sep 18, 2024
9f93eea
Merge branch 'Azure:main' into loggingpolicy2
m-redding Oct 8, 2024
281aa37
Merge branch 'loggingpolicy2' of https://github.com/m-redding/azure-s…
m-redding Oct 8, 2024
b5d97f0
Merge branch 'Azure:main' into loggingpolicy2
m-redding Oct 22, 2024
4a97e78
WIP - updates
m-redding Oct 23, 2024
2726470
Export API
m-redding Oct 23, 2024
e93cbd9
API
m-redding Oct 23, 2024
9e5f1d3
API tweaks
m-redding Oct 23, 2024
87bafa7
comment
m-redding Oct 23, 2024
009792c
Merge branch 'Azure:main' into loggingpolicy2
m-redding Nov 4, 2024
1fb84da
changes 1
m-redding Nov 5, 2024
d5a9360
changes 2
m-redding Nov 7, 2024
985844f
changes
m-redding Nov 7, 2024
3afbc2e
fixes
m-redding Nov 7, 2024
b5ba8ac
more updates
m-redding Nov 7, 2024
8227713
ideas
annelo-msft Nov 8, 2024
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
1 change: 1 addition & 0 deletions eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<PackageReference Update="System.ValueTuple" Version="4.5.0" />
<PackageReference Update="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
<PackageReference Update="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Update="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0"/>

<!-- Azure SDK packages -->
<PackageReference Update="Azure.Communication.Identity" Version="1.3.1" />
Expand Down
15 changes: 15 additions & 0 deletions sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ public void Send(System.ClientModel.Primitives.PipelineMessage message) { }
public partial class ClientPipelineOptions
{
public ClientPipelineOptions() { }
public System.Collections.Generic.IList<string> AllowedHeaderNames { get { throw null; } }
public System.Collections.Generic.IList<string> AllowedQueryParameters { get { throw null; } }
public bool? EnableLogging { get { throw null; } set { } }
public bool? EnableMessageContentLogging { get { throw null; } set { } }
public bool? EnableMessageLogging { get { throw null; } set { } }
public Microsoft.Extensions.Logging.ILoggerFactory? LoggerFactory { get { throw null; } set { } }
public int? MessageContentSizeLimit { get { throw null; } set { } }
public System.ClientModel.Primitives.PipelinePolicy? MessageLoggingPolicy { get { throw null; } set { } }
public System.TimeSpan? NetworkTimeout { get { throw null; } set { } }
public System.ClientModel.Primitives.PipelinePolicy? RetryPolicy { get { throw null; } set { } }
public System.ClientModel.Primitives.PipelineTransport? Transport { get { throw null; } set { } }
Expand Down Expand Up @@ -158,6 +166,13 @@ public JsonModelConverter(System.ClientModel.Primitives.ModelReaderWriterOptions
public override System.ClientModel.Primitives.IJsonModel<object> Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { throw null; }
public override void Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.IJsonModel<object> value, System.Text.Json.JsonSerializerOptions options) { }
}
public partial class MessageLoggingPolicy : System.ClientModel.Primitives.PipelinePolicy
{
public MessageLoggingPolicy(System.ClientModel.Primitives.ClientPipelineOptions? options = null) { }
public static System.ClientModel.Primitives.MessageLoggingPolicy Default { get { throw null; } }
public override void Process(System.ClientModel.Primitives.PipelineMessage message, System.Collections.Generic.IReadOnlyList<System.ClientModel.Primitives.PipelinePolicy> pipeline, int currentIndex) { }
public override System.Threading.Tasks.ValueTask ProcessAsync(System.ClientModel.Primitives.PipelineMessage message, System.Collections.Generic.IReadOnlyList<System.ClientModel.Primitives.PipelinePolicy> pipeline, int currentIndex) { throw null; }
}
public static partial class ModelReaderWriter
{
public static object? Read(System.BinaryData data, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)] System.Type returnType, System.ClientModel.Primitives.ModelReaderWriterOptions? options = null) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ public void Send(System.ClientModel.Primitives.PipelineMessage message) { }
public partial class ClientPipelineOptions
{
public ClientPipelineOptions() { }
public System.Collections.Generic.IList<string> AllowedHeaderNames { get { throw null; } }
public System.Collections.Generic.IList<string> AllowedQueryParameters { get { throw null; } }
public bool? EnableLogging { get { throw null; } set { } }
public bool? EnableMessageContentLogging { get { throw null; } set { } }
public bool? EnableMessageLogging { get { throw null; } set { } }
public Microsoft.Extensions.Logging.ILoggerFactory? LoggerFactory { get { throw null; } set { } }
public int? MessageContentSizeLimit { get { throw null; } set { } }
public System.ClientModel.Primitives.PipelinePolicy? MessageLoggingPolicy { get { throw null; } set { } }
public System.TimeSpan? NetworkTimeout { get { throw null; } set { } }
public System.ClientModel.Primitives.PipelinePolicy? RetryPolicy { get { throw null; } set { } }
public System.ClientModel.Primitives.PipelineTransport? Transport { get { throw null; } set { } }
Expand Down Expand Up @@ -157,6 +165,13 @@ public JsonModelConverter(System.ClientModel.Primitives.ModelReaderWriterOptions
public override System.ClientModel.Primitives.IJsonModel<object> Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { throw null; }
public override void Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.IJsonModel<object> value, System.Text.Json.JsonSerializerOptions options) { }
}
public partial class MessageLoggingPolicy : System.ClientModel.Primitives.PipelinePolicy
{
public MessageLoggingPolicy(System.ClientModel.Primitives.ClientPipelineOptions? options = null) { }
public static System.ClientModel.Primitives.MessageLoggingPolicy Default { get { throw null; } }
public override void Process(System.ClientModel.Primitives.PipelineMessage message, System.Collections.Generic.IReadOnlyList<System.ClientModel.Primitives.PipelinePolicy> pipeline, int currentIndex) { }
public override System.Threading.Tasks.ValueTask ProcessAsync(System.ClientModel.Primitives.PipelineMessage message, System.Collections.Generic.IReadOnlyList<System.ClientModel.Primitives.PipelinePolicy> pipeline, int currentIndex) { throw null; }
}
public static partial class ModelReaderWriter
{
public static object? Read(System.BinaryData data, System.Type returnType, System.ClientModel.Primitives.ModelReaderWriterOptions? options = null) { throw null; }
Expand Down
108 changes: 108 additions & 0 deletions sdk/core/System.ClientModel/src/Internal/ChangeTrackingStringList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace System.ClientModel.Internal;

internal class ChangeTrackingStringList : IList<string>
{
private IList<string> _list;

private bool _tracking;

public ChangeTrackingStringList()
{
_list = new List<string>();

_tracking = false;
}

public ChangeTrackingStringList(IEnumerable<string> collection)
{
_list = new List<string>(collection);

_tracking = false;
}

public bool HasChanged { get; private set; }

public void StartTracking() => _tracking = true;

public void StopTracking() => _tracking = false;

public void Freeze()
{
_list = new ReadOnlyCollection<string>(_list);
}

#region IList implementation

public string this[int index]
{
get => _list[index];
set
{
_list[index] = value;

HasChanged |= _tracking;
}
}

public int Count => _list.Count;

public bool IsReadOnly => _list.IsReadOnly;

public void Add(string item)
{
_list.Add(item);

HasChanged |= _tracking;
}

public void Clear()
{
int count = _list.Count;

_list.Clear();

HasChanged |= _tracking && (count != 0);
}

public bool Contains(string item) => _list.Contains(item);

public void CopyTo(string[] array, int arrayIndex) => _list.CopyTo(array, arrayIndex);

public IEnumerator<string> GetEnumerator() => _list.GetEnumerator();

public int IndexOf(string item) => _list.IndexOf(item);

public void Insert(int index, string item)
{
_list.Insert(index, item);

HasChanged |= _tracking;
}

public bool Remove(string item)
{
bool removed = _list.Remove(item);

HasChanged |= _tracking && removed;

return removed;
}

public void RemoveAt(int index)
{
_list.RemoveAt(index);

HasChanged |= _tracking;
}

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

#endregion
}
54 changes: 54 additions & 0 deletions sdk/core/System.ClientModel/src/Internal/ContentTypeUtilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Text;

namespace System.ClientModel.Internal;

internal class ContentTypeUtilities
{
public static bool TryGetTextEncoding(string contentType, out Encoding? encoding)
{
const string charsetMarker = "; charset=";
const string utf8Charset = "utf-8";
const string textContentTypePrefix = "text/";
const string jsonSuffix = "json";
const string appJsonPrefix = "application/json";
const string xmlSuffix = "xml";
const string urlEncodedSuffix = "-urlencoded";

// Default is technically US-ASCII, but will default to UTF-8 which is a superset.
const string appFormUrlEncoded = "application/x-www-form-urlencoded";

if (contentType == null)
{
encoding = null;
return false;
}

var charsetIndex = contentType.IndexOf(charsetMarker, StringComparison.OrdinalIgnoreCase);
if (charsetIndex != -1)
{
ReadOnlySpan<char> charset = contentType.AsSpan().Slice(charsetIndex + charsetMarker.Length);
if (charset.StartsWith(utf8Charset.AsSpan(), StringComparison.OrdinalIgnoreCase))
{
encoding = Encoding.UTF8;
return true;
}
}

if (contentType.StartsWith(textContentTypePrefix, StringComparison.OrdinalIgnoreCase) ||
contentType.EndsWith(jsonSuffix, StringComparison.OrdinalIgnoreCase) ||
contentType.EndsWith(xmlSuffix, StringComparison.OrdinalIgnoreCase) ||
contentType.EndsWith(urlEncodedSuffix, StringComparison.OrdinalIgnoreCase) ||
contentType.StartsWith(appJsonPrefix, StringComparison.OrdinalIgnoreCase) ||
contentType.StartsWith(appFormUrlEncoded, StringComparison.OrdinalIgnoreCase))
{
encoding = Encoding.UTF8;
return true;
}

encoding = null;
return false;
}
}
Loading