diff --git a/src/Microsoft.OData.Client/Microsoft.OData.Client.csproj b/src/Microsoft.OData.Client/Microsoft.OData.Client.csproj index bb410b077e..fa607c9b26 100644 --- a/src/Microsoft.OData.Client/Microsoft.OData.Client.csproj +++ b/src/Microsoft.OData.Client/Microsoft.OData.Client.csproj @@ -1,6 +1,6 @@  - net8.0 + net8.0 Microsoft.OData.Client Microsoft.OData.Client $(AssemblyName).xml diff --git a/src/Microsoft.OData.Core/Json/BufferingJsonReader.cs b/src/Microsoft.OData.Core/Json/BufferingJsonReader.cs index 4a977af36b..5b8074f594 100644 --- a/src/Microsoft.OData.Core/Json/BufferingJsonReader.cs +++ b/src/Microsoft.OData.Core/Json/BufferingJsonReader.cs @@ -248,7 +248,7 @@ public bool Read() /// A task that represents the asynchronous read operation. /// The value of the TResult parameter contains the node value of the last buffered read if buffering is on or off; /// otherwise the node value of the last unbuffered read. - public Task GetValueAsync() + public ValueTask GetValueAsync() { this.AssertAsynchronous(); @@ -257,11 +257,11 @@ public Task GetValueAsync() if (this.isBuffering) { Debug.Assert(this.currentBufferedNode != null, "this.currentBufferedNode != null"); - return Task.FromResult(this.currentBufferedNode.Value); + return ValueTask.FromResult(this.currentBufferedNode.Value); } // In non-buffering mode if we have buffered nodes satisfy the request from the first node there - return Task.FromResult(this.bufferedNodesHead.Value); + return ValueTask.FromResult(this.bufferedNodesHead.Value); } return this.innerReader.GetValueAsync(); @@ -272,7 +272,7 @@ public Task GetValueAsync() /// /// A task that represents the asynchronous read operation. /// The value of the TResult parameter contains true if a new node was found, or false if end of input was reached. - public Task ReadAsync() + public ValueTask ReadAsync() { Debug.Assert(!this.parsingInStreamError, "!this.parsingInStreamError"); this.AssertAsynchronous(); @@ -286,7 +286,7 @@ public Task ReadAsync() /// /// A task that represents the asynchronous operation. /// true if the current value can be streamed; otherwise false. - public virtual async Task CanStreamAsync() + public virtual async ValueTask CanStreamAsync() { this.AssertAsynchronous(); @@ -307,7 +307,7 @@ public virtual async Task CanStreamAsync() /// A task that represents the asynchronous read operation. /// The value of the TResult parameter contains a used to read a stream value. [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1825:Avoid zero-length array allocations.", Justification = "")] - public virtual async Task CreateReadStreamAsync() + public virtual async ValueTask CreateReadStreamAsync() { this.AssertAsynchronous(); @@ -342,7 +342,7 @@ await this.innerReader.ReadAsync() /// /// A task that represents the asynchronous read operation. /// The value of the TResult parameter contains a for reading the text value. - public virtual async Task CreateTextReaderAsync() + public virtual async ValueTask CreateTextReaderAsync() { this.AssertAsynchronous(); @@ -682,7 +682,7 @@ protected virtual void ProcessObjectValue() /// represents an in-stream error. If so, it throws an . If false, this check will not happen. /// This parsingInStremError field is set to true when trying to parse an in-stream error; in normal operation it is false. /// - protected async Task ReadInternalAsync() + protected async ValueTask ReadInternalAsync() { this.AssertAsynchronous(); diff --git a/src/Microsoft.OData.Core/Json/IJsonReader.cs b/src/Microsoft.OData.Core/Json/IJsonReader.cs index cee3136a1f..4553f0cf17 100644 --- a/src/Microsoft.OData.Core/Json/IJsonReader.cs +++ b/src/Microsoft.OData.Core/Json/IJsonReader.cs @@ -68,7 +68,7 @@ public interface IJsonReader /// /// A task that represents the asynchronous operation. /// The value of the TResult parameter contains true if a new node was found, or false if end of input was reached. - Task ReadAsync(); + ValueTask ReadAsync(); /// /// Asynchronously returns the value of the last reported node. @@ -85,27 +85,27 @@ public interface IJsonReader /// - Double if a number which doesn't fit into Int32 was found. /// If the last node is a Property this property returns a string which is the name of the property. /// - Task GetValueAsync(); + ValueTask GetValueAsync(); /// /// Asynchronously creates a Stream for reading a binary value. /// /// A task that represents the asynchronous operation. /// The value of the TResult parameter contains a for reading the binary value. - Task CreateReadStreamAsync(); + ValueTask CreateReadStreamAsync(); /// /// Asynchronously creates a TextReader for reading a string value. /// /// A task that represents the asynchronous operation. /// The value of the TResult parameter contains a for reading the string value. - Task CreateTextReaderAsync(); + ValueTask CreateTextReaderAsync(); /// /// Asynchronously checks whether or not the current value can be streamed. /// /// A task that represents the asynchronous operation. /// true if the current value can be streamed; otherwise false. - Task CanStreamAsync(); + ValueTask CanStreamAsync(); } } diff --git a/src/Microsoft.OData.Core/Json/IJsonWriter.cs b/src/Microsoft.OData.Core/Json/IJsonWriter.cs index fd4b3f0d92..5eb2c4636b 100644 --- a/src/Microsoft.OData.Core/Json/IJsonWriter.cs +++ b/src/Microsoft.OData.Core/Json/IJsonWriter.cs @@ -213,45 +213,45 @@ public interface IJsonWriter /// /// A task that represents the asynchronous operation. [Obsolete("This will be dropped in the 9.x release.")] - Task StartPaddingFunctionScopeAsync(); + ValueTask StartPaddingFunctionScopeAsync(); /// /// Asynchronously ends the padding function scope. /// /// A task that represents the asynchronous operation. [Obsolete("This will be dropped in the 9.x release.")] - Task EndPaddingFunctionScopeAsync(); + ValueTask EndPaddingFunctionScopeAsync(); /// /// Asynchronously starts the object scope. /// /// A task that represents the asynchronous operation. - Task StartObjectScopeAsync(); + ValueTask StartObjectScopeAsync(); /// /// Asynchronously ends the current object scope. /// /// A task that represents the asynchronous operation. - Task EndObjectScopeAsync(); + ValueTask EndObjectScopeAsync(); /// /// Asynchronously starts the array scope. /// /// A task that represents the asynchronous operation. - Task StartArrayScopeAsync(); + ValueTask StartArrayScopeAsync(); /// /// Asynchronously ends the current array scope. /// /// A task that represents the asynchronous operation. - Task EndArrayScopeAsync(); + ValueTask EndArrayScopeAsync(); /// /// Asynchronously writes the name for the object property. /// /// Name of the object property. /// A task that represents the asynchronous write operation. - Task WriteNameAsync(string name); + ValueTask WriteNameAsync(string name); /// /// Asynchronously writes a function name for JSON padding. @@ -259,119 +259,119 @@ public interface IJsonWriter /// Name of the padding function to write. /// A task that represents the asynchronous write operation. [Obsolete("This will be dropped in the 9.x release.")] - Task WritePaddingFunctionNameAsync(string functionName); + ValueTask WritePaddingFunctionNameAsync(string functionName); /// /// Asynchronously writes a boolean value. /// /// Boolean value to be written. /// A task that represents the asynchronous write operation. - Task WriteValueAsync(bool value); + ValueTask WriteValueAsync(bool value); /// /// Asynchronously writes an integer value. /// /// Integer value to be written. /// A task that represents the asynchronous write operation. - Task WriteValueAsync(int value); + ValueTask WriteValueAsync(int value); /// /// Asynchronously writes a float value. /// /// Float value to be written. /// A task that represents the asynchronous write operation. - Task WriteValueAsync(float value); + ValueTask WriteValueAsync(float value); /// /// Asynchronously writes a short value. /// /// Short value to be written. /// A task that represents the asynchronous write operation. - Task WriteValueAsync(short value); + ValueTask WriteValueAsync(short value); /// /// Asynchronously writes a long value. /// /// Long value to be written. /// A task that represents the asynchronous write operation. - Task WriteValueAsync(long value); + ValueTask WriteValueAsync(long value); /// /// Asynchronously writes a double value. /// /// Double value to be written. /// A task that represents the asynchronous write operation. - Task WriteValueAsync(double value); + ValueTask WriteValueAsync(double value); /// /// Asynchronously writes a Guid value. /// /// Guid value to be written. /// A task that represents the asynchronous write operation. - Task WriteValueAsync(Guid value); + ValueTask WriteValueAsync(Guid value); /// /// Asynchronously writes a decimal value /// /// Decimal value to be written. /// A task that represents the asynchronous write operation. - Task WriteValueAsync(decimal value); + ValueTask WriteValueAsync(decimal value); /// /// Asynchronously writes a DateTimeOffset value /// /// DateTimeOffset value to be written. /// A task that represents the asynchronous write operation. - Task WriteValueAsync(DateTimeOffset value); + ValueTask WriteValueAsync(DateTimeOffset value); /// /// Asynchronously writes a TimeSpan value /// /// TimeSpan value to be written. /// A task that represents the asynchronous write operation. - Task WriteValueAsync(TimeSpan value); + ValueTask WriteValueAsync(TimeSpan value); /// /// Asynchronously writes a byte value. /// /// Byte value to be written. /// A task that represents the asynchronous write operation. - Task WriteValueAsync(byte value); + ValueTask WriteValueAsync(byte value); /// /// Asynchronously writes an sbyte value. /// /// SByte value to be written. /// A task that represents the asynchronous write operation. - Task WriteValueAsync(sbyte value); + ValueTask WriteValueAsync(sbyte value); /// /// Asynchronously writes a string value. /// /// String value to be written. /// A task that represents the asynchronous write operation. - Task WriteValueAsync(string value); + ValueTask WriteValueAsync(string value); /// /// Asynchronously writes a byte array. /// /// Byte array to be written. /// A task that represents the asynchronous write operation. - Task WriteValueAsync(byte[] value); + ValueTask WriteValueAsync(byte[] value); /// /// Asynchronously writes a Date value /// /// Date value to be written. /// A task that represents the asynchronous write operation. - Task WriteValueAsync(Date value); + ValueTask WriteValueAsync(Date value); /// /// Asynchronously writes a TimeOfDay value /// /// TimeOfDay value to be written. /// A task that represents the asynchronous write operation. - Task WriteValueAsync(TimeOfDay value); + ValueTask WriteValueAsync(TimeOfDay value); #if NETCOREAPP @@ -380,7 +380,7 @@ public interface IJsonWriter /// /// The value to be written. /// A task that represents the asynchronous write operation. - Task WriteValueAsync(JsonElement value); + ValueTask WriteValueAsync(JsonElement value); #endif /// @@ -388,7 +388,7 @@ public interface IJsonWriter /// /// Raw value to be written. /// A task that represents the asynchronous write operation. - Task WriteRawValueAsync(string rawValue); + ValueTask WriteRawValueAsync(string rawValue); /// /// Asynchronously clears all buffers for the current writer. @@ -401,7 +401,7 @@ public interface IJsonWriter /// /// A task that represents the asynchronous operation. /// The value of the TResult parameter contains the stream to write the property value to. - Task StartStreamValueScopeAsync(); + ValueTask StartStreamValueScopeAsync(); /// /// Asynchronously starts the TextWriter value scope. @@ -409,18 +409,18 @@ public interface IJsonWriter /// ContentType of the string being written. /// A task that represents the asynchronous operation. /// The value of the TResult parameter contains the textwriter to write the text property value to. - Task StartTextWriterValueScopeAsync(string contentType); + ValueTask StartTextWriterValueScopeAsync(string contentType); /// /// Asynchronously ends the current stream property value scope. /// /// A task that represents the asynchronous operation. - Task EndStreamValueScopeAsync(); + ValueTask EndStreamValueScopeAsync(); /// /// Asynchronously ends the TextWriter value scope. /// /// A task that represents the asynchronous operation. - Task EndTextWriterValueScopeAsync(); + ValueTask EndTextWriterValueScopeAsync(); } } diff --git a/src/Microsoft.OData.Core/Json/JsonLightInstanceAnnotationWriter.cs b/src/Microsoft.OData.Core/Json/JsonLightInstanceAnnotationWriter.cs index 052f0cea5e..f1a86f6103 100644 --- a/src/Microsoft.OData.Core/Json/JsonLightInstanceAnnotationWriter.cs +++ b/src/Microsoft.OData.Core/Json/JsonLightInstanceAnnotationWriter.cs @@ -254,7 +254,7 @@ internal void WriteInstanceAnnotation( /// Whether to ignore the filter in settings. /// The name of the property this instance annotation applies to /// A task that represents the asynchronous write operation. - internal Task WriteInstanceAnnotationsAsync( + internal ValueTask WriteInstanceAnnotationsAsync( ICollection instanceAnnotations, InstanceAnnotationWriteTracker tracker, bool ignoreFilter = false, @@ -267,7 +267,7 @@ internal Task WriteInstanceAnnotationsAsync( if (instanceAnnotations.Count == 0) { - return TaskUtils.CompletedTask; + return ValueTask.CompletedTask; } HashSet instanceAnnotationNames = new HashSet(StringComparer.Ordinal); @@ -279,7 +279,7 @@ internal Task WriteInstanceAnnotationsAsync( { return WriteInstanceAnnotationsListAsync(instanceAnnotationsList, tracker, instanceAnnotationNames, ignoreFilter, propertyName); - async Task WriteInstanceAnnotationsListAsync( + async ValueTask WriteInstanceAnnotationsListAsync( List innerInstanceAnnotationsList, InstanceAnnotationWriteTracker innerInstanceAnnotationWriteTracker, HashSet innerInstanceAnnotationNames, @@ -301,7 +301,7 @@ await this.WriteAndTrackInstanceAnnotationAsync( { return WriteInstanceAnnotationsInnerAsync(instanceAnnotations, tracker, instanceAnnotationNames, ignoreFilter, propertyName); - async Task WriteInstanceAnnotationsInnerAsync( + async ValueTask WriteInstanceAnnotationsInnerAsync( ICollection innerInstanceAnnotations, InstanceAnnotationWriteTracker innerInstanceAnnotationWriteTracker, HashSet innerInstanceAnnotationNames, @@ -328,7 +328,7 @@ await this.WriteAndTrackInstanceAnnotationAsync( /// Collection of instance annotations to write. /// The name of the property this instance annotation applies to /// If writing an undeclared property. - internal Task WriteInstanceAnnotationsAsync( + internal ValueTask WriteInstanceAnnotationsAsync( ICollection instanceAnnotations, string propertyName = null, bool isUndeclaredProperty = false) @@ -349,7 +349,7 @@ internal Task WriteInstanceAnnotationsAsync( /// Asynchronously writes all the instance annotations specified in of error. /// /// Collection of instance annotations to write. - internal Task WriteInstanceAnnotationsForErrorAsync(ICollection instanceAnnotations) + internal ValueTask WriteInstanceAnnotationsForErrorAsync(ICollection instanceAnnotations) { Debug.Assert(instanceAnnotations != null, "instanceAnnotations should not be null if we called this"); return this.WriteInstanceAnnotationsAsync(instanceAnnotations, new InstanceAnnotationWriteTracker(), true); @@ -570,7 +570,7 @@ await this.WriteInstanceAnnotationAsync(annotation, ignoreFilter, propertyName) /// The collection of instance annotations /// The name of the property the instance annotations apply to /// A task that represents the asynchronous write operation. - private async Task WriteInstanceAnnotationsForUndeclaredPropertyAsync(ICollection instanceAnnotations, string propertyName) + private async ValueTask WriteInstanceAnnotationsForUndeclaredPropertyAsync(ICollection instanceAnnotations, string propertyName) { // write undeclared property's all annotations // optimize the foreach when instanceAnnotations is a List to avoid enumerator allocations on the heap @@ -614,7 +614,7 @@ private void WriteInstanceAnnotationName(string propertyName, string annotationN /// /// The name of the property this instance annotation applied to. /// The name of the instance annotation. - private Task WriteInstanceAnnotationNameAsync(string propertyName, string annotationName) + private ValueTask WriteInstanceAnnotationNameAsync(string propertyName, string annotationName) { if (propertyName != null) { diff --git a/src/Microsoft.OData.Core/Json/JsonReader.cs b/src/Microsoft.OData.Core/Json/JsonReader.cs index fc64b6bf23..a3c9343d03 100644 --- a/src/Microsoft.OData.Core/Json/JsonReader.cs +++ b/src/Microsoft.OData.Core/Json/JsonReader.cs @@ -521,7 +521,7 @@ public TextReader CreateTextReader() /// - Double if a number which doesn't fit into Int32 was found. /// If the last node is a Property this property returns a string which is the name of the property. /// - public virtual async Task GetValueAsync() + public virtual async ValueTask GetValueAsync() { if (this.readingStream) { @@ -559,15 +559,15 @@ public virtual async Task GetValueAsync() /// /// A task that represents the asynchronous operation. /// true if the current value can be streamed; otherwise false. - public Task CanStreamAsync() + public ValueTask CanStreamAsync() { if (this.canStream) { - return Task.FromResult(true); + return ValueTask.FromResult(true); } else { - return Task.FromResult(false); + return ValueTask.FromResult(false); } } @@ -578,7 +578,7 @@ public Task CanStreamAsync() /// The value of the TResult parameter contains true if a new node was found, /// or false if end of input was reached. [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "Not really feasible to extract code to methods without introducing unnecessary complexity.")] - public virtual async Task ReadAsync() + public virtual async ValueTask ReadAsync() { if (this.readingStream) { @@ -755,7 +755,7 @@ public virtual async Task ReadAsync() /// /// A task that represents the asynchronous operation. /// The value of the TResult parameter contains a for reading a base64 URL encoded binary value. - public async Task CreateReadStreamAsync() + public async ValueTask CreateReadStreamAsync() { if (!this.canStream) { @@ -770,7 +770,7 @@ await this.ParseNullPrimitiveValueAsync() this.scopes.Peek().ValueCount++; await this.ReadAsync() .ConfigureAwait(false); - return new ODataBinaryStreamReader((a, b, c) => { return Task.FromResult(0); }); + return new ODataBinaryStreamReader((a, b, c) => { return ValueTask.FromResult(0); }); } this.tokenStartIndex++; @@ -783,7 +783,7 @@ await this.ReadAsync() /// /// A task that represents the asynchronous operation. /// The value of the TResult parameter contains a for reading a text value. - public async Task CreateTextReaderAsync() + public async ValueTask CreateTextReaderAsync() { if (!this.canStream) { @@ -802,7 +802,7 @@ await this.ParseNullPrimitiveValueAsync() this.scopes.Peek().ValueCount++; await this.ReadAsync() .ConfigureAwait(false); - return new ODataTextStreamReader((a, b, c) => { return Task.FromResult(0); }); + return new ODataTextStreamReader((a, b, c) => { return ValueTask.FromResult(0); }); } // skip over the opening quote character for a string value @@ -1597,7 +1597,7 @@ private bool ReadInput() /// /// A task that represents the asynchronous operation. /// The value of the TResult parameter contains the node type to report to the user. - private async Task ParseValueAsync() + private async ValueTask ParseValueAsync() { Debug.Assert( this.tokenStartIndex < this.storedCharacterCount && !IsWhitespaceCharacter(this.characterBuffer[this.tokenStartIndex]), @@ -1866,7 +1866,7 @@ private async Task> ParseStringPrimitiveValueAsync() /// A task that represents the asynchronous operation. /// The value of the TResult parameter contains null if successful; otherwise throws. /// Assumes that the current token position points to the 'n' character. - private async Task ParseNullPrimitiveValueAsync() + private async ValueTask ParseNullPrimitiveValueAsync() { Debug.Assert( this.tokenStartIndex < this.storedCharacterCount && this.characterBuffer[this.tokenStartIndex] == 'n', @@ -1889,7 +1889,7 @@ private async Task ParseNullPrimitiveValueAsync() /// A task that represents the asynchronous operation. /// The value of the TResult parameter contains true or false if successful; otherwise throws. /// Assumes that the current token position points to the 't' or 'f' character. - private async Task ParseBooleanPrimitiveValueAsync() + private async ValueTask ParseBooleanPrimitiveValueAsync() { Debug.Assert( this.tokenStartIndex < this.storedCharacterCount && (this.characterBuffer[this.tokenStartIndex] == 't' || this.characterBuffer[this.tokenStartIndex] == 'f'), @@ -1917,7 +1917,7 @@ private async Task ParseBooleanPrimitiveValueAsync() /// A task that represents the asynchronous operation. /// The value of the TResult parameter contains an Int32, Decimal or Double value; otherwise throws. /// Assumes that the current token position points to the first character of the number, so either digit, dot or dash. - private async Task ParseNumberPrimitiveValueAsync() + private async ValueTask ParseNumberPrimitiveValueAsync() { Debug.Assert( this.tokenStartIndex < this.storedCharacterCount && (this.characterBuffer[this.tokenStartIndex] == '.' || this.characterBuffer[this.tokenStartIndex] == '-' || Char.IsDigit(this.characterBuffer[this.tokenStartIndex])), @@ -1981,7 +1981,7 @@ private async Task ParseNumberPrimitiveValueAsync() /// - string value quoted with double quotes. /// - string value quoted with single quotes. /// - sequence of letters, digits, underscores and dollar signs (without quoted and in any order). - private async Task ParseNameAsync() + private async ValueTask ParseNameAsync() { Debug.Assert(this.tokenStartIndex < this.storedCharacterCount, "Must have at least one character available."); @@ -2028,7 +2028,7 @@ private async Task ParseNameAsync() /// Note that the string parsing can never end with EndOfInput, since we're already seen the quote. /// So it can either return a string successfully or fail. [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "Splitting the function would make it hard to understand.")] - private async Task ReadCharsAsync(char[] chars, int offset, int maxLength) + private async ValueTask ReadCharsAsync(char[] chars, int offset, int maxLength) { if (!readingStream) { @@ -2148,11 +2148,7 @@ private async Task ReadCharsAsync(char[] chars, int offset, int maxLength) /// The value of the TResult parameter contains true if a non-whitespace character was found, /// in which case the is pointing at that character; /// otherwise false if there are no non-whitespace characters left in the input. -#if NETSTANDARD2_0 || NETCOREAPP3_1_OR_GREATER private async ValueTask SkipWhitespacesAsync() -#else - private async Task SkipWhitespacesAsync() -#endif { do { @@ -2176,11 +2172,7 @@ private async Task SkipWhitespacesAsync() /// A task that represents the asynchronous operation. /// The value of the TResult parameter contains true if at least the required number of characters is available; /// otherwise false if end of input was reached. -#if NETSTANDARD2_0 || NETCOREAPP3_1_OR_GREATER private async ValueTask EnsureAvailableCharactersAsync(int characterCountAfterTokenStart) -#else - private async Task EnsureAvailableCharactersAsync(int characterCountAfterTokenStart) -#endif { while (this.tokenStartIndex + characterCountAfterTokenStart > this.storedCharacterCount) { @@ -2201,11 +2193,7 @@ private async Task EnsureAvailableCharactersAsync(int characterCountAfterT /// otherwise false if end of input was reached. /// This may move characters in the , so after this is called /// all indices to the are invalid except for . -#if NETSTANDARD2_0 || NETCOREAPP3_1_OR_GREATER private async ValueTask ReadInputAsync() -#else - private async Task ReadInputAsync() -#endif { Debug.Assert(this.tokenStartIndex >= 0 && this.tokenStartIndex <= this.storedCharacterCount, "The token start is out of stored characters range."); diff --git a/src/Microsoft.OData.Core/Json/JsonWriter.Async.cs b/src/Microsoft.OData.Core/Json/JsonWriter.Async.cs index ea4fba3875..8987c79865 100644 --- a/src/Microsoft.OData.Core/Json/JsonWriter.Async.cs +++ b/src/Microsoft.OData.Core/Json/JsonWriter.Async.cs @@ -22,14 +22,14 @@ namespace Microsoft.OData.Json internal sealed partial class JsonWriter { /// - public Task StartPaddingFunctionScopeAsync() + public ValueTask StartPaddingFunctionScopeAsync() { Debug.Assert(this.scopes.Count == 0, "Padding scope can only be the outer most scope."); return this.StartScopeAsync(ScopeType.Padding); } /// - public async Task EndPaddingFunctionScopeAsync() + public async ValueTask EndPaddingFunctionScopeAsync() { Debug.Assert(this.scopes.Count > 0, "No scope to end."); @@ -43,13 +43,13 @@ public async Task EndPaddingFunctionScopeAsync() } /// - public Task StartObjectScopeAsync() + public ValueTask StartObjectScopeAsync() { return this.StartScopeAsync(ScopeType.Object); } /// - public async Task EndObjectScopeAsync() + public async ValueTask EndObjectScopeAsync() { Debug.Assert(this.scopes.Count > 0, "No scope to end."); @@ -63,13 +63,13 @@ public async Task EndObjectScopeAsync() } /// - public Task StartArrayScopeAsync() + public ValueTask StartArrayScopeAsync() { return this.StartScopeAsync(ScopeType.Array); } /// - public async Task EndArrayScopeAsync() + public async ValueTask EndArrayScopeAsync() { Debug.Assert(this.scopes.Count > 0, "No scope to end."); @@ -83,7 +83,7 @@ public async Task EndArrayScopeAsync() } /// - public async Task WriteNameAsync(string name) + public async ValueTask WriteNameAsync(string name) { Debug.Assert(!string.IsNullOrEmpty(name), "The name must be specified."); Debug.Assert(this.scopes.Count > 0, "There must be an active scope for name to be written."); @@ -103,41 +103,41 @@ await this.writer.WriteEscapedJsonStringAsync(name, this.stringEscapeOption, thi } /// - public Task WritePaddingFunctionNameAsync(string functionName) + public async ValueTask WritePaddingFunctionNameAsync(string functionName) { - return this.writer.WriteAsync(functionName); + await this.writer.WriteAsync(functionName); } /// - public async Task WriteValueAsync(bool value) + public async ValueTask WriteValueAsync(bool value) { await this.WriteValueSeparatorAsync().ConfigureAwait(false); await this.writer.WriteValueAsync(value).ConfigureAwait(false); } /// - public async Task WriteValueAsync(int value) + public async ValueTask WriteValueAsync(int value) { await this.WriteValueSeparatorAsync().ConfigureAwait(false); await this.writer.WriteValueAsync(value).ConfigureAwait(false); } /// - public async Task WriteValueAsync(float value) + public async ValueTask WriteValueAsync(float value) { await this.WriteValueSeparatorAsync().ConfigureAwait(false); await this.writer.WriteValueAsync(value).ConfigureAwait(false); } /// - public async Task WriteValueAsync(short value) + public async ValueTask WriteValueAsync(short value) { await this.WriteValueSeparatorAsync().ConfigureAwait(false); await this.writer.WriteValueAsync(value).ConfigureAwait(false); } /// - public async Task WriteValueAsync(long value) + public async ValueTask WriteValueAsync(long value) { await this.WriteValueSeparatorAsync().ConfigureAwait(false); @@ -154,21 +154,21 @@ await this.writer.WriteValueAsync(value.ToString(CultureInfo.InvariantCulture), } /// - public async Task WriteValueAsync(double value) + public async ValueTask WriteValueAsync(double value) { await this.WriteValueSeparatorAsync().ConfigureAwait(false); await this.writer.WriteValueAsync(value).ConfigureAwait(false); } /// - public async Task WriteValueAsync(Guid value) + public async ValueTask WriteValueAsync(Guid value) { await this.WriteValueSeparatorAsync().ConfigureAwait(false); await this.writer.WriteValueAsync(value).ConfigureAwait(false); } /// - public async Task WriteValueAsync(decimal value) + public async ValueTask WriteValueAsync(decimal value) { await this.WriteValueSeparatorAsync().ConfigureAwait(false); @@ -185,7 +185,7 @@ await this.writer.WriteValueAsync(value.ToString(CultureInfo.InvariantCulture), } /// - public async Task WriteValueAsync(DateTimeOffset value) + public async ValueTask WriteValueAsync(DateTimeOffset value) { await this.WriteValueSeparatorAsync().ConfigureAwait(false); await this.writer.WriteValueAsync(value, ODataJsonDateTimeFormat.ISO8601DateTime) @@ -193,42 +193,42 @@ await this.writer.WriteValueAsync(value, ODataJsonDateTimeFormat.ISO8601DateTime } /// - public async Task WriteValueAsync(TimeSpan value) + public async ValueTask WriteValueAsync(TimeSpan value) { await this.WriteValueSeparatorAsync().ConfigureAwait(false); await this.writer.WriteValueAsync(value).ConfigureAwait(false); } /// - public async Task WriteValueAsync(TimeOfDay value) + public async ValueTask WriteValueAsync(TimeOfDay value) { await this.WriteValueSeparatorAsync().ConfigureAwait(false); await this.writer.WriteValueAsync(value).ConfigureAwait(false); } /// - public async Task WriteValueAsync(Date value) + public async ValueTask WriteValueAsync(Date value) { await this.WriteValueSeparatorAsync().ConfigureAwait(false); await this.writer.WriteValueAsync(value).ConfigureAwait(false); } /// - public async Task WriteValueAsync(byte value) + public async ValueTask WriteValueAsync(byte value) { await this.WriteValueSeparatorAsync().ConfigureAwait(false); await this.writer.WriteValueAsync(value).ConfigureAwait(false); } /// - public async Task WriteValueAsync(sbyte value) + public async ValueTask WriteValueAsync(sbyte value) { await this.WriteValueSeparatorAsync().ConfigureAwait(false); await this.writer.WriteValueAsync(value).ConfigureAwait(false); } /// - public async Task WriteValueAsync(string value) + public async ValueTask WriteValueAsync(string value) { await this.WriteValueSeparatorAsync().ConfigureAwait(false); await this.writer.WriteValueAsync(value, this.stringEscapeOption, this.wrappedBuffer, this.ArrayPool) @@ -236,14 +236,14 @@ await this.writer.WriteValueAsync(value, this.stringEscapeOption, this.wrappedBu } /// - public async Task WriteValueAsync(byte[] value) + public async ValueTask WriteValueAsync(byte[] value) { await this.WriteValueSeparatorAsync().ConfigureAwait(false); await this.writer.WriteValueAsync(value, this.wrappedBuffer, this.ArrayPool).ConfigureAwait(false); } #if NETCOREAPP - public Task WriteValueAsync(JsonElement value) + public ValueTask WriteValueAsync(JsonElement value) { switch (value.ValueKind) { @@ -265,11 +265,11 @@ public Task WriteValueAsync(JsonElement value) // we've exhausted all known JSON types, if we get // to this point, then it's undefined behavior Debug.Fail($"Unexpected JSON ValueKind {value.ValueKind}"); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } - private async Task WriteJsonElementArrayAsync(JsonElement value) + private async ValueTask WriteJsonElementArrayAsync(JsonElement value) { Debug.Assert(value.ValueKind == JsonValueKind.Array); @@ -282,7 +282,7 @@ private async Task WriteJsonElementArrayAsync(JsonElement value) await this.EndArrayScopeAsync().ConfigureAwait(false); } - private async Task WriteJsonElementObjectAsync(JsonElement value) + private async ValueTask WriteJsonElementObjectAsync(JsonElement value) { Debug.Assert(value.ValueKind == JsonValueKind.Object); @@ -296,7 +296,7 @@ private async Task WriteJsonElementObjectAsync(JsonElement value) await this.EndObjectScopeAsync().ConfigureAwait(false); } - private Task WriteJsonElementNumberAsync(JsonElement value) + private ValueTask WriteJsonElementNumberAsync(JsonElement value) { Debug.Assert(value.ValueKind == JsonValueKind.Number); @@ -356,12 +356,12 @@ private Task WriteJsonElementNumberAsync(JsonElement value) } Debug.Fail($"Exhausted all known JSON number types and did not find match."); - return Task.CompletedTask; + return ValueTask.CompletedTask; } #endif /// - public async Task WriteRawValueAsync(string rawValue) + public async ValueTask WriteRawValueAsync(string rawValue) { await this.WriteValueSeparatorAsync().ConfigureAwait(false); await this.writer.WriteAsync(rawValue).ConfigureAwait(false); @@ -398,7 +398,7 @@ public async ValueTask DisposeAsync() #endif /// - public async Task StartStreamValueScopeAsync() + public async ValueTask StartStreamValueScopeAsync() { await this.WriteValueSeparatorAsync().ConfigureAwait(false); await this.writer.WriteAsync(JsonConstants.QuoteCharacter).ConfigureAwait(false); @@ -414,7 +414,7 @@ public async Task StartStreamValueScopeAsync() } /// - public async Task EndStreamValueScopeAsync() + public async ValueTask EndStreamValueScopeAsync() { await this.binaryValueStream.FlushAsync().ConfigureAwait(false); #if NETCOREAPP @@ -428,7 +428,7 @@ public async Task EndStreamValueScopeAsync() } /// - public async Task StartTextWriterValueScopeAsync(string contentType) + public async ValueTask StartTextWriterValueScopeAsync(string contentType) { await this.WriteValueSeparatorAsync().ConfigureAwait(false); this.currentContentType = contentType; @@ -446,25 +446,25 @@ await this.writer.WriteAsync(JsonConstants.QuoteCharacter) } /// - public Task EndTextWriterValueScopeAsync() + public async ValueTask EndTextWriterValueScopeAsync() { if (!IsWritingJson) { - return this.writer.WriteAsync(JsonConstants.QuoteCharacter); + await this.writer.WriteAsync(JsonConstants.QuoteCharacter).ConfigureAwait(false); } - return TaskUtils.CompletedTask; + return; } /// /// Asynchronously writes a separator of a value if it's needed for the next value to be written. /// /// A task that represents the asynchronous write operation. - private Task WriteValueSeparatorAsync() + private async ValueTask WriteValueSeparatorAsync() { if (this.scopes.Count == 0) { - return TaskUtils.CompletedTask; + return; } Scope currentScope = this.scopes.Peek(); @@ -473,11 +473,11 @@ private Task WriteValueSeparatorAsync() currentScope.ObjectCount++; if (currentScope.ObjectCount > 1) { - return this.writer.WriteAsync(JsonConstants.ArrayElementSeparator); + await this.writer.WriteAsync(JsonConstants.ArrayElementSeparator).ConfigureAwait(false); } } - return TaskUtils.CompletedTask; + return; } /// @@ -485,7 +485,7 @@ private Task WriteValueSeparatorAsync() /// /// The scope type to start. /// A task that represents the asynchronous write operation. - private async Task StartScopeAsync(ScopeType type) + private async ValueTask StartScopeAsync(ScopeType type) { if (this.scopes.Count != 0 && this.scopes.Peek().Type != ScopeType.Padding) { diff --git a/src/Microsoft.OData.Core/Json/JsonWriterExtensions.Async.cs b/src/Microsoft.OData.Core/Json/JsonWriterExtensions.Async.cs index a492ddfcd3..243cca8670 100644 --- a/src/Microsoft.OData.Core/Json/JsonWriterExtensions.Async.cs +++ b/src/Microsoft.OData.Core/Json/JsonWriterExtensions.Async.cs @@ -26,7 +26,7 @@ internal static partial class JsonWriterExtensions /// Writes the given json object value to the underlying json writer. /// Called when the top-level object is started to possibly inject first property into the object. /// A task that represents the asynchronous write operation. - internal static async Task WriteJsonObjectValueAsync( + internal static async ValueTask WriteJsonObjectValueAsync( this IJsonWriter jsonWriter, IDictionary jsonObjectValue, Func injectPropertyDelegate) @@ -56,7 +56,7 @@ internal static async Task WriteJsonObjectValueAsync( /// The to write to. /// The value to write. /// A task that represents the asynchronous write operation. - internal static Task WritePrimitiveValueAsync(this IJsonWriter jsonWriter, object value) + internal static ValueTask WritePrimitiveValueAsync(this IJsonWriter jsonWriter, object value) { if (value is bool) { @@ -140,7 +140,7 @@ internal static Task WritePrimitiveValueAsync(this IJsonWriter jsonWriter, objec return jsonWriter.WriteValueAsync((TimeOfDay)value); } - return TaskUtils.GetFaultedTask( + return ValueTask.FromException( new ODataException(ODataErrorStrings.ODataJsonWriter_UnsupportedValueType(value.GetType().FullName))); } @@ -150,7 +150,7 @@ internal static Task WritePrimitiveValueAsync(this IJsonWriter jsonWriter, objec /// The to write to. /// value to write. /// A task that represents the asynchronous write operation. - internal static Task WriteODataValueAsync(this IJsonWriter jsonWriter, ODataValue odataValue) + internal static ValueTask WriteODataValueAsync(this IJsonWriter jsonWriter, ODataValue odataValue) { if (odataValue == null || odataValue is ODataNullValue) { @@ -170,7 +170,7 @@ internal static Task WriteODataValueAsync(this IJsonWriter jsonWriter, ODataValu { return WriteODataResourceValueAsync(jsonWriter, resourceValue); - async Task WriteODataResourceValueAsync( + async ValueTask WriteODataResourceValueAsync( IJsonWriter innerJsonWriter, ODataResourceValue innerResourceValue) { @@ -190,7 +190,7 @@ async Task WriteODataResourceValueAsync( { return WriteODataCollectionValueAsync(jsonWriter, collectionValue); - async Task WriteODataCollectionValueAsync( + async ValueTask WriteODataCollectionValueAsync( IJsonWriter innerJsonWriter, ODataCollectionValue innerCollectionValue) { @@ -214,7 +214,7 @@ async Task WriteODataCollectionValueAsync( } } - return TaskUtils.GetFaultedTask( + return ValueTask.FromException( new ODataException(ODataErrorStrings.ODataJsonWriter_UnsupportedValueType(odataValue.GetType().FullName))); } @@ -224,7 +224,7 @@ async Task WriteODataCollectionValueAsync( /// The to write to. /// Writes the json array value to the underlying json writer. /// A task that represents the asynchronous write operation. - private static async Task WriteJsonArrayValueAsync(this IJsonWriter jsonWriter, IEnumerable arrayValue) + private static async ValueTask WriteJsonArrayValueAsync(this IJsonWriter jsonWriter, IEnumerable arrayValue) { Debug.Assert(arrayValue != null, "arrayValue != null"); @@ -244,7 +244,7 @@ private static async Task WriteJsonArrayValueAsync(this IJsonWriter jsonWriter, /// The to write to. /// value to write. /// A task that represents the asynchronous write operation. - private static Task WriteJsonValueAsync(this IJsonWriter jsonWriter, object propertyValue) + private static ValueTask WriteJsonValueAsync(this IJsonWriter jsonWriter, object propertyValue) { if (propertyValue == null) { diff --git a/src/Microsoft.OData.Core/Json/ODataJsonWriterUtils.cs b/src/Microsoft.OData.Core/Json/ODataJsonWriterUtils.cs index 0685f5b1bf..603d3eca0b 100644 --- a/src/Microsoft.OData.Core/Json/ODataJsonWriterUtils.cs +++ b/src/Microsoft.OData.Core/Json/ODataJsonWriterUtils.cs @@ -135,9 +135,9 @@ internal static void ODataValueToString(StringBuilder sb, ODataValue value) /// A flag indicating whether error details should be written (in debug mode only) or not. /// The maximum number of nested inner errors to allow. /// A task that represents the asynchronous write operation. - internal static Task WriteErrorAsync( + internal static ValueTask WriteErrorAsync( IJsonWriter jsonWriter, - Func, Task> writeInstanceAnnotationsDelegate, + Func, ValueTask> writeInstanceAnnotationsDelegate, ODataError error, bool includeDebugInformation, int maxInnerErrorDepth) @@ -409,7 +409,7 @@ private static void ODataResourceValueToString(StringBuilder sb, ODataResourceVa /// Delegate to write the instance annotations. /// The maximum number of nested inner errors to allow. /// A task that represents the asynchronous write operation. - private static async Task WriteErrorAsync( + private static async ValueTask WriteErrorAsync( IJsonWriter jsonWriter, string code, string message, @@ -417,7 +417,7 @@ private static async Task WriteErrorAsync( IEnumerable details, ODataInnerError innerError, ICollection instanceAnnotations, - Func, Task> writeInstanceAnnotationsDelegate, + Func, ValueTask> writeInstanceAnnotationsDelegate, int maxInnerErrorDepth) { Debug.Assert(jsonWriter != null, "jsonWriter != null"); @@ -526,7 +526,7 @@ private static async Task WriteErrorDetailsAsync(IJsonWriter jsonWriter, IEnumer /// The number of times this method has been called recursively. /// The maximum number of nested inner errors to allow. /// A task that represents the asynchronous write operation. - private static async Task WriteInnerErrorAsync(IJsonWriter jsonWriter, ODataInnerError innerError, + private static async ValueTask WriteInnerErrorAsync(IJsonWriter jsonWriter, ODataInnerError innerError, string innerErrorPropertyName, int recursionDepth, int maxInnerErrorDepth) { Debug.Assert(jsonWriter != null, "jsonWriter != null"); diff --git a/src/Microsoft.OData.Core/Json/ODataUtf8JsonWriter.Stream.cs b/src/Microsoft.OData.Core/Json/ODataUtf8JsonWriter.Stream.cs index a173837dbe..cd23cfe19e 100644 --- a/src/Microsoft.OData.Core/Json/ODataUtf8JsonWriter.Stream.cs +++ b/src/Microsoft.OData.Core/Json/ODataUtf8JsonWriter.Stream.cs @@ -7,6 +7,8 @@ #if NETCOREAPP namespace Microsoft.OData.Json { + using Microsoft.OData.Edm; + using Microsoft.OData.Metadata; using System; using System.Buffers; using System.Diagnostics; @@ -58,7 +60,7 @@ public void EndStreamValueScope() /// Asynchronously starts a scope for writing a stream value. /// /// A task representing the asynchronous operation. The task result contains a stream for writing the stream value. - public async Task StartStreamValueScopeAsync() + public async ValueTask StartStreamValueScopeAsync() { this.WriteSeparatorIfNecessary(); this.bufferWriter.Write(this.DoubleQuote.Slice(0, 1).Span); @@ -73,7 +75,7 @@ public async Task StartStreamValueScopeAsync() /// Asynchronously ends a scope for writing a stream value. /// /// A task representing the asynchronous operation. - public async Task EndStreamValueScopeAsync() + public async ValueTask EndStreamValueScopeAsync() { if (this.binaryValueStream != null) { @@ -238,6 +240,19 @@ public override async Task WriteAsync(byte[] buffer, int offset, int count, Canc await this.WriteByteValueInChunksAsync(value).ConfigureAwait(false); } + /// + /// Asynchronously writes a portion of a byte array to the underlying stream in chunks. + /// + /// The byte array from which data will be written. + /// The zero-based byte offset in the buffer at which to begin copying bytes to the stream. + /// The maximum number of bytes to write. + /// A CancellationToken to observe while waiting for the task to complete. + /// A task representing the asynchronous write operation. + public override async ValueTask WriteAsync(ReadOnlyMemory value, CancellationToken token) + { + await this.WriteByteValueInChunksAsync(value).ConfigureAwait(false); + } + /// /// Writes the byte value represented by the provided read-only span in chunks using Base64 encoding. /// diff --git a/src/Microsoft.OData.Core/Json/ODataUtf8JsonWriter.TextWriter.cs b/src/Microsoft.OData.Core/Json/ODataUtf8JsonWriter.TextWriter.cs index 1414222ad8..51d00fcef5 100644 --- a/src/Microsoft.OData.Core/Json/ODataUtf8JsonWriter.TextWriter.cs +++ b/src/Microsoft.OData.Core/Json/ODataUtf8JsonWriter.TextWriter.cs @@ -83,7 +83,7 @@ public void EndTextWriterValueScope() /// /// The content type of the TextWriter value scope. /// A task representing the asynchronous operation. The task result is a TextWriter for writing JSON data. - public async Task StartTextWriterValueScopeAsync(string contentType) + public async ValueTask StartTextWriterValueScopeAsync(string contentType) { await this.FlushAsync().ConfigureAwait(false); @@ -109,7 +109,7 @@ public async Task StartTextWriterValueScopeAsync(string contentType) /// Asynchronously ends a TextWriter value scope. /// /// A task representing the asynchronous operation. - public async Task EndTextWriterValueScopeAsync() + public async ValueTask EndTextWriterValueScopeAsync() { if (!this.isWritingJson) { diff --git a/src/Microsoft.OData.Core/Json/ODataUtf8JsonWriter.cs b/src/Microsoft.OData.Core/Json/ODataUtf8JsonWriter.cs index d0d8785057..6f4bc03c42 100644 --- a/src/Microsoft.OData.Core/Json/ODataUtf8JsonWriter.cs +++ b/src/Microsoft.OData.Core/Json/ODataUtf8JsonWriter.cs @@ -861,28 +861,28 @@ public void Dispose() #region "Asynchronous API" - public async Task StartPaddingFunctionScopeAsync() + public async ValueTask StartPaddingFunctionScopeAsync() { this.CommitUtf8JsonWriterContentsToBuffer(); this.bufferWriter.Write(parentheses[..1].Span); await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task WritePaddingFunctionNameAsync(string functionName) + public async ValueTask WritePaddingFunctionNameAsync(string functionName) { this.CommitUtf8JsonWriterContentsToBuffer(); this.bufferWriter.Write(Encoding.UTF8.GetBytes(functionName)); await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task EndPaddingFunctionScopeAsync() + public async ValueTask EndPaddingFunctionScopeAsync() { this.CommitUtf8JsonWriterContentsToBuffer(); this.bufferWriter.Write(parentheses[1..2].Span); await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task StartObjectScopeAsync() + public async ValueTask StartObjectScopeAsync() { this.WriteSeparatorIfNecessary(); this.EnterObjectScope(); @@ -890,14 +890,14 @@ public async Task StartObjectScopeAsync() await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task EndObjectScopeAsync() + public async ValueTask EndObjectScopeAsync() { this.utf8JsonWriter.WriteEndObject(); this.ExitScope(); await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task StartArrayScopeAsync() + public async ValueTask StartArrayScopeAsync() { this.WriteSeparatorIfNecessary(); this.EnterArrayScope(); @@ -905,49 +905,49 @@ public async Task StartArrayScopeAsync() await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task EndArrayScopeAsync() + public async ValueTask EndArrayScopeAsync() { this.utf8JsonWriter.WriteEndArray(); this.ExitScope(); await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task WriteNameAsync(string name) + public async ValueTask WriteNameAsync(string name) { this.WriteSeparatorIfNecessary(); this.utf8JsonWriter.WritePropertyName(name); await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task WriteValueAsync(bool value) + public async ValueTask WriteValueAsync(bool value) { this.WriteSeparatorIfNecessary(); this.utf8JsonWriter.WriteBooleanValue(value); await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task WriteValueAsync(int value) + public async ValueTask WriteValueAsync(int value) { this.WriteSeparatorIfNecessary(); this.utf8JsonWriter.WriteNumberValue(value); await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task WriteValueAsync(float value) + public async ValueTask WriteValueAsync(float value) { this.WriteSeparatorIfNecessary(); this.utf8JsonWriter.WriteNumberValue(value); await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task WriteValueAsync(short value) + public async ValueTask WriteValueAsync(short value) { this.WriteSeparatorIfNecessary(); this.utf8JsonWriter.WriteNumberValue(value); await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task WriteValueAsync(long value) + public async ValueTask WriteValueAsync(long value) { this.WriteSeparatorIfNecessary(); if (this.isIeee754Compatible) @@ -962,7 +962,7 @@ public async Task WriteValueAsync(long value) await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task WriteValueAsync(double value) + public async ValueTask WriteValueAsync(double value) { this.WriteSeparatorIfNecessary(); if (double.IsNaN(value)) @@ -985,14 +985,14 @@ public async Task WriteValueAsync(double value) await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task WriteValueAsync(Guid value) + public async ValueTask WriteValueAsync(Guid value) { this.WriteSeparatorIfNecessary(); this.utf8JsonWriter.WriteStringValue(value); await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task WriteValueAsync(decimal value) + public async ValueTask WriteValueAsync(decimal value) { this.WriteSeparatorIfNecessary(); if (this.isIeee754Compatible) @@ -1007,7 +1007,7 @@ public async Task WriteValueAsync(decimal value) await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task WriteValueAsync(DateTimeOffset value) + public async ValueTask WriteValueAsync(DateTimeOffset value) { this.WriteSeparatorIfNecessary(); if (value.Offset == TimeSpan.Zero) @@ -1029,7 +1029,7 @@ public async Task WriteValueAsync(DateTimeOffset value) await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task WriteValueAsync(TimeSpan value) + public async ValueTask WriteValueAsync(TimeSpan value) { this.WriteSeparatorIfNecessary(); string stringValue = EdmValueWriter.DurationAsXml(value); @@ -1037,35 +1037,35 @@ public async Task WriteValueAsync(TimeSpan value) await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task WriteValueAsync(Date value) + public async ValueTask WriteValueAsync(Date value) { this.WriteSeparatorIfNecessary(); this.utf8JsonWriter.WriteStringValue(value.ToString()); await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task WriteValueAsync(TimeOfDay value) + public async ValueTask WriteValueAsync(TimeOfDay value) { this.WriteSeparatorIfNecessary(); this.utf8JsonWriter.WriteStringValue(value.ToString()); await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task WriteValueAsync(byte value) + public async ValueTask WriteValueAsync(byte value) { this.WriteSeparatorIfNecessary(); this.utf8JsonWriter.WriteNumberValue(value); await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task WriteValueAsync(sbyte value) + public async ValueTask WriteValueAsync(sbyte value) { this.WriteSeparatorIfNecessary(); this.utf8JsonWriter.WriteNumberValue(value); await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task WriteValueAsync(string value) + public async ValueTask WriteValueAsync(string value) { if (value == null) { @@ -1138,7 +1138,7 @@ private async ValueTask WriteStringValueInChunksAsync(ReadOnlyMemory value CheckIfManualValueAtArrayStart(); } - public async Task WriteValueAsync(byte[] value) + public async ValueTask WriteValueAsync(byte[] value) { if (value == null) { @@ -1195,14 +1195,14 @@ private async ValueTask WriteByteValueInChunksAsync(ReadOnlyMemory value) CheckIfManualValueAtArrayStart(); } - public async Task WriteValueAsync(JsonElement value) + public async ValueTask WriteValueAsync(JsonElement value) { this.WriteSeparatorIfNecessary(); value.WriteTo(utf8JsonWriter); await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); } - public async Task WriteRawValueAsync(string rawValue) + public async ValueTask WriteRawValueAsync(string rawValue) { this.WriteRawValueCore(rawValue); await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false); diff --git a/src/Microsoft.OData.Core/Json/TranscodingWriteStream.cs b/src/Microsoft.OData.Core/Json/TranscodingWriteStream.cs index 724bec43ab..d048ab39e1 100644 --- a/src/Microsoft.OData.Core/Json/TranscodingWriteStream.cs +++ b/src/Microsoft.OData.Core/Json/TranscodingWriteStream.cs @@ -406,23 +406,6 @@ async ValueTask WriteAsyncCore(ReadOnlyMemory remainingOuterEncodedBytes, public override void WriteByte(byte value) => Write(new ReadOnlySpan(new byte[] { value })); - - private static void ValidateBufferArguments(byte[] buffer, int offset, int size) - { - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - if ((uint)offset > (uint)buffer.Length) - { - throw new ArgumentOutOfRangeException(nameof(offset)); - } - if ((uint)size > (uint)(buffer.Length - offset)) - { - throw new ArgumentOutOfRangeException(nameof(size)); - } - } } } diff --git a/src/Microsoft.OData.Core/JsonLight/JsonLightODataAnnotationWriter.cs b/src/Microsoft.OData.Core/JsonLight/JsonLightODataAnnotationWriter.cs index e2967218a7..635230c396 100644 --- a/src/Microsoft.OData.Core/JsonLight/JsonLightODataAnnotationWriter.cs +++ b/src/Microsoft.OData.Core/JsonLight/JsonLightODataAnnotationWriter.cs @@ -173,7 +173,7 @@ await this.jsonWriter.WriteValueAsync(WriterUtils.PrefixTypeNameForWriting(typeN /// The name of the property to annotate. /// The name of the annotation to write. /// A task that represents the asynchronous write operation. - public Task WritePropertyAnnotationNameAsync(string propertyName, string annotationName) + public async Task WritePropertyAnnotationNameAsync(string propertyName, string annotationName) { Debug.Assert(this.jsonWriter != null, "this.jsonWriter != null"); Debug.Assert(!string.IsNullOrEmpty(propertyName), "!string.IsNullOrEmpty(propertyName)"); @@ -181,7 +181,7 @@ public Task WritePropertyAnnotationNameAsync(string propertyName, string annotat Debug.Assert(annotationName.StartsWith(JsonLightConstants.ODataAnnotationNamespacePrefix, StringComparison.Ordinal), "annotationName.StartsWith(\"odata.\")"); - return this.jsonWriter.WritePropertyAnnotationNameAsync(propertyName, SimplifyODataAnnotationName(annotationName)); + await this.jsonWriter.WritePropertyAnnotationNameAsync(propertyName, SimplifyODataAnnotationName(annotationName)); } /// @@ -189,14 +189,14 @@ public Task WritePropertyAnnotationNameAsync(string propertyName, string annotat /// /// The name of the instance annotation to write. /// A task that represents the asynchronous write operation. - public Task WriteInstanceAnnotationNameAsync(string annotationName) + public async Task WriteInstanceAnnotationNameAsync(string annotationName) { Debug.Assert(this.jsonWriter != null, "this.jsonWriter != null"); Debug.Assert(!string.IsNullOrEmpty(annotationName), "!string.IsNullOrEmpty(annotationName)"); Debug.Assert(annotationName.StartsWith(JsonLightConstants.ODataAnnotationNamespacePrefix, StringComparison.Ordinal), "annotationName.StartsWith(\"odata.\")"); - return this.jsonWriter.WriteInstanceAnnotationNameAsync(SimplifyODataAnnotationName(annotationName)); + await this.jsonWriter.WriteInstanceAnnotationNameAsync(SimplifyODataAnnotationName(annotationName)); } /// diff --git a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightBatchWriter.cs b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightBatchWriter.cs index ce96e0a3ed..23419d7f72 100644 --- a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightBatchWriter.cs +++ b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightBatchWriter.cs @@ -909,7 +909,7 @@ private void WriteRequestUri(Uri uri, BatchPayloadUriOption payloadUriOption) /// Asynchronously writes the start boundary for an operation. This is Json start object. /// /// A task that represents the asynchronous write operation. - private Task WriteStartBoundaryForOperationAsync() + private ValueTask WriteStartBoundaryForOperationAsync() { // Start the individual message object return this.jsonWriter.StartObjectScopeAsync(); @@ -981,7 +981,7 @@ await this.EnsurePrecedingMessageIsClosedAsync() /// Asynchronously closes preceding message Json object if any. /// /// A task that represents the asynchronous write operation. - private Task EnsurePrecedingMessageIsClosedAsync() + private ValueTask EnsurePrecedingMessageIsClosedAsync() { // There shouldn't be any pending message object. Debug.Assert(this.CurrentOperationMessage == null, "this.CurrentOperationMessage == null"); diff --git a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightCollectionWriter.cs b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightCollectionWriter.cs index e05616d83b..e101e5e0bb 100644 --- a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightCollectionWriter.cs +++ b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightCollectionWriter.cs @@ -179,9 +179,9 @@ protected override Task StartPayloadAsync() /// Asynchronously finish writing an OData payload. /// /// A task that represents the asynchronous write operation. - protected override Task EndPayloadAsync() + protected async override Task EndPayloadAsync() { - return this.jsonLightCollectionSerializer.WritePayloadEndAsync(); + await this.jsonLightCollectionSerializer.WritePayloadEndAsync(); } /// diff --git a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightDeltaWriter.cs b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightDeltaWriter.cs index 1ca2ed129d..fdce5e2a8e 100644 --- a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightDeltaWriter.cs +++ b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightDeltaWriter.cs @@ -121,7 +121,7 @@ public override void WriteStart(ODataDeltaResourceSet deltaResourceSet) /// /// Delta resource set/collection to write. /// A task instance that represents the asynchronous write operation. - public override Task WriteStartAsync(ODataDeltaResourceSet deltaResourceSet) + public override ValueTask WriteStartAsync(ODataDeltaResourceSet deltaResourceSet) { return this.resourceWriter.WriteStartAsync(deltaResourceSet); } @@ -138,7 +138,7 @@ public override void WriteEnd() /// Asynchronously finish writing a delta resource set. /// /// A task instance that represents the asynchronous write operation. - public override Task WriteEndAsync() + public override ValueTask WriteEndAsync() { return this.resourceWriter.WriteEndAsync(); } @@ -157,7 +157,7 @@ public override void WriteStart(ODataNestedResourceInfo nestedResourceInfo) /// /// The nested resource info to write. /// A task instance that represents the asynchronous write operation. - public override Task WriteStartAsync(ODataNestedResourceInfo nestedResourceInfo) + public override ValueTask WriteStartAsync(ODataNestedResourceInfo nestedResourceInfo) { return this.resourceWriter.WriteStartAsync(nestedResourceInfo); } @@ -176,7 +176,7 @@ public override void WriteStart(ODataResourceSet expandedResourceSet) /// /// The expanded resource set to write. /// A task instance that represents the asynchronous write operation. - public override Task WriteStartAsync(ODataResourceSet expandedResourceSet) + public override ValueTask WriteStartAsync(ODataResourceSet expandedResourceSet) { return this.resourceWriter.WriteStartAsync(expandedResourceSet); } @@ -195,7 +195,7 @@ public override void WriteStart(ODataResource deltaResource) /// /// The delta resource to write. /// A task instance that represents the asynchronous write operation. - public override Task WriteStartAsync(ODataResource deltaResource) + public override ValueTask WriteStartAsync(ODataResource deltaResource) { return this.resourceWriter.WriteStartAsync(deltaResource); } @@ -215,7 +215,7 @@ public override void WriteDeltaDeletedEntry(ODataDeltaDeletedEntry deltaDeletedE /// /// The delta deleted resource to write. /// A task instance that represents the asynchronous write operation. - public override Task WriteDeltaDeletedEntryAsync(ODataDeltaDeletedEntry deltaDeletedEntry) + public override ValueTask WriteDeltaDeletedEntryAsync(ODataDeltaDeletedEntry deltaDeletedEntry) { return this.resourceWriter.WriteStartAsync(ODataDeltaDeletedEntry.GetDeletedResource(deltaDeletedEntry)); } @@ -234,7 +234,7 @@ public override void WriteDeltaLink(ODataDeltaLink deltaLink) /// /// The delta link to write. /// A task instance that represents the asynchronous write operation. - public override Task WriteDeltaLinkAsync(ODataDeltaLink deltaLink) + public override ValueTask WriteDeltaLinkAsync(ODataDeltaLink deltaLink) { return this.resourceWriter.WriteDeltaLinkAsync(deltaLink); } @@ -253,7 +253,7 @@ public override void WriteDeltaDeletedLink(ODataDeltaDeletedLink deltaDeletedLin /// /// The delta deleted link to write. /// A task instance that represents the asynchronous write operation. - public override Task WriteDeltaDeletedLinkAsync(ODataDeltaDeletedLink deltaDeletedLink) + public override ValueTask WriteDeltaDeletedLinkAsync(ODataDeltaDeletedLink deltaDeletedLink) { return this.resourceWriter.WriteDeltaDeletedLinkAsync(deltaDeletedLink); } diff --git a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightInputContext.cs b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightInputContext.cs index d6e601d3c1..ed2894d314 100644 --- a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightInputContext.cs +++ b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightInputContext.cs @@ -188,13 +188,14 @@ public override ODataReader CreateResourceSetReader(IEdmEntitySetBase entitySet, /// The entity set we are going to read resources for. /// The expected structured type for the items in the resource set. /// Task which when completed returns the newly created . - public override Task CreateResourceSetReaderAsync(IEdmEntitySetBase entitySet, IEdmStructuredType expectedResourceType) + public async override ValueTask CreateResourceSetReaderAsync(IEdmEntitySetBase entitySet, IEdmStructuredType expectedResourceType) { this.AssertAsynchronous(); this.VerifyCanCreateODataReader(entitySet, expectedResourceType); // Note that the reading is actually synchronous since we buffer the entire input when getting the stream from the message. - return TaskUtils.GetTaskForSynchronousOperation(() => this.CreateResourceSetReaderImplementation(entitySet, expectedResourceType, /*readingParameter*/ false, /*readingDelta*/ false)); + ODataReader reader = await TaskUtils.GetTaskForSynchronousOperation(() => this.CreateResourceSetReaderImplementation(entitySet, expectedResourceType, /*readingParameter*/ false, /*readingDelta*/ false)); + return reader; } /// @@ -217,13 +218,14 @@ public override ODataReader CreateDeltaResourceSetReader(IEdmEntitySetBase entit /// The entity set we are going to read resources for. /// The expected structured type for the items in the resource set. /// Task which when completed returns the newly created . - public override Task CreateDeltaResourceSetReaderAsync(IEdmEntitySetBase entitySet, IEdmStructuredType expectedResourceType) + public async override ValueTask CreateDeltaResourceSetReaderAsync(IEdmEntitySetBase entitySet, IEdmStructuredType expectedResourceType) { this.AssertAsynchronous(); this.VerifyCanCreateODataReader(entitySet, expectedResourceType); // Note that the reading is actually synchronous since we buffer the entire input when getting the stream from the message. - return TaskUtils.GetTaskForSynchronousOperation(() => this.CreateResourceSetReaderImplementation(entitySet, expectedResourceType, /*readingParameter*/ false, /*readingDelta*/ true)); + ODataReader reader = await TaskUtils.GetTaskForSynchronousOperation(() => this.CreateResourceSetReaderImplementation(entitySet, expectedResourceType, /*readingParameter*/ false, /*readingDelta*/ true)); + return reader; } /// @@ -246,13 +248,14 @@ public override ODataReader CreateResourceReader(IEdmNavigationSource navigation /// The navigation source we are going to read resources for. /// The expected structured type for the resource to be read. /// Task which when completed returns the newly created . - public override Task CreateResourceReaderAsync(IEdmNavigationSource navigationSource, IEdmStructuredType expectedResourceType) + public async override ValueTask CreateResourceReaderAsync(IEdmNavigationSource navigationSource, IEdmStructuredType expectedResourceType) { this.AssertAsynchronous(); this.VerifyCanCreateODataReader(navigationSource, expectedResourceType); // Note that the reading is actually synchronous since we buffer the entire input when getting the stream from the message. - return TaskUtils.GetTaskForSynchronousOperation(() => this.CreateResourceReaderImplementation(navigationSource, expectedResourceType)); + ODataReader reader = await TaskUtils.GetTaskForSynchronousOperation(() => this.CreateResourceReaderImplementation(navigationSource, expectedResourceType)); + return reader; } /// @@ -273,13 +276,14 @@ public override ODataCollectionReader CreateCollectionReader(IEdmTypeReference e /// /// The expected type reference for the items in the collection. /// Task which when completed returns the newly create . - public override Task CreateCollectionReaderAsync(IEdmTypeReference expectedItemTypeReference) + public async override ValueTask CreateCollectionReaderAsync(IEdmTypeReference expectedItemTypeReference) { this.AssertAsynchronous(); this.VerifyCanCreateCollectionReader(expectedItemTypeReference); // Note that the reading is actually synchronous since we buffer the entire input when getting the stream from the message. - return TaskUtils.GetTaskForSynchronousOperation(() => this.CreateCollectionReaderImplementation(expectedItemTypeReference)); + ODataCollectionReader reader = await TaskUtils.GetTaskForSynchronousOperation(() => this.CreateCollectionReaderImplementation(expectedItemTypeReference)); + return reader; } /// @@ -305,13 +309,14 @@ public override ODataProperty ReadProperty(IEdmStructuralProperty property, IEdm /// The producing the property to be read. /// The expected type reference of the property to read. /// Task which when completed returns an representing the read property. - public override Task ReadPropertyAsync(IEdmStructuralProperty property, IEdmTypeReference expectedPropertyTypeReference) + public async override ValueTask ReadPropertyAsync(IEdmStructuralProperty property, IEdmTypeReference expectedPropertyTypeReference) { this.AssertAsynchronous(); this.VerifyCanReadProperty(); ODataJsonLightPropertyAndValueDeserializer jsonLightPropertyAndValueDeserializer = new ODataJsonLightPropertyAndValueDeserializer(this); - return jsonLightPropertyAndValueDeserializer.ReadTopLevelPropertyAsync(expectedPropertyTypeReference); + ODataProperty oDataProperty = await jsonLightPropertyAndValueDeserializer.ReadTopLevelPropertyAsync(expectedPropertyTypeReference); + return oDataProperty; } @@ -331,12 +336,13 @@ public override ODataError ReadError() /// Asynchronously read a top-level error. /// /// Task which when completed returns an representing the read error. - public override Task ReadErrorAsync() + public async override ValueTask ReadErrorAsync() { this.AssertAsynchronous(); ODataJsonLightErrorDeserializer jsonLightErrorDeserializer = new ODataJsonLightErrorDeserializer(this); - return jsonLightErrorDeserializer.ReadTopLevelErrorAsync(); + ODataError error = await jsonLightErrorDeserializer.ReadTopLevelErrorAsync(); + return error; } /// @@ -359,12 +365,13 @@ public override ODataReader CreateUriParameterResourceSetReader(IEdmEntitySetBas /// The entity set we are going to read resources for. /// The expected structured type for the items in the resource set. /// Task which when completed returns the newly created . - public override Task CreateUriParameterResourceSetReaderAsync(IEdmEntitySetBase entitySet, IEdmStructuredType expectedResourceType) + public async override ValueTask CreateUriParameterResourceSetReaderAsync(IEdmEntitySetBase entitySet, IEdmStructuredType expectedResourceType) { this.AssertAsynchronous(); this.VerifyCanCreateODataReader(entitySet, expectedResourceType); - return TaskUtils.GetTaskForSynchronousOperation(() => this.CreateResourceSetReaderImplementation(entitySet, expectedResourceType, /*readingParameter*/ true, /*readingDelta*/ false)); + ODataReader reader = await TaskUtils.GetTaskForSynchronousOperation(() => this.CreateResourceSetReaderImplementation(entitySet, expectedResourceType, /*readingParameter*/ true, /*readingDelta*/ false)); + return reader; } /// @@ -384,9 +391,10 @@ public override ODataReader CreateUriParameterResourceReader(IEdmNavigationSourc /// The navigation source we are going to read resources for. /// The expected structured type for the resource to be read. /// Task which when completed returns the newly created . - public override Task CreateUriParameterResourceReaderAsync(IEdmNavigationSource navigationSource, IEdmStructuredType expectedResourceType) + public async override ValueTask CreateUriParameterResourceReaderAsync(IEdmNavigationSource navigationSource, IEdmStructuredType expectedResourceType) { - return this.CreateResourceReaderAsync(navigationSource, expectedResourceType); + ODataReader reader = await this.CreateResourceReaderAsync(navigationSource, expectedResourceType); + return reader; } /// @@ -407,13 +415,14 @@ public override ODataParameterReader CreateParameterReader(IEdmOperation operati /// /// The operation whose parameters are being read. /// Task which when completed returns the newly created . - public override Task CreateParameterReaderAsync(IEdmOperation operation) + public async override ValueTask CreateParameterReaderAsync(IEdmOperation operation) { this.AssertAsynchronous(); this.VerifyCanCreateParameterReader(operation); // Note that the reading is actually synchronous since we buffer the entire input when getting the stream from the message. - return TaskUtils.GetTaskForSynchronousOperation(() => this.CreateParameterReaderImplementation(operation)); + ODataParameterReader reader = await TaskUtils.GetTaskForSynchronousOperation(() => this.CreateParameterReaderImplementation(operation)); + return reader; } /// @@ -464,13 +473,14 @@ internal override ODataDeltaReader CreateDeltaReader(IEdmEntitySetBase entitySet /// The entity set we are going to read entities for. /// The expected base entity type for the entries in the delta response. /// Task which when completed returns the newly created . - internal override Task CreateDeltaReaderAsync(IEdmEntitySetBase entitySet, IEdmEntityType expectedBaseEntityType) + internal async override ValueTask CreateDeltaReaderAsync(IEdmEntitySetBase entitySet, IEdmEntityType expectedBaseEntityType) { this.AssertAsynchronous(); this.VerifyCanCreateODataReader(entitySet, expectedBaseEntityType); // Note that the reading is actually synchronous since we buffer the entire input when getting the stream from the message. - return TaskUtils.GetTaskForSynchronousOperation(() => this.CreateDeltaReaderImplementation(entitySet, expectedBaseEntityType)); + ODataDeltaReader reader = await TaskUtils.GetTaskForSynchronousOperation(() => this.CreateDeltaReaderImplementation(entitySet, expectedBaseEntityType)); + return reader; } /// @@ -486,10 +496,11 @@ internal override ODataBatchReader CreateBatchReader() /// Asynchronously create a . /// /// Task which when completed returns the newly created . - internal override Task CreateBatchReaderAsync() + internal async override ValueTask CreateBatchReaderAsync() { // Note that the reading is actually synchronous since we buffer the entire input when getting the stream from the message. - return TaskUtils.GetTaskForSynchronousOperation(() => this.CreateBatchReaderImplementation(/*synchronous*/ false)); + ODataBatchReader reader = await TaskUtils.GetTaskForSynchronousOperation(() => this.CreateBatchReaderImplementation(/*synchronous*/ false)); + return reader; } /// @@ -512,12 +523,13 @@ internal override ODataServiceDocument ReadServiceDocument() /// an that represents the read service document. /// /// Task which when completed returns an representing the read service document. - internal override Task ReadServiceDocumentAsync() + internal async override ValueTask ReadServiceDocumentAsync() { this.AssertAsynchronous(); ODataJsonLightServiceDocumentDeserializer jsonLightServiceDocumentDeserializer = new ODataJsonLightServiceDocumentDeserializer(this); - return jsonLightServiceDocumentDeserializer.ReadServiceDocumentAsync(); + ODataServiceDocument document = await jsonLightServiceDocumentDeserializer.ReadServiceDocumentAsync(); + return document; } /// @@ -536,12 +548,13 @@ internal override ODataEntityReferenceLinks ReadEntityReferenceLinks() /// Asynchronously read a set of top-level entity reference links. /// /// Task which when completed returns an representing the read links. - internal override Task ReadEntityReferenceLinksAsync() + internal async override ValueTask ReadEntityReferenceLinksAsync() { this.AssertAsynchronous(); ODataJsonLightEntityReferenceLinkDeserializer jsonLightEntityReferenceLinkDeserializer = new ODataJsonLightEntityReferenceLinkDeserializer(this); - return jsonLightEntityReferenceLinkDeserializer.ReadEntityReferenceLinksAsync(); + ODataEntityReferenceLinks links = await jsonLightEntityReferenceLinkDeserializer.ReadEntityReferenceLinksAsync(); + return links; } /// @@ -561,13 +574,14 @@ internal override ODataEntityReferenceLink ReadEntityReferenceLink() /// Asynchronously read a top-level entity reference link. /// /// Task which when completed returns an representing the read entity reference link. - internal override Task ReadEntityReferenceLinkAsync() + internal async override ValueTask ReadEntityReferenceLinkAsync() { this.AssertAsynchronous(); this.VerifyCanReadEntityReferenceLink(); ODataJsonLightEntityReferenceLinkDeserializer jsonLightEntityReferenceLinkDeserializer = new ODataJsonLightEntityReferenceLinkDeserializer(this); - return jsonLightEntityReferenceLinkDeserializer.ReadEntityReferenceLinkAsync(); + ODataEntityReferenceLink link = await jsonLightEntityReferenceLinkDeserializer.ReadEntityReferenceLinkAsync(); + return link; } /// diff --git a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightOutputContext.cs b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightOutputContext.cs index e6c6c5f54c..7d24fef6e5 100644 --- a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightOutputContext.cs +++ b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightOutputContext.cs @@ -221,11 +221,11 @@ public override ODataWriter CreateODataResourceSetWriter(IEdmEntitySetBase entit /// The resource type for the items in the resource set to be written (or null if the entity set base type should be used). /// A running task for the created writer. /// The write must flush the output when it's finished (inside the last Write call). - public override Task CreateODataResourceSetWriterAsync(IEdmEntitySetBase entitySet, IEdmStructuredType resourceType) + public async override ValueTask CreateODataResourceSetWriterAsync(IEdmEntitySetBase entitySet, IEdmStructuredType resourceType) { this.AssertAsynchronous(); - return TaskUtils.GetTaskForSynchronousOperation(( + ODataWriter writer = await TaskUtils.GetTaskForSynchronousOperation(( thisParam, entitySetParam, resourceTypeParam) => thisParam.CreateODataResourceSetWriterImplementation( @@ -236,6 +236,8 @@ public override Task CreateODataResourceSetWriterAsync(IEdmEntitySe this, entitySet, resourceType); + + return writer; } /// @@ -259,11 +261,11 @@ public override ODataWriter CreateODataDeltaResourceSetWriter(IEdmEntitySetBase /// The resource type for the items in the resource set to be written (or null if the entity set base type should be used). /// A running task for the created writer. /// The write must flush the output when it's finished (inside the last Write call). - public override Task CreateODataDeltaResourceSetWriterAsync(IEdmEntitySetBase entitySet, IEdmStructuredType resourceType) + public async override ValueTask CreateODataDeltaResourceSetWriterAsync(IEdmEntitySetBase entitySet, IEdmStructuredType resourceType) { this.AssertAsynchronous(); - return TaskUtils.GetTaskForSynchronousOperation(( + ODataWriter writer = await TaskUtils.GetTaskForSynchronousOperation(( thisParam, entitySetParam, resourceTypeParam) => thisParam.CreateODataResourceSetWriterImplementation( @@ -274,6 +276,8 @@ public override Task CreateODataDeltaResourceSetWriterAsync(IEdmEnt this, entitySet, resourceType); + + return writer; } /// @@ -297,11 +301,11 @@ public override ODataWriter CreateODataResourceWriter(IEdmNavigationSource navig /// The structured type for the resources in the resource set to be written (or null if the entity set base type should be used). /// A running task for the created writer. /// The write must flush the output when it's finished (inside the last Write call). - public override Task CreateODataResourceWriterAsync(IEdmNavigationSource navigationSource, IEdmStructuredType resourceType) + public async override ValueTask CreateODataResourceWriterAsync(IEdmNavigationSource navigationSource, IEdmStructuredType resourceType) { this.AssertAsynchronous(); - return TaskUtils.GetTaskForSynchronousOperation(( + ODataWriter writer = await TaskUtils.GetTaskForSynchronousOperation(( thisParam, navigationSourceParam, resourceTypeParam) => thisParam.CreateODataResourceWriterImplementation( @@ -310,6 +314,8 @@ public override Task CreateODataResourceWriterAsync(IEdmNavigationS this, navigationSource, resourceType); + + return writer; } /// @@ -331,16 +337,18 @@ public override ODataCollectionWriter CreateODataCollectionWriter(IEdmTypeRefere /// The item type of the collection being written or null if no metadata is available. /// A running task for the created collection writer. /// The write must flush the output when it's finished (inside the last Write call). - public override Task CreateODataCollectionWriterAsync(IEdmTypeReference itemTypeReference) + public async override ValueTask CreateODataCollectionWriterAsync(IEdmTypeReference itemTypeReference) { this.AssertAsynchronous(); - return TaskUtils.GetTaskForSynchronousOperation(( + ODataCollectionWriter writer = await TaskUtils.GetTaskForSynchronousOperation(( thisParam, itemTypeReferenceParam) => thisParam.CreateODataCollectionWriterImplementation( itemTypeReferenceParam), this, itemTypeReference); + + return writer; } /// @@ -362,9 +370,10 @@ public override ODataWriter CreateODataUriParameterResourceWriter(IEdmNavigation /// The structured type for the resources in the resource set to be written. /// A running task for the created writer. /// The write must flush the output when it's finished (inside the last Write call). - public override Task CreateODataUriParameterResourceWriterAsync(IEdmNavigationSource navigationSource, IEdmStructuredType resourceType) + public async override ValueTask CreateODataUriParameterResourceWriterAsync(IEdmNavigationSource navigationSource, IEdmStructuredType resourceType) { - return this.CreateODataResourceWriterAsync(navigationSource, resourceType); + ODataWriter writer = await this.CreateODataResourceWriterAsync(navigationSource, resourceType); + return writer; } /// @@ -388,11 +397,11 @@ public override ODataWriter CreateODataUriParameterResourceSetWriter(IEdmEntityS /// The resource type for the items in the resource set to be written (or null if the entity set base type should be used). /// A running task for the created writer. /// The write must flush the output when it's finished (inside the last Write call). - public override Task CreateODataUriParameterResourceSetWriterAsync(IEdmEntitySetBase entitySet, IEdmStructuredType resourceType) + public async override ValueTask CreateODataUriParameterResourceSetWriterAsync(IEdmEntitySetBase entitySet, IEdmStructuredType resourceType) { this.AssertAsynchronous(); - return TaskUtils.GetTaskForSynchronousOperation(( + ODataWriter writer = await TaskUtils.GetTaskForSynchronousOperation(( thisParam, entitySetParam, resourceTypeParam) => thisParam.CreateODataResourceSetWriterImplementation( @@ -403,6 +412,8 @@ public override Task CreateODataUriParameterResourceSetWriterAsync( this, entitySet, resourceType); + + return writer; } /// @@ -424,16 +435,18 @@ public override ODataParameterWriter CreateODataParameterWriter(IEdmOperation op /// The operation import whose parameters will be written. /// A running task for the created parameter writer. /// The write must flush the output when it's finished (inside the last Write call). - public override Task CreateODataParameterWriterAsync(IEdmOperation operation) + public async override ValueTask CreateODataParameterWriterAsync(IEdmOperation operation) { this.AssertAsynchronous(); - return TaskUtils.GetTaskForSynchronousOperation(( + ODataParameterWriter writer = await TaskUtils.GetTaskForSynchronousOperation(( thisParam, operationParam) => thisParam.CreateODataParameterWriterImplementation( operationParam), this, operation); + + return writer; } /// @@ -455,7 +468,7 @@ public override void WriteProperty(ODataProperty property) /// The property to write /// A task representing the asynchronous operation of writing the property. /// It is the responsibility of this method to flush the output before the task finishes. - public override async Task WritePropertyAsync(ODataProperty property) + public override async ValueTask WritePropertyAsync(ODataProperty property) { this.AssertAsynchronous(); @@ -492,7 +505,7 @@ public override void WriteError(ODataError error, bool includeDebugInformation) /// /// A task representing the asynchronous operation of writing the error. /// It is the responsibility of this method to flush the output before the task finishes. - public override async Task WriteErrorAsync(ODataError error, bool includeDebugInformation) + public override async ValueTask WriteErrorAsync(ODataError error, bool includeDebugInformation) { this.AssertAsynchronous(); @@ -604,13 +617,15 @@ internal override ODataBatchWriter CreateODataBatchWriter() /// A running task for the created batch writer. /// We don't plan to make this public! /// The write must flush the output when it's finished (inside the last Write call). - internal override Task CreateODataBatchWriterAsync() + internal async override ValueTask CreateODataBatchWriterAsync() { this.AssertAsynchronous(); - return TaskUtils.GetTaskForSynchronousOperation( + ODataBatchWriter writer = await TaskUtils.GetTaskForSynchronousOperation( thisParam => thisParam.CreateODataBatchWriterImplementation(), this); + + return writer; } /// @@ -654,7 +669,7 @@ internal override void WriteInStreamError(ODataError error, bool includeDebugInf /// the in-stream error is written. /// It is the responsibility of this method to flush the output before the task finishes. /// - internal override async Task WriteInStreamErrorAsync(ODataError error, bool includeDebugInformation) + internal override async ValueTask WriteInStreamErrorAsync(ODataError error, bool includeDebugInformation) { this.AssertAsynchronous(); @@ -684,11 +699,11 @@ internal override ODataDeltaWriter CreateODataDeltaWriter(IEdmEntitySetBase enti /// The entity type for the entries in the resource set to be written (or null if the entity set base type should be used). /// A running task for the created writer. /// The write must flush the output when it's finished (inside the last Write call). - internal override Task CreateODataDeltaWriterAsync(IEdmEntitySetBase entitySet, IEdmEntityType entityType) + internal async override ValueTask CreateODataDeltaWriterAsync(IEdmEntitySetBase entitySet, IEdmEntityType entityType) { this.AssertAsynchronous(); - return TaskUtils.GetTaskForSynchronousOperation(( + ODataDeltaWriter writer = await TaskUtils.GetTaskForSynchronousOperation(( thisParam, entitySetParam, entityTypeParam) => thisParam.CreateODataDeltaWriterImplementation( @@ -697,6 +712,8 @@ internal override Task CreateODataDeltaWriterAsync(IEdmEntityS this, entitySet, entityType); + + return writer; } /// @@ -720,7 +737,7 @@ internal override void WriteServiceDocument(ODataServiceDocument serviceDocument /// The service document to write. /// A task representing the asynchronous operation of writing the service document. /// It is the responsibility of this method to flush the output before the task finishes. - internal override async Task WriteServiceDocumentAsync(ODataServiceDocument serviceDocument) + internal override async ValueTask WriteServiceDocumentAsync(ODataServiceDocument serviceDocument) { this.AssertAsynchronous(); @@ -749,7 +766,7 @@ internal override void WriteEntityReferenceLinks(ODataEntityReferenceLinks links /// The entity reference links to write as message payload. /// A task representing the asynchronous writing of the entity reference links. /// It is the responsibility of this method to flush the output before the task finishes. - internal override async Task WriteEntityReferenceLinksAsync(ODataEntityReferenceLinks links) + internal override async ValueTask WriteEntityReferenceLinksAsync(ODataEntityReferenceLinks links) { this.AssertAsynchronous(); @@ -778,7 +795,7 @@ internal override void WriteEntityReferenceLink(ODataEntityReferenceLink link) /// The link result to write as message payload. /// A running task representing the writing of the link. /// It is the responsibility of this method to flush the output before the task finishes. - internal override async Task WriteEntityReferenceLinkAsync(ODataEntityReferenceLink link) + internal override async ValueTask WriteEntityReferenceLinkAsync(ODataEntityReferenceLink link) { this.AssertAsynchronous(); diff --git a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightPropertySerializer.cs b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightPropertySerializer.cs index 59e1349367..83a69c3eaf 100644 --- a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightPropertySerializer.cs +++ b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightPropertySerializer.cs @@ -974,7 +974,7 @@ await this.WriteStreamInfoAsync(propertyName, streamInfo) /// If writing top level property. /// If writing an undeclared property. /// A task that represents the asynchronous write operation. - private Task WriteInstanceAnnotationAsync(ODataPropertyInfo property, bool isTopLevel, bool isUndeclaredProperty) + private ValueTask WriteInstanceAnnotationAsync(ODataPropertyInfo property, bool isTopLevel, bool isUndeclaredProperty) { if (property.InstanceAnnotations.Count != 0) { @@ -988,7 +988,7 @@ private Task WriteInstanceAnnotationAsync(ODataPropertyInfo property, bool isTop } } - return TaskUtils.CompletedTask; + return ValueTask.CompletedTask; } /// diff --git a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightReader.cs b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightReader.cs index dd26083b77..d217ff2e4b 100644 --- a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightReader.cs +++ b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightReader.cs @@ -479,9 +479,10 @@ protected override TextReader CreateTextReaderImplementation() /// A task that represents the asynchronous operation. /// The value of the TResult parameter contains a for reading the stream property. /// - protected override Task CreateReadStreamImplementationAsync() + protected async override Task CreateReadStreamImplementationAsync() { - return this.jsonLightInputContext.JsonReader.CreateReadStreamAsync(); + Stream stream = await this.jsonLightInputContext.JsonReader.CreateReadStreamAsync(); + return stream; } /// @@ -491,9 +492,10 @@ protected override Task CreateReadStreamImplementationAsync() /// A task that represents the asynchronous operation. /// The value of the TResult parameter contains a for reading the string property. /// - protected override Task CreateTextReaderImplementationAsync() + protected async override Task CreateTextReaderImplementationAsync() { - return this.jsonLightInputContext.JsonReader.CreateTextReaderAsync(); + TextReader reader = await this.jsonLightInputContext.JsonReader.CreateTextReaderAsync(); + return reader; } #endregion diff --git a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightResourceDeserializer.cs b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightResourceDeserializer.cs index 9bfcf6be44..6216d778ab 100644 --- a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightResourceDeserializer.cs +++ b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightResourceDeserializer.cs @@ -3681,14 +3681,12 @@ await this.ReadOverPropertyNameAsync() /// Asynchronously reads over the current property name if positioned on a property /// /// A task that represents the asynchronous read operation. - private Task ReadOverPropertyNameAsync() + private async ValueTask ReadOverPropertyNameAsync() { if (this.JsonReader.NodeType == JsonNodeType.Property) { - return this.JsonReader.ReadAsync(); + await this.JsonReader.ReadAsync(); } - - return TaskUtils.CompletedTask; } /// diff --git a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightSerializer.cs b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightSerializer.cs index 4d36bf1690..d6835c37f6 100644 --- a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightSerializer.cs +++ b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightSerializer.cs @@ -243,14 +243,14 @@ async Task WritePayloadStartInnerAsync(IJsonWriter localJsonWriter, string jsonP /// Asynchronously writes the end of the entire JSON payload. /// /// A task that represents the asynchronous write operation. - internal Task WritePayloadEndAsync() + internal ValueTask WritePayloadEndAsync() { if (this.MessageWriterSettings.HasJsonPaddingFunction()) { return this.JsonWriter.EndPaddingFunctionScopeAsync(); } - return Task.CompletedTask; + return ValueTask.CompletedTask; } /// @@ -293,7 +293,7 @@ internal async Task WriteContextUriPropertyAsync( /// /// The delegate that writes the actual JSON payload that is being wrapped. /// A task that represents the asynchronous write operation. - internal async Task WriteTopLevelPayloadAsync(Func payloadWriterFunc) + internal async ValueTask WriteTopLevelPayloadAsync(Func payloadWriterFunc) { Debug.Assert(payloadWriterFunc != null, "payloadWriterAction != null"); @@ -310,7 +310,7 @@ internal async Task WriteTopLevelPayloadAsync(Func payloadWriterFunc) /// The error instance to write. /// A flag indicating whether error details should be written (in debug mode only) or not. /// A task that represents the asynchronous write operation. - internal Task WriteTopLevelErrorAsync(ODataError error, bool includeDebugInformation) + internal ValueTask WriteTopLevelErrorAsync(ODataError error, bool includeDebugInformation) { Debug.Assert(error != null, "error != null"); @@ -598,8 +598,8 @@ protected async Task WriteTopLevelPayloadAsync( /// The second argument value provided to the delegate. /// The third argument value provided to the delegate. /// A task that represents the asynchronous write operation. - protected async Task WriteTopLevelPayloadAsync( - Func payloadWriterFunc, + protected async ValueTask WriteTopLevelPayloadAsync( + Func payloadWriterFunc, TArg1 arg1, TArg2 arg2, TArg3 arg3) diff --git a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightValueSerializer.cs b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightValueSerializer.cs index c7aa56719d..e20aa32d24 100644 --- a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightValueSerializer.cs +++ b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightValueSerializer.cs @@ -402,9 +402,9 @@ public virtual void WriteStreamValue(ODataBinaryStreamValue streamValue) /// Asynchronously writes a null value to the writer. /// /// A task that represents the asynchronous write operation. - public virtual Task WriteNullValueAsync() + public async virtual Task WriteNullValueAsync() { - return this.JsonWriter.WriteValueAsync((string)null); + await this.JsonWriter.WriteValueAsync((string)null); } /// @@ -413,17 +413,17 @@ public virtual Task WriteNullValueAsync() /// enum value /// expected type reference /// A task that represents the asynchronous write operation. - public virtual Task WriteEnumValueAsync( + public async virtual Task WriteEnumValueAsync( ODataEnumValue value, IEdmTypeReference expectedTypeReference) { if (value.Value == null) { - return this.WriteNullValueAsync(); + await this.WriteNullValueAsync(); } else { - return this.JsonWriter.WritePrimitiveValueAsync(value.Value); + await this.JsonWriter.WritePrimitiveValueAsync(value.Value); } } @@ -713,7 +713,7 @@ await TaskUtils.GetTaskForSynchronousOperation( /// /// The untyped value to write. /// A task that represents the asynchronous write operation. - public virtual Task WriteUntypedValueAsync( + public async virtual Task WriteUntypedValueAsync( ODataUntypedValue value) { Debug.Assert(value != null, "value != null"); @@ -723,7 +723,7 @@ public virtual Task WriteUntypedValueAsync( throw new ODataException(ODataErrorStrings.ODataJsonLightValueSerializer_MissingRawValueOnUntyped); } - return this.JsonWriter.WriteRawValueAsync(value.RawValue); + await this.JsonWriter.WriteRawValueAsync(value.RawValue); } /// diff --git a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightWriter.cs b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightWriter.cs index af49416fc5..0c22989e20 100644 --- a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightWriter.cs +++ b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightWriter.cs @@ -1265,9 +1265,9 @@ protected override Task StartPayloadAsync() /// Asynchronously ends writing a payload (called exactly once after everything else in case of success) /// /// A task that represents the asynchronous write operation. - protected override Task EndPayloadAsync() + protected async override Task EndPayloadAsync() { - return this.jsonLightResourceSerializer.WritePayloadEndAsync(); + await this.jsonLightResourceSerializer.WritePayloadEndAsync(); } /// @@ -1739,13 +1739,13 @@ await this.jsonWriter.StartArrayScopeAsync() /// /// The resource set to write. /// A task that represents the asynchronous write operation. - protected override Task EndDeltaResourceSetAsync(ODataDeltaResourceSet deltaResourceSet) + protected async override Task EndDeltaResourceSetAsync(ODataDeltaResourceSet deltaResourceSet) { Debug.Assert(deltaResourceSet != null, "deltaResourceSet != null"); if (this.ParentNestedResourceInfo == null) { - return EndDeltaResourceSetInnerAsync(deltaResourceSet); + await EndDeltaResourceSetInnerAsync(deltaResourceSet); async Task EndDeltaResourceSetInnerAsync(ODataDeltaResourceSet innerDeltaResourceSet) { @@ -1774,7 +1774,7 @@ await this.jsonWriter.EndObjectScopeAsync() else { // End the array which holds the entries in the resource set. - return this.jsonWriter.EndArrayScopeAsync(); + await this.jsonWriter.EndArrayScopeAsync(); } } @@ -1857,15 +1857,15 @@ await this.WriteDeletedEntryContentsAsync(resource) /// /// The resource to write. /// A task that represents the asynchronous write operation. - protected override Task EndDeletedResourceAsync(ODataDeletedResource deletedResource) + protected async override Task EndDeletedResourceAsync(ODataDeletedResource deletedResource) { if (deletedResource == null) { - return TaskUtils.CompletedTask; + return; } // Close the object scope - return this.jsonWriter.EndObjectScopeAsync(); + await this.jsonWriter.EndObjectScopeAsync(); } /// @@ -1935,11 +1935,11 @@ await this.jsonWriter.FlushAsync() /// Asynchronously finish writing a stream value. /// /// A task that represents the asynchronous write operation. - protected sealed override Task EndBinaryStreamAsync() + protected async sealed override Task EndBinaryStreamAsync() { if (this.jsonWriter == null) { - return EndBinaryStreamInnerAsync(); + await EndBinaryStreamInnerAsync(); async Task EndBinaryStreamInnerAsync() { @@ -1953,7 +1953,7 @@ await this.jsonLightOutputContext.BinaryValueStream.FlushAsync() } else { - return this.jsonWriter.EndStreamValueScopeAsync(); + await this.jsonWriter.EndStreamValueScopeAsync(); } } @@ -1989,9 +1989,9 @@ await this.jsonWriter.FlushAsync() /// Asynchronously finish writing a text value. /// /// A task that represents the asynchronous write operation. - protected sealed override Task EndTextWriterAsync() + protected async sealed override Task EndTextWriterAsync() { - return this.jsonWriter.EndTextWriterValueScopeAsync(); + await this.jsonWriter.EndTextWriterValueScopeAsync(); } /// diff --git a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightWriterUtils.cs b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightWriterUtils.cs index b61fec0433..7f4ec880ec 100644 --- a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightWriterUtils.cs +++ b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightWriterUtils.cs @@ -60,7 +60,7 @@ internal static void WriteInstanceAnnotationName(this IJsonWriter jsonWriter, st /// Writes the 'value' property name asynchronously. /// /// The JSON writer to write to. - internal static Task WriteValuePropertyNameAsync(this IJsonWriter jsonWriter) + internal static ValueTask WriteValuePropertyNameAsync(this IJsonWriter jsonWriter) { Debug.Assert(jsonWriter != null, "jsonWriter != null"); @@ -73,7 +73,7 @@ internal static Task WriteValuePropertyNameAsync(this IJsonWriter jsonWriter) /// The JSON writer to write to. /// The name of the property to annotate. /// The name of the annotation to write. - internal static Task WritePropertyAnnotationNameAsync(this IJsonWriter jsonWriter, string propertyName, string annotationName) + internal static ValueTask WritePropertyAnnotationNameAsync(this IJsonWriter jsonWriter, string propertyName, string annotationName) { Debug.Assert(jsonWriter != null, "jsonWriter != null"); Debug.Assert(!string.IsNullOrEmpty(propertyName), "!string.IsNullOrEmpty(propertyName)"); @@ -87,7 +87,7 @@ internal static Task WritePropertyAnnotationNameAsync(this IJsonWriter jsonWrite /// /// The JSON writer to write to. /// The name of the instance annotation to write. - internal static Task WriteInstanceAnnotationNameAsync(this IJsonWriter jsonWriter, string annotationName) + internal static ValueTask WriteInstanceAnnotationNameAsync(this IJsonWriter jsonWriter, string annotationName) { Debug.Assert(jsonWriter != null, "jsonWriter != null"); Debug.Assert(!string.IsNullOrEmpty(annotationName), "!string.IsNullOrEmpty(annotationName)"); diff --git a/src/Microsoft.OData.Core/JsonLight/ReorderingJsonReader.cs b/src/Microsoft.OData.Core/JsonLight/ReorderingJsonReader.cs index 9c932fbfbd..e434ea10bd 100644 --- a/src/Microsoft.OData.Core/JsonLight/ReorderingJsonReader.cs +++ b/src/Microsoft.OData.Core/JsonLight/ReorderingJsonReader.cs @@ -92,7 +92,7 @@ public override bool CanStream() /// The value of the TResult parameter contains a used to read a stream value. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1825:Avoid zero-length array allocations.", Justification = "")] - public override async Task CreateReadStreamAsync() + public override async ValueTask CreateReadStreamAsync() { Stream result; object value = null; @@ -129,7 +129,7 @@ await this.ReadAsync() /// A task that represents the asynchronous read operation. /// The value of the TResult parameter contains a for reading the text value. /// - public override async Task CreateTextReaderAsync() + public override async ValueTask CreateTextReaderAsync() { if (this.NodeType == JsonNodeType.Property) { @@ -155,7 +155,7 @@ await this.ReadAsync() /// A task that represents the asynchronous operation. /// The value of the TResult parameter contains true if the current value can be streamed; otherwise false. /// - public override async Task CanStreamAsync() + public override async ValueTask CanStreamAsync() { object value = await this.GetValueAsync() .ConfigureAwait(false); diff --git a/src/Microsoft.OData.Core/Microsoft.OData.Core.csproj b/src/Microsoft.OData.Core/Microsoft.OData.Core.csproj index 4073ef8b23..6c5afa36ec 100644 --- a/src/Microsoft.OData.Core/Microsoft.OData.Core.csproj +++ b/src/Microsoft.OData.Core/Microsoft.OData.Core.csproj @@ -1,7 +1,7 @@  - net8.0 + net8.0 Microsoft.OData.Core Microsoft.OData.Core diff --git a/src/Microsoft.OData.Core/MultipartMixed/ODataMultipartMixedBatchInputContext.cs b/src/Microsoft.OData.Core/MultipartMixed/ODataMultipartMixedBatchInputContext.cs index 29ec177de1..7b6b3c4d2f 100644 --- a/src/Microsoft.OData.Core/MultipartMixed/ODataMultipartMixedBatchInputContext.cs +++ b/src/Microsoft.OData.Core/MultipartMixed/ODataMultipartMixedBatchInputContext.cs @@ -63,10 +63,11 @@ internal override ODataBatchReader CreateBatchReader() /// Asynchronously create a . /// /// Task which when completed returns the newly created . - internal override Task CreateBatchReaderAsync() + internal async override ValueTask CreateBatchReaderAsync() { // Note that the reading is actually synchronous since we buffer the entire input when getting the stream from the message. - return TaskUtils.GetTaskForSynchronousOperation(() => this.CreateBatchReaderImplementation(/*synchronous*/ false)); + ODataBatchReader reader = await TaskUtils.GetTaskForSynchronousOperation(() => this.CreateBatchReaderImplementation(/*synchronous*/ false)); + return reader; } /// diff --git a/src/Microsoft.OData.Core/MultipartMixed/ODataMultipartMixedBatchOutputContext.cs b/src/Microsoft.OData.Core/MultipartMixed/ODataMultipartMixedBatchOutputContext.cs index 751ea5ae9e..f24c09963d 100644 --- a/src/Microsoft.OData.Core/MultipartMixed/ODataMultipartMixedBatchOutputContext.cs +++ b/src/Microsoft.OData.Core/MultipartMixed/ODataMultipartMixedBatchOutputContext.cs @@ -56,13 +56,15 @@ internal override ODataBatchWriter CreateODataBatchWriter() /// A running task for the created batch writer. /// We don't plan to make this public! /// The write must flush the output when it's finished (inside the last Write call). - internal override Task CreateODataBatchWriterAsync() + internal async override ValueTask CreateODataBatchWriterAsync() { this.AssertAsynchronous(); - return TaskUtils.GetTaskForSynchronousOperation( + ODataBatchWriter writer = await TaskUtils.GetTaskForSynchronousOperation( thisParam => thisParam.CreateODataBatchWriterImplementation(), this); + + return writer; } /// diff --git a/src/Microsoft.OData.Core/ODataDeltaWriter.cs b/src/Microsoft.OData.Core/ODataDeltaWriter.cs index 38891241ca..fe871b66f4 100644 --- a/src/Microsoft.OData.Core/ODataDeltaWriter.cs +++ b/src/Microsoft.OData.Core/ODataDeltaWriter.cs @@ -27,7 +27,7 @@ public abstract class ODataDeltaWriter /// /// Delta resource set/collection to write. /// A task instance that represents the asynchronous write operation. - public abstract Task WriteStartAsync(ODataDeltaResourceSet deltaResourceSet); + public abstract ValueTask WriteStartAsync(ODataDeltaResourceSet deltaResourceSet); /// /// Finish writing a delta resource set. @@ -38,7 +38,7 @@ public abstract class ODataDeltaWriter /// Asynchronously finish writing a delta resource set. /// /// A task instance that represents the asynchronous write operation. - public abstract Task WriteEndAsync(); + public abstract ValueTask WriteEndAsync(); /// /// Start writing a nested resource info. @@ -51,7 +51,7 @@ public abstract class ODataDeltaWriter /// /// The nested resource info to write. /// A task instance that represents the asynchronous write operation. - public abstract Task WriteStartAsync(ODataNestedResourceInfo nestedResourceInfo); + public abstract ValueTask WriteStartAsync(ODataNestedResourceInfo nestedResourceInfo); /// /// Start writing an expanded resource set. @@ -64,7 +64,7 @@ public abstract class ODataDeltaWriter /// /// The expanded resource set to write. /// A task instance that represents the asynchronous write operation. - public abstract Task WriteStartAsync(ODataResourceSet expandedResourceSet); + public abstract ValueTask WriteStartAsync(ODataResourceSet expandedResourceSet); /// /// Start writing a delta resource. @@ -77,7 +77,7 @@ public abstract class ODataDeltaWriter /// /// The delta resource to write. /// A task instance that represents the asynchronous write operation. - public abstract Task WriteStartAsync(ODataResource deltaResource); + public abstract ValueTask WriteStartAsync(ODataResource deltaResource); /// @@ -91,7 +91,7 @@ public abstract class ODataDeltaWriter /// /// The delta deleted resource to write. /// A task instance that represents the asynchronous write operation. - public abstract Task WriteDeltaDeletedEntryAsync(ODataDeltaDeletedEntry deltaDeletedEntry); + public abstract ValueTask WriteDeltaDeletedEntryAsync(ODataDeltaDeletedEntry deltaDeletedEntry); /// /// Writing a delta link. @@ -104,7 +104,7 @@ public abstract class ODataDeltaWriter /// /// The delta link to write. /// A task instance that represents the asynchronous write operation. - public abstract Task WriteDeltaLinkAsync(ODataDeltaLink deltaLink); + public abstract ValueTask WriteDeltaLinkAsync(ODataDeltaLink deltaLink); /// /// Writing a delta deleted link. @@ -117,7 +117,7 @@ public abstract class ODataDeltaWriter /// /// The delta deleted link to write. /// A task instance that represents the asynchronous write operation. - public abstract Task WriteDeltaDeletedLinkAsync(ODataDeltaDeletedLink deltaDeletedLink); + public abstract ValueTask WriteDeltaDeletedLinkAsync(ODataDeltaDeletedLink deltaDeletedLink); /// /// Flushes the write buffer to the underlying stream. diff --git a/src/Microsoft.OData.Core/ODataInputContext.cs b/src/Microsoft.OData.Core/ODataInputContext.cs index 8ed1fc6b6a..4fa1a5d497 100644 --- a/src/Microsoft.OData.Core/ODataInputContext.cs +++ b/src/Microsoft.OData.Core/ODataInputContext.cs @@ -193,7 +193,7 @@ public virtual ODataReader CreateResourceSetReader(IEdmEntitySetBase entitySet, /// The entity set we are going to read resources for. /// The expected structured type for the items in the resource set. /// Task which when completed returns the newly created . - public virtual Task CreateResourceSetReaderAsync(IEdmEntitySetBase entitySet, IEdmStructuredType expectedResourceType) + public virtual ValueTask CreateResourceSetReaderAsync(IEdmEntitySetBase entitySet, IEdmStructuredType expectedResourceType) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.ResourceSet); } @@ -215,7 +215,7 @@ public virtual ODataReader CreateDeltaResourceSetReader(IEdmEntitySetBase entity /// The entity set we are going to read resources for. /// The expected structured type for the items in the resource set. /// Task which when completed returns the newly created . - public virtual Task CreateDeltaResourceSetReaderAsync(IEdmEntitySetBase entitySet, IEdmStructuredType expectedResourceType) + public virtual ValueTask CreateDeltaResourceSetReaderAsync(IEdmEntitySetBase entitySet, IEdmStructuredType expectedResourceType) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.ResourceSet); } @@ -237,7 +237,7 @@ public virtual ODataReader CreateResourceReader(IEdmNavigationSource navigationS /// The navigation source we are going to read resources for. /// The expected structured type for the resource to be read. /// Task which when completed returns the newly created . - public virtual Task CreateResourceReaderAsync(IEdmNavigationSource navigationSource, IEdmStructuredType expectedResourceType) + public virtual ValueTask CreateResourceReaderAsync(IEdmNavigationSource navigationSource, IEdmStructuredType expectedResourceType) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Resource); } @@ -257,7 +257,7 @@ public virtual ODataCollectionReader CreateCollectionReader(IEdmTypeReference ex /// /// The expected type reference for the items in the collection. /// Task which when completed returns the newly created . - public virtual Task CreateCollectionReaderAsync(IEdmTypeReference expectedItemTypeReference) + public virtual ValueTask CreateCollectionReaderAsync(IEdmTypeReference expectedItemTypeReference) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Collection); } @@ -281,7 +281,7 @@ public virtual ODataProperty ReadProperty(IEdmStructuralProperty edmStructuralPr /// The producing the property to be read. /// The expected type reference of the property to read. /// Task which when completed returns an representing the read property. - public virtual Task ReadPropertyAsync(IEdmStructuralProperty edmStructuralProperty, IEdmTypeReference expectedPropertyTypeReference) + public virtual ValueTask ReadPropertyAsync(IEdmStructuralProperty edmStructuralProperty, IEdmTypeReference expectedPropertyTypeReference) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Property); } @@ -299,7 +299,7 @@ public virtual ODataError ReadError() /// Asynchronously read a top-level error. /// /// Task which when completed returns an representing the read error. - public virtual Task ReadErrorAsync() + public virtual ValueTask ReadErrorAsync() { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Error); } @@ -321,7 +321,7 @@ public virtual ODataReader CreateUriParameterResourceReader(IEdmNavigationSource /// The navigation source we are going to read resources for. /// The expected structured type for the resource to be read. /// Task which when completed returns the newly created . - public virtual Task CreateUriParameterResourceReaderAsync(IEdmNavigationSource navigationSource, IEdmStructuredType expectedResourceType) + public virtual ValueTask CreateUriParameterResourceReaderAsync(IEdmNavigationSource navigationSource, IEdmStructuredType expectedResourceType) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Parameter); } @@ -343,7 +343,7 @@ public virtual ODataReader CreateUriParameterResourceSetReader(IEdmEntitySetBase /// The entity set we are going to read resources for. /// The expected structured type for the items in the resource set. /// Task which when completed returns the newly created . - public virtual Task CreateUriParameterResourceSetReaderAsync(IEdmEntitySetBase entitySet, IEdmStructuredType expectedResourceType) + public virtual ValueTask CreateUriParameterResourceSetReaderAsync(IEdmEntitySetBase entitySet, IEdmStructuredType expectedResourceType) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.ResourceSet); } @@ -363,7 +363,7 @@ public virtual ODataParameterReader CreateParameterReader(IEdmOperation operatio /// /// The operation whose parameters are being read. /// Task which when completed returns the newly created . - public virtual Task CreateParameterReaderAsync(IEdmOperation operation) + public virtual ValueTask CreateParameterReaderAsync(IEdmOperation operation) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Parameter); } @@ -381,7 +381,7 @@ internal virtual ODataAsynchronousReader CreateAsynchronousReader() /// Asynchronously create an . /// /// Task which when completed returns the newly created . - internal virtual Task CreateAsynchronousReaderAsync() + internal virtual ValueTask CreateAsynchronousReaderAsync() { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Asynchronous); } @@ -403,7 +403,7 @@ internal virtual ODataDeltaReader CreateDeltaReader(IEdmEntitySetBase entitySet, /// The entity set we are going to read entities for. /// The expected base entity type for the entries in the delta response. /// Task which when completed returns the newly created . - internal virtual Task CreateDeltaReaderAsync(IEdmEntitySetBase entitySet, IEdmEntityType expectedBaseEntityType) + internal virtual ValueTask CreateDeltaReaderAsync(IEdmEntitySetBase entitySet, IEdmEntityType expectedBaseEntityType) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.ResourceSet); } @@ -427,7 +427,7 @@ internal virtual ODataBatchReader CreateBatchReader() /// /// Since we don't want to support batch format extensibility (at least not yet) this method should remain internal. /// - internal virtual Task CreateBatchReaderAsync() + internal virtual ValueTask CreateBatchReaderAsync() { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Batch); } @@ -449,7 +449,7 @@ internal virtual ODataServiceDocument ReadServiceDocument() /// an that represents the read service document. /// /// Task which when completed returns an representing the read service document. - internal virtual Task ReadServiceDocumentAsync() + internal virtual ValueTask ReadServiceDocumentAsync() { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.ServiceDocument); } @@ -502,7 +502,7 @@ internal virtual ODataEntityReferenceLinks ReadEntityReferenceLinks() /// Asynchronously read a set of top-level entity reference links. /// /// Task which when completed returns an representing the read links. - internal virtual Task ReadEntityReferenceLinksAsync() + internal virtual ValueTask ReadEntityReferenceLinksAsync() { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.EntityReferenceLinks); } @@ -520,7 +520,7 @@ internal virtual ODataEntityReferenceLink ReadEntityReferenceLink() /// Asynchronously read a top-level entity reference link. /// /// Task which when completed returns an representing the read entity reference link. - internal virtual Task ReadEntityReferenceLinkAsync() + internal virtual ValueTask ReadEntityReferenceLinkAsync() { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.EntityReferenceLink); } @@ -540,7 +540,7 @@ internal virtual object ReadValue(IEdmPrimitiveTypeReference expectedPrimitiveTy /// /// The expected type reference for the value to be read; null if no expected type is available. /// Task which when completed returns an representing the read value. - internal virtual Task ReadValueAsync(IEdmPrimitiveTypeReference expectedPrimitiveTypeReference) + internal virtual ValueTask ReadValueAsync(IEdmPrimitiveTypeReference expectedPrimitiveTypeReference) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Value); } diff --git a/src/Microsoft.OData.Core/ODataMessageReader.cs b/src/Microsoft.OData.Core/ODataMessageReader.cs index 5b66f67bdb..a9bcfef962 100644 --- a/src/Microsoft.OData.Core/ODataMessageReader.cs +++ b/src/Microsoft.OData.Core/ODataMessageReader.cs @@ -256,19 +256,19 @@ public IEnumerable DetectPayloadKind() /// will always at most return a single result per payload kind. /// [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "Need to a return a task of an enumerable.")] - public Task> DetectPayloadKindAsync() + public async ValueTask> DetectPayloadKindAsync() { IEnumerable payloadKindsFromContentType; if (this.TryGetSinglePayloadKindResultFromContentType(out payloadKindsFromContentType)) { - return Task.FromResult(payloadKindsFromContentType); + return payloadKindsFromContentType; } // Otherwise we have to do sniffing List detectedPayloadKinds = new List(); // NOTE: this relies on the lazy eval of the enumerator - return Task.Factory.Iterate(this.GetPayloadKindDetectionTasks(payloadKindsFromContentType, detectedPayloadKinds)) + IEnumerable results = await Task.Factory.Iterate(this.GetPayloadKindDetectionTasks(payloadKindsFromContentType, detectedPayloadKinds)) .FollowAlwaysWith( t => { @@ -284,6 +284,8 @@ public Task> DetectPayloadKindAsync return (IEnumerable)detectedPayloadKinds; }); + + return results; } /// Creates an to read an async response. @@ -298,12 +300,17 @@ public ODataAsynchronousReader CreateODataAsynchronousReader() /// Asynchronously creates an to read an async response. /// A running task for the created async reader. - public Task CreateODataAsynchronousReaderAsync() + public async ValueTask CreateODataAsynchronousReaderAsync() { this.VerifyCanCreateODataAsynchronousReader(); - return this.ReadFromInputAsync( - (context) => context.CreateAsynchronousReaderAsync(), + ODataAsynchronousReader reader = await this.ReadFromInputAsync( + (context) => + { + return context.CreateAsynchronousReaderAsync(); + }, ODataPayloadKind.Asynchronous); + + return reader; } /// Creates an to read a resource set. @@ -340,7 +347,7 @@ public ODataReader CreateODataResourceSetReader(IEdmEntitySetBase entitySet, IEd /// Asynchronously creates an to read a resource set. /// A running task for the created reader. - public Task CreateODataResourceSetReaderAsync() + public ValueTask CreateODataResourceSetReaderAsync() { return this.CreateODataResourceSetReaderAsync(/*entitySet*/null, /*entityType*/null); } @@ -350,7 +357,7 @@ public Task CreateODataResourceSetReaderAsync() /// /// The expected type for the items in the resource set. /// A running task for the created reader. - public Task CreateODataResourceSetReaderAsync(IEdmStructuredType expectedResourceType) + public ValueTask CreateODataResourceSetReaderAsync(IEdmStructuredType expectedResourceType) { return this.CreateODataResourceSetReaderAsync(/*entitySet*/null, expectedResourceType); } @@ -361,13 +368,18 @@ public Task CreateODataResourceSetReaderAsync(IEdmStructuredType ex /// The entity set we are going to read entities for. /// The expected type for the items in the resource set. /// A running task for the created reader. - public Task CreateODataResourceSetReaderAsync(IEdmEntitySetBase entitySet, IEdmStructuredType expectedResourceType) + public async ValueTask CreateODataResourceSetReaderAsync(IEdmEntitySetBase entitySet, IEdmStructuredType expectedResourceType) { this.VerifyCanCreateODataResourceSetReader(entitySet, expectedResourceType); expectedResourceType = expectedResourceType ?? this.edmTypeResolver.GetElementType(entitySet); - return this.ReadFromInputAsync( - (context) => context.CreateResourceSetReaderAsync(entitySet, expectedResourceType), + ODataReader reader = await this.ReadFromInputAsync( + (context) => + { + return context.CreateResourceSetReaderAsync(entitySet, expectedResourceType); + }, ODataPayloadKind.ResourceSet); + + return reader; } /// Creates an to read a delta resource set. @@ -404,7 +416,7 @@ public ODataReader CreateODataDeltaResourceSetReader(IEdmEntitySetBase entitySet /// Asynchronously creates an to read a delta resource set. /// A running task for the created reader. - public Task CreateODataDeltaResourceSetReaderAsync() + public ValueTask CreateODataDeltaResourceSetReaderAsync() { return this.CreateODataDeltaResourceSetReaderAsync(/*entitySet*/null, /*entityType*/null); } @@ -414,7 +426,7 @@ public Task CreateODataDeltaResourceSetReaderAsync() /// /// The expected type for the items in the resource set. /// A running task for the created reader. - public Task CreateODataDeltaResourceSetReaderAsync(IEdmStructuredType expectedResourceType) + public ValueTask CreateODataDeltaResourceSetReaderAsync(IEdmStructuredType expectedResourceType) { return this.CreateODataDeltaResourceSetReaderAsync(/*entitySet*/null, expectedResourceType); } @@ -425,13 +437,18 @@ public Task CreateODataDeltaResourceSetReaderAsync(IEdmStructuredTy /// The entity set we are going to read entities for. /// The expected type for the items in the resource set. /// A running task for the created reader. - public Task CreateODataDeltaResourceSetReaderAsync(IEdmEntitySetBase entitySet, IEdmStructuredType expectedResourceType) + public async ValueTask CreateODataDeltaResourceSetReaderAsync(IEdmEntitySetBase entitySet, IEdmStructuredType expectedResourceType) { this.VerifyCanCreateODataResourceSetReader(entitySet, expectedResourceType); expectedResourceType = expectedResourceType ?? this.edmTypeResolver.GetElementType(entitySet); - return this.ReadFromInputAsync( - (context) => context.CreateDeltaResourceSetReaderAsync(entitySet, expectedResourceType), + ODataReader reader = await this.ReadFromInputAsync( + (context) => + { + return context.CreateDeltaResourceSetReaderAsync(entitySet, expectedResourceType); + }, ODataPayloadKind.Delta); + + return reader; } /// Creates an to read a resource. @@ -468,7 +485,7 @@ public ODataReader CreateODataResourceReader(IEdmNavigationSource navigationSour /// Asynchronously creates an to read a resource. /// A running task for the created reader. - public Task CreateODataResourceReaderAsync() + public ValueTask CreateODataResourceReaderAsync() { return this.CreateODataResourceReaderAsync(/*entitySet*/null, /*entityType*/null); } @@ -478,7 +495,7 @@ public Task CreateODataResourceReaderAsync() /// /// The expected structured type for the resource to be read. /// A running task for the created reader. - public Task CreateODataResourceReaderAsync(IEdmStructuredType resourceType) + public ValueTask CreateODataResourceReaderAsync(IEdmStructuredType resourceType) { return this.CreateODataResourceReaderAsync(/*entitySet*/null, resourceType); } @@ -489,13 +506,18 @@ public Task CreateODataResourceReaderAsync(IEdmStructuredType resou /// The navigation source we are going to read resources for. /// The expected structured type for the resource to be read. /// A running task for the created reader. - public Task CreateODataResourceReaderAsync(IEdmNavigationSource navigationSource, IEdmStructuredType resourceType) + public async ValueTask CreateODataResourceReaderAsync(IEdmNavigationSource navigationSource, IEdmStructuredType resourceType) { this.VerifyCanCreateODataResourceReader(navigationSource, resourceType); resourceType = resourceType ?? this.edmTypeResolver.GetElementType(navigationSource); - return this.ReadFromInputAsync( - (context) => context.CreateResourceReaderAsync(navigationSource, resourceType), + ODataReader reader = await this.ReadFromInputAsync( + (context) => + { + return context.CreateResourceReaderAsync(navigationSource, resourceType); + }, ODataPayloadKind.Resource); + + return reader; } /// Creates an to read a collection of primitive or complex values (as result of a service operation invocation). @@ -520,7 +542,7 @@ public ODataCollectionReader CreateODataCollectionReader(IEdmTypeReference expec /// Asynchronously creates an to read a collection of primitive or complex values (as result of a service operation invocation). /// A running task for the created collection reader. - public Task CreateODataCollectionReaderAsync() + public ValueTask CreateODataCollectionReaderAsync() { return this.CreateODataCollectionReaderAsync(null /*expectedItemTypeReference*/); } @@ -530,12 +552,14 @@ public Task CreateODataCollectionReaderAsync() /// /// The expected type reference for the items in the collection. /// A running task for the created collection reader. - public Task CreateODataCollectionReaderAsync(IEdmTypeReference expectedItemTypeReference) + public async ValueTask CreateODataCollectionReaderAsync(IEdmTypeReference expectedItemTypeReference) { this.VerifyCanCreateODataCollectionReader(expectedItemTypeReference); - return this.ReadFromInputAsync( + ODataCollectionReader reader = await this.ReadFromInputAsync( (context) => context.CreateCollectionReaderAsync(expectedItemTypeReference), ODataPayloadKind.Collection); + + return reader; } @@ -551,12 +575,14 @@ public ODataBatchReader CreateODataBatchReader() /// Asynchronously creates an to read a batch of requests or responses. /// A running task for the created batch reader. - public Task CreateODataBatchReaderAsync() + public async ValueTask CreateODataBatchReaderAsync() { this.VerifyCanCreateODataBatchReader(); - return this.ReadFromInputAsync( + ODataBatchReader reader = await this.ReadFromInputAsync( (context) => context.CreateBatchReaderAsync(), ODataPayloadKind.Batch); + + return reader; } /// @@ -580,13 +606,15 @@ public ODataReader CreateODataUriParameterResourceReader(IEdmNavigationSource na /// The navigation source we are going to read resources for. /// The expected structured type for the resource to be read. /// A running task for the created reader. - public Task CreateODataUriParameterResourceReaderAsync(IEdmNavigationSource navigationSource, IEdmStructuredType expectedResourceType) + public async ValueTask CreateODataUriParameterResourceReaderAsync(IEdmNavigationSource navigationSource, IEdmStructuredType expectedResourceType) { this.VerifyCanCreateODataResourceReader(navigationSource, expectedResourceType); expectedResourceType = expectedResourceType ?? this.edmTypeResolver.GetElementType(navigationSource); - return this.ReadFromInputAsync( + ODataReader reader = await this.ReadFromInputAsync( (context) => context.CreateUriParameterResourceReaderAsync(navigationSource, expectedResourceType), ODataPayloadKind.Resource); + + return reader; } /// @@ -610,13 +638,15 @@ public ODataReader CreateODataUriParameterResourceSetReader(IEdmEntitySetBase en /// The entity set we are going to read entities for. /// The expected type for the items in the resource set. /// A running task for the created reader. - public Task CreateODataUriParameterResourceSetReaderAsync(IEdmEntitySetBase entitySet, IEdmStructuredType expectedResourceType) + public async ValueTask CreateODataUriParameterResourceSetReaderAsync(IEdmEntitySetBase entitySet, IEdmStructuredType expectedResourceType) { this.VerifyCanCreateODataResourceSetReader(entitySet, expectedResourceType); expectedResourceType = expectedResourceType ?? this.edmTypeResolver.GetElementType(entitySet); - return this.ReadFromInputAsync( + ODataReader reader = await this.ReadFromInputAsync( (context) => context.CreateUriParameterResourceSetReaderAsync(entitySet, expectedResourceType), ODataPayloadKind.ResourceSet); + + return reader; } /// @@ -637,12 +667,14 @@ public ODataParameterReader CreateODataParameterReader(IEdmOperation operation) /// /// The operation whose parameters are being read. /// A running task for the created parameter reader. - public Task CreateODataParameterReaderAsync(IEdmOperation operation) + public async ValueTask CreateODataParameterReaderAsync(IEdmOperation operation) { this.VerifyCanCreateODataParameterReader(operation); - return this.ReadFromInputAsync( + ODataParameterReader reader = await this.ReadFromInputAsync( (context) => context.CreateParameterReaderAsync(operation), ODataPayloadKind.Parameter); + + return reader; } /// Reads a service document payload. @@ -657,12 +689,14 @@ public ODataServiceDocument ReadServiceDocument() /// Asynchronously reads a service document payload. /// A task representing the asynchronous operation of reading the service document. - public Task ReadServiceDocumentAsync() + public async ValueTask ReadServiceDocumentAsync() { this.VerifyCanReadServiceDocument(); - return this.ReadFromInputAsync( + ODataServiceDocument document = await this.ReadFromInputAsync( (context) => context.ReadServiceDocumentAsync(), ODataPayloadKind.ServiceDocument); + + return document; } /// Reads an as message payload. @@ -701,7 +735,7 @@ public ODataProperty ReadProperty(IEdmStructuralProperty property) /// Asynchronously reads an as message payload. /// A task representing the asynchronous operation of reading the property. - public Task ReadPropertyAsync() + public ValueTask ReadPropertyAsync() { return this.ReadPropertyAsync((IEdmTypeReference)null); } @@ -711,12 +745,14 @@ public Task ReadPropertyAsync() /// /// The expected type reference of the property to read. /// A task representing the asynchronous operation of reading the property. - public Task ReadPropertyAsync(IEdmTypeReference expectedPropertyTypeReference) + public async ValueTask ReadPropertyAsync(IEdmTypeReference expectedPropertyTypeReference) { this.VerifyCanReadProperty(expectedPropertyTypeReference); - return this.ReadFromInputAsync( + ODataProperty odataProperty = await this.ReadFromInputAsync( (context) => context.ReadPropertyAsync(/*propertyOrFunctionImport*/null, expectedPropertyTypeReference), ODataPayloadKind.Property); + + return odataProperty; } /// @@ -724,12 +760,14 @@ public Task ReadPropertyAsync(IEdmTypeReference expectedPropertyT /// /// The metadata of the property to read. /// A task representing the asynchronous operation of reading the property. - public Task ReadPropertyAsync(IEdmStructuralProperty property) + public async ValueTask ReadPropertyAsync(IEdmStructuralProperty property) { this.VerifyCanReadProperty(property); - return this.ReadFromInputAsync( + ODataProperty odataProperty = await this.ReadFromInputAsync( (context) => context.ReadPropertyAsync(property, property.Type), ODataPayloadKind.Property); + + return odataProperty; } @@ -746,12 +784,14 @@ public ODataError ReadError() /// Asynchronously reads an as the message payload. /// A task representing the asynchronous operation of reading the error. - public Task ReadErrorAsync() + public async ValueTask ReadErrorAsync() { this.VerifyCanReadError(); - return this.ReadFromInputAsync( + ODataError odataError = await this.ReadFromInputAsync( (context) => context.ReadErrorAsync(), ODataPayloadKind.Error); + + return odataError; } /// Reads the result of a $ref query (entity reference links) as the message payload. @@ -767,12 +807,14 @@ public ODataEntityReferenceLinks ReadEntityReferenceLinks() /// Asynchronously reads the result of a $ref query as the message payload. /// A task representing the asynchronous reading of the entity reference links. - public Task ReadEntityReferenceLinksAsync() + public async ValueTask ReadEntityReferenceLinksAsync() { this.VerifyCanReadEntityReferenceLinks(); - return this.ReadFromInputAsync( + ODataEntityReferenceLinks links = await this.ReadFromInputAsync( (context) => context.ReadEntityReferenceLinksAsync(), ODataPayloadKind.EntityReferenceLinks); + + return links; } /// Reads a singleton result of a $ref query (entity reference link) as the message payload. @@ -788,12 +830,14 @@ public ODataEntityReferenceLink ReadEntityReferenceLink() /// Asynchronously reads a singleton result of a $ref query (entity reference link) as the message payload. /// A running task representing the reading of the entity reference link. - public Task ReadEntityReferenceLinkAsync() + public async ValueTask ReadEntityReferenceLinkAsync() { this.VerifyCanReadEntityReferenceLink(); - return this.ReadFromInputAsync( + ODataEntityReferenceLink link = await this.ReadFromInputAsync( (context) => context.ReadEntityReferenceLinkAsync(), ODataPayloadKind.EntityReferenceLink); + + return link; } /// @@ -816,13 +860,15 @@ public object ReadValue(IEdmTypeReference expectedTypeReference) /// /// The expected type reference for the value to be read; null if no expected type is available. /// A running task representing the reading of the value. - public Task ReadValueAsync(IEdmTypeReference expectedTypeReference) + public async ValueTask ReadValueAsync(IEdmTypeReference expectedTypeReference) { ODataPayloadKind[] supportedPayloadKinds = this.VerifyCanReadValue(expectedTypeReference); - return this.ReadFromInputAsync( + object value = await this.ReadFromInputAsync( (context) => context.ReadValueAsync((IEdmPrimitiveTypeReference)expectedTypeReference), supportedPayloadKinds); + + return value; } /// Reads the message body as metadata document. It can read JSON/XML CSDL based on the content type. @@ -1457,5 +1503,25 @@ private Task ReadFromInputAsync(Func> readFunc, return readFunc(this.inputContext); }); } + + [Obsolete("Temporary method. Delete later.")] + private Task ReadFromInputAsync(Func> readFunc, params ODataPayloadKind[] payloadKinds) where T : class + { + this.ProcessContentType(payloadKinds); + Debug.Assert(this.format != null, "By now we should have figured out which format to use."); + + return this.message.GetStreamAsync() + .FollowOnSuccessWithTask( + streamTask => this.format.CreateInputContextAsync( + this.GetOrCreateMessageInfo(streamTask.Result, true), + this.settings)) + .FollowOnSuccessWithTask( + async createInputContextTask => + { + this.inputContext = createInputContextTask.Result; + var result = await readFunc(this.inputContext); + return result; + }); + } } } diff --git a/src/Microsoft.OData.Core/ODataMessageWriter.cs b/src/Microsoft.OData.Core/ODataMessageWriter.cs index aa3ade2f22..8741e90550 100644 --- a/src/Microsoft.OData.Core/ODataMessageWriter.cs +++ b/src/Microsoft.OData.Core/ODataMessageWriter.cs @@ -218,7 +218,7 @@ public ODataWriter CreateODataResourceSetWriter(IEdmEntitySetBase entitySet, IEd /// Asynchronously creates an to write an async response. /// A running task for the created writer. - public Task CreateODataAsynchronousWriterAsync() + public ValueTask CreateODataAsynchronousWriterAsync() { this.VerifyCanCreateODataAsyncWriter(); return this.WriteToOutputAsync( @@ -228,7 +228,7 @@ public Task CreateODataAsynchronousWriterAsync() /// Asynchronously creates an to write a resource set. /// A running task for the created writer. - public Task CreateODataResourceSetWriterAsync() + public ValueTask CreateODataResourceSetWriterAsync() { return CreateODataResourceSetWriterAsync(/*entitySet*/null, /*entityType*/null); } @@ -238,7 +238,7 @@ public Task CreateODataResourceSetWriterAsync() /// /// The entity set we are going to write entities for. /// A running task for the created writer. - public Task CreateODataResourceSetWriterAsync(IEdmEntitySetBase entitySet) + public ValueTask CreateODataResourceSetWriterAsync(IEdmEntitySetBase entitySet) { return CreateODataResourceSetWriterAsync(entitySet, /*entityType*/null); } @@ -249,7 +249,7 @@ public Task CreateODataResourceSetWriterAsync(IEdmEntitySetBase ent /// The entity set we are going to write entities for. /// The structured type for the entries in the resource set to be written (or null if the entity set base type should be used). /// A running task for the created writer. - public Task CreateODataResourceSetWriterAsync(IEdmEntitySetBase entitySet, IEdmStructuredType structuredType) + public ValueTask CreateODataResourceSetWriterAsync(IEdmEntitySetBase entitySet, IEdmStructuredType structuredType) { this.VerifyCanCreateODataResourceSetWriter(); return this.WriteToOutputAsync( @@ -290,7 +290,7 @@ public ODataWriter CreateODataDeltaResourceSetWriter(IEdmEntitySetBase entitySet /// Asynchronously creates an to write a delta resource set. /// A running task for the created writer. - public Task CreateODataDeltaResourceSetWriterAsync() + public ValueTask CreateODataDeltaResourceSetWriterAsync() { return CreateODataDeltaResourceSetWriterAsync(/*entitySet*/null, /*entityType*/null); } @@ -300,7 +300,7 @@ public Task CreateODataDeltaResourceSetWriterAsync() /// /// The entity set we are going to write entities for. /// A running task for the created writer. - public Task CreateODataDeltaResourceSetWriterAsync(IEdmEntitySetBase entitySet) + public ValueTask CreateODataDeltaResourceSetWriterAsync(IEdmEntitySetBase entitySet) { return CreateODataDeltaResourceSetWriterAsync(entitySet, /*entityType*/null); } @@ -311,12 +311,14 @@ public Task CreateODataDeltaResourceSetWriterAsync(IEdmEntitySetBas /// The entity set we are going to write entities for. /// The entity type for the entries in the resource set to be written (or null if the entity set base type should be used). /// A running task for the created writer. - public Task CreateODataDeltaResourceSetWriterAsync(IEdmEntitySetBase entitySet, IEdmEntityType entityType) + public async ValueTask CreateODataDeltaResourceSetWriterAsync(IEdmEntitySetBase entitySet, IEdmEntityType entityType) { this.VerifyCanCreateODataResourceSetWriter(); - return this.WriteToOutputAsync( + ODataWriter writer = await this.WriteToOutputAsync( ODataPayloadKind.ResourceSet, (context) => context.CreateODataDeltaResourceSetWriterAsync(entitySet, entityType)); + + return writer; } /// Creates an to write a resource. @@ -353,7 +355,7 @@ public ODataWriter CreateODataResourceWriter(IEdmNavigationSource navigationSour /// Asynchronously creates an to write a resource. /// A running task for the created writer. - public Task CreateODataResourceWriterAsync() + public ValueTask CreateODataResourceWriterAsync() { return CreateODataResourceWriterAsync(/*entitySet*/null, /*resourceType*/null); } @@ -363,7 +365,7 @@ public Task CreateODataResourceWriterAsync() /// /// The navigation source we are going to write entities for. /// A running task for the created writer. - public Task CreateODataResourceWriterAsync(IEdmNavigationSource navigationSource) + public ValueTask CreateODataResourceWriterAsync(IEdmNavigationSource navigationSource) { return CreateODataResourceWriterAsync(navigationSource, /*resourceType*/null); } @@ -374,7 +376,7 @@ public Task CreateODataResourceWriterAsync(IEdmNavigationSource nav /// The navigation source we are going to write resource set for. /// The structured type for the items in the resource set to be written (or null if the entity set base type should be used). /// A running task for the created writer. - public Task CreateODataResourceWriterAsync(IEdmNavigationSource navigationSource, IEdmStructuredType resourceType) + public ValueTask CreateODataResourceWriterAsync(IEdmNavigationSource navigationSource, IEdmStructuredType resourceType) { this.VerifyCanCreateODataResourceWriter(); return this.WriteToOutputAsync( @@ -402,7 +404,7 @@ public ODataWriter CreateODataUriParameterResourceWriter(IEdmNavigationSource na /// The navigation source we are going to write resource for. /// The structured type for the resources in the resource set to be written. /// A running task for the created uri parameter writer. - public Task CreateODataUriParameterResourceWriterAsync(IEdmNavigationSource navigationSource, IEdmStructuredType resourceType) + public ValueTask CreateODataUriParameterResourceWriterAsync(IEdmNavigationSource navigationSource, IEdmStructuredType resourceType) { this.VerifyCanCreateODataResourceWriter(); return this.WriteToOutputAsync( @@ -430,7 +432,7 @@ public ODataWriter CreateODataUriParameterResourceSetWriter(IEdmEntitySetBase en /// The resource set we are going to write resources for. /// The structured type for the resources in the resource set to be written. /// A running task for the created uri parameter writer. - public Task CreateODataUriParameterResourceSetWriterAsync(IEdmEntitySetBase entitySetBase, IEdmStructuredType resourceType) + public ValueTask CreateODataUriParameterResourceSetWriterAsync(IEdmEntitySetBase entitySetBase, IEdmStructuredType resourceType) { this.VerifyCanCreateODataResourceSetWriter(); return this.WriteToOutputAsync( @@ -460,7 +462,7 @@ public ODataCollectionWriter CreateODataCollectionWriter(IEdmTypeReference itemT /// Asynchronously creates an to write a collection of primitive or complex values (as result of a service operation invocation). /// A running task for the created collection writer. - public Task CreateODataCollectionWriterAsync() + public ValueTask CreateODataCollectionWriterAsync() { return this.CreateODataCollectionWriterAsync(null); } @@ -470,7 +472,7 @@ public Task CreateODataCollectionWriterAsync() /// /// The item type of the collection being written or null if no metadata is available. /// A running task for the created collection writer. - public Task CreateODataCollectionWriterAsync(IEdmTypeReference itemTypeReference) + public ValueTask CreateODataCollectionWriterAsync(IEdmTypeReference itemTypeReference) { this.VerifyCanCreateODataCollectionWriter(itemTypeReference); return this.WriteToOutputAsync( @@ -490,7 +492,7 @@ public ODataBatchWriter CreateODataBatchWriter() /// Asynchronously creates an to write a batch of requests or responses. /// A running task for the created batch writer. - public Task CreateODataBatchWriterAsync() + public ValueTask CreateODataBatchWriterAsync() { this.VerifyCanCreateODataBatchWriter(); return this.WriteToOutputAsync( @@ -516,7 +518,7 @@ public ODataParameterWriter CreateODataParameterWriter(IEdmOperation operation) /// /// The operation whose parameters will be written. /// A running task for the created parameter writer. - public Task CreateODataParameterWriterAsync(IEdmOperation operation) + public ValueTask CreateODataParameterWriterAsync(IEdmOperation operation) { this.VerifyCanCreateODataParameterWriter(operation); return this.WriteToOutputAsync( @@ -537,7 +539,7 @@ public void WriteServiceDocument(ODataServiceDocument serviceDocument) /// Asynchronously writes a service document with the specified as the message payload. /// A task representing the asynchronous operation of writing the service document. /// The service document to write. - public Task WriteServiceDocumentAsync(ODataServiceDocument serviceDocument) + public ValueTask WriteServiceDocumentAsync(ODataServiceDocument serviceDocument) { this.VerifyCanWriteServiceDocument(serviceDocument); return this.WriteToOutputAsync( @@ -558,7 +560,7 @@ public void WriteProperty(ODataProperty property) /// Asynchronously writes an as the message payload. /// A task representing the asynchronous operation of writing the property. /// The property to write - public Task WritePropertyAsync(ODataProperty property) + public ValueTask WritePropertyAsync(ODataProperty property) { this.VerifyCanWriteProperty(property); return this.WriteToOutputAsync( @@ -594,7 +596,7 @@ public void WriteError(ODataError error, bool includeDebugInformation) /// A task representing the asynchronous operation of writing the error. /// The error to write. /// A flag indicating whether debug information (for example, the inner error from the ) should be included in the payload. This should only be used in debug scenarios. - public Task WriteErrorAsync(ODataError error, bool includeDebugInformation) + public ValueTask WriteErrorAsync(ODataError error, bool includeDebugInformation) { // We currently assume that the error is top-level if no create/write method has been called on this message writer. // It is possible that the user would create a Json writer, but writes nothing to it before writes the first error. @@ -627,7 +629,7 @@ public void WriteEntityReferenceLinks(ODataEntityReferenceLinks links) /// Asynchronously writes the result of a $ref query as the message payload. /// A task representing the asynchronous writing of the entity reference links. /// The entity reference links to write as message payload. - public Task WriteEntityReferenceLinksAsync(ODataEntityReferenceLinks links) + public ValueTask WriteEntityReferenceLinksAsync(ODataEntityReferenceLinks links) { this.VerifyCanWriteEntityReferenceLinks(links); return this.WriteToOutputAsync( @@ -648,7 +650,7 @@ public void WriteEntityReferenceLink(ODataEntityReferenceLink link) /// Asynchronously writes a singleton result of a $ref query as the message payload. /// A running task representing the writing of the link. /// The link result to write as the message payload. - public Task WriteEntityReferenceLinkAsync(ODataEntityReferenceLink link) + public ValueTask WriteEntityReferenceLinkAsync(ODataEntityReferenceLink link) { this.VerifyCanWriteEntityReferenceLink(link); return this.WriteToOutputAsync( @@ -669,7 +671,7 @@ public void WriteValue(object value) /// Asynchronously writes a single value as the message body. /// A running task representing the writing of the value. /// The value to write. - public Task WriteValueAsync(object value) + public ValueTask WriteValueAsync(object value) { ODataPayloadKind payloadKind = this.VerifyCanWriteValue(value); return this.WriteToOutputAsync( @@ -690,7 +692,7 @@ public void WriteMetadataDocument() /// Asynchronously writes a metadata document as the message payload. /// /// A task representing the asynchronous operation of writing the metadata document. - public Task WriteMetadataDocumentAsync() + public ValueTask WriteMetadataDocumentAsync() { this.VerifyCanWriteMetadataDocument(); return this.WriteToOutputAsync( @@ -1291,7 +1293,7 @@ private TResult WriteToOutput(ODataPayloadKind payloadKind, FuncThe payload kind to write. /// The write operation to invoke on the output. /// Task which represents the pending write operation. - private async Task WriteToOutputAsync(ODataPayloadKind payloadKind, Func writeAsyncAction) + private async ValueTask WriteToOutputAsync(ODataPayloadKind payloadKind, Func writeAsyncAction) { // Set the content type header here since all headers have to be set before getting the stream this.SetOrVerifyHeaders(payloadKind); @@ -1311,7 +1313,7 @@ private async Task WriteToOutputAsync(ODataPayloadKind payloadKind, FuncThe payload kind to write. /// The write operation to invoke on the output. /// Task which represents the pending write operation. - private async Task WriteToOutputAsync(ODataPayloadKind payloadKind, Func> writeFunc) + private async ValueTask WriteToOutputAsync(ODataPayloadKind payloadKind, Func> writeFunc) { // Set the content type header here since all headers have to be set before getting the stream this.SetOrVerifyHeaders(payloadKind); diff --git a/src/Microsoft.OData.Core/ODataMetadataJsonOutputContext.cs b/src/Microsoft.OData.Core/ODataMetadataJsonOutputContext.cs index f5370f058a..c517720b5c 100644 --- a/src/Microsoft.OData.Core/ODataMetadataJsonOutputContext.cs +++ b/src/Microsoft.OData.Core/ODataMetadataJsonOutputContext.cs @@ -89,11 +89,11 @@ internal Task FlushAsync() /// /// A task representing the asynchronous operation of writing the metadata document. /// It is the responsibility of this method to flush the output before the task finishes. - internal override Task WriteMetadataDocumentAsync() + internal async override ValueTask WriteMetadataDocumentAsync() { this.AssertAsynchronous(); - return TaskUtils.GetTaskForSynchronousOperationReturningTask( + await TaskUtils.GetTaskForSynchronousOperationReturningTask( () => { this.WriteMetadataDocumentImplementation(); diff --git a/src/Microsoft.OData.Core/ODataMetadataOutputContext.cs b/src/Microsoft.OData.Core/ODataMetadataOutputContext.cs index ed7272ecc0..51f979c533 100644 --- a/src/Microsoft.OData.Core/ODataMetadataOutputContext.cs +++ b/src/Microsoft.OData.Core/ODataMetadataOutputContext.cs @@ -100,11 +100,11 @@ internal Task FlushAsync() /// be included in the payload. This should only be used in debug scenarios. /// /// Task which represents the pending write operation. - internal override Task WriteInStreamErrorAsync(ODataError error, bool includeDebugInformation) + internal async override ValueTask WriteInStreamErrorAsync(ODataError error, bool includeDebugInformation) { this.AssertAsynchronous(); - return TaskUtils.GetTaskForSynchronousOperationReturningTask( + await TaskUtils.GetTaskForSynchronousOperationReturningTask( () => { ODataMetadataWriterUtils.WriteError(this.xmlWriter, error, includeDebugInformation, this.MessageWriterSettings.MessageQuotas.MaxNestingDepth); @@ -117,11 +117,11 @@ internal override Task WriteInStreamErrorAsync(ODataError error, bool includeDeb /// /// A task representing the asynchronous operation of writing the metadata document. /// It is the responsibility of this method to flush the output before the task finishes. - internal override Task WriteMetadataDocumentAsync() + internal async override ValueTask WriteMetadataDocumentAsync() { this.AssertAsynchronous(); - return TaskUtils.GetTaskForSynchronousOperationReturningTask( + await TaskUtils.GetTaskForSynchronousOperationReturningTask( () => { this.WriteMetadataDocumentImplementation(); diff --git a/src/Microsoft.OData.Core/ODataOutputContext.cs b/src/Microsoft.OData.Core/ODataOutputContext.cs index 14ff0152a1..073eb24f8c 100644 --- a/src/Microsoft.OData.Core/ODataOutputContext.cs +++ b/src/Microsoft.OData.Core/ODataOutputContext.cs @@ -210,7 +210,7 @@ public virtual ODataWriter CreateODataResourceSetWriter(IEdmEntitySetBase entity /// The entity type for the entries in the resource set to be written (or null if the entity set base type should be used). /// A running task for the created writer. /// The write must flush the output when it's finished (inside the last Write call). - public virtual Task CreateODataResourceSetWriterAsync(IEdmEntitySetBase entitySet, IEdmStructuredType entityType) + public virtual ValueTask CreateODataResourceSetWriterAsync(IEdmEntitySetBase entitySet, IEdmStructuredType entityType) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.ResourceSet); } @@ -235,7 +235,7 @@ public virtual ODataWriter CreateODataDeltaResourceSetWriter(IEdmEntitySetBase e /// The entity type for the entries in the resource set to be written (or null if the entity set base type should be used). /// A running task for the created writer. /// The write must flush the output when it's finished (inside the last Write call). - public virtual Task CreateODataDeltaResourceSetWriterAsync(IEdmEntitySetBase entitySet, IEdmStructuredType entityType) + public virtual ValueTask CreateODataDeltaResourceSetWriterAsync(IEdmEntitySetBase entitySet, IEdmStructuredType entityType) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.ResourceSet); } @@ -260,7 +260,7 @@ public virtual ODataWriter CreateODataResourceWriter(IEdmNavigationSource naviga /// The structured type for the items in the resource set to be written (or null if the entity set base type should be used). /// A running task for the created writer. /// The write must flush the output when it's finished (inside the last Write call). - public virtual Task CreateODataResourceWriterAsync(IEdmNavigationSource navigationSource, IEdmStructuredType resourceType) + public virtual ValueTask CreateODataResourceWriterAsync(IEdmNavigationSource navigationSource, IEdmStructuredType resourceType) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Resource); } @@ -283,7 +283,7 @@ public virtual ODataCollectionWriter CreateODataCollectionWriter(IEdmTypeReferen /// The item type of the collection being written or null if no metadata is available. /// A running task for the created collection writer. /// The write must flush the output when it's finished (inside the last Write call). - public virtual Task CreateODataCollectionWriterAsync(IEdmTypeReference itemTypeReference) + public virtual ValueTask CreateODataCollectionWriterAsync(IEdmTypeReference itemTypeReference) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Collection); } @@ -308,7 +308,7 @@ public virtual ODataWriter CreateODataUriParameterResourceWriter(IEdmNavigationS /// The structured type for the items in the resource set to be written (or null if the entity set base type should be used). /// A running task for the created writer. /// The write must flush the output when it's finished (inside the last Write call). - public virtual Task CreateODataUriParameterResourceWriterAsync(IEdmNavigationSource navigationSource, IEdmStructuredType resourceType) + public virtual ValueTask CreateODataUriParameterResourceWriterAsync(IEdmNavigationSource navigationSource, IEdmStructuredType resourceType) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Resource); } @@ -333,7 +333,7 @@ public virtual ODataWriter CreateODataUriParameterResourceSetWriter(IEdmEntitySe /// The resource type for the items in the resource set to be written (or null if the entity set base type should be used). /// A running task for the created writer. /// The write must flush the output when it's finished (inside the last Write call). - public virtual Task CreateODataUriParameterResourceSetWriterAsync(IEdmEntitySetBase entitySet, IEdmStructuredType resourceType) + public virtual ValueTask CreateODataUriParameterResourceSetWriterAsync(IEdmEntitySetBase entitySet, IEdmStructuredType resourceType) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.ResourceSet); } @@ -356,7 +356,7 @@ public virtual ODataParameterWriter CreateODataParameterWriter(IEdmOperation ope /// The operation whose parameters will be written. /// A running task for the created parameter writer. /// The write must flush the output when it's finished (inside the last Write call). - public virtual Task CreateODataParameterWriterAsync(IEdmOperation operation) + public virtual ValueTask CreateODataParameterWriterAsync(IEdmOperation operation) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Error); } @@ -378,7 +378,7 @@ public virtual void WriteProperty(ODataProperty odataProperty) /// The OData property to write /// A task representing the asynchronous operation of writing the OData property. /// It is the responsibility of this method to flush the output before the task finishes. - public virtual Task WritePropertyAsync(ODataProperty odataProperty) + public virtual ValueTask WritePropertyAsync(ODataProperty odataProperty) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Property); } @@ -408,7 +408,7 @@ public virtual void WriteError(ODataError odataError, bool includeDebugInformati /// /// A task representing the asynchronous operation of writing the error. /// It is the responsibility of this method to flush the output before the task finishes. - public virtual Task WriteErrorAsync(ODataError odataError, bool includeDebugInformation) + public virtual ValueTask WriteErrorAsync(ODataError odataError, bool includeDebugInformation) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Error); } @@ -452,7 +452,7 @@ internal virtual void WriteInStreamError(ODataError error, bool includeDebugInfo /// the in-stream error is written. /// It is the responsibility of this method to flush the output before the task finishes. /// - internal virtual Task WriteInStreamErrorAsync(ODataError error, bool includeDebugInformation) + internal virtual ValueTask WriteInStreamErrorAsync(ODataError error, bool includeDebugInformation) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Error); } @@ -473,7 +473,7 @@ internal virtual ODataAsynchronousWriter CreateODataAsynchronousWriter() /// /// A running task for the created writer. /// The write must flush the output when it's finished (inside the last Write call). - internal virtual Task CreateODataAsynchronousWriterAsync() + internal virtual ValueTask CreateODataAsynchronousWriterAsync() { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Asynchronous); } @@ -498,7 +498,7 @@ internal virtual ODataDeltaWriter CreateODataDeltaWriter(IEdmEntitySetBase entit /// The entity type for the entries in the resource set to be written (or null if the entity set base type should be used). /// A running task for the created writer. /// The write must flush the output when it's finished (inside the last Write call). - internal virtual Task CreateODataDeltaWriterAsync(IEdmEntitySetBase entitySet, IEdmEntityType entityType) + internal virtual ValueTask CreateODataDeltaWriterAsync(IEdmEntitySetBase entitySet, IEdmEntityType entityType) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.ResourceSet); } @@ -527,7 +527,7 @@ internal virtual ODataBatchWriter CreateODataBatchWriter() /// The write must flush the output when it's finished (inside the last Write call). /// Since we don't want to support batch format extensibility (at least not yet) this method should remain internal. /// - internal virtual Task CreateODataBatchWriterAsync() + internal virtual ValueTask CreateODataBatchWriterAsync() { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Batch); } @@ -551,7 +551,7 @@ internal virtual void WriteServiceDocument(ODataServiceDocument serviceDocument) /// The service document to write in the service document. /// A task representing the asynchronous operation of writing the service document. /// It is the responsibility of this method to flush the output before the task finishes. - internal virtual Task WriteServiceDocumentAsync(ODataServiceDocument serviceDocument) + internal virtual ValueTask WriteServiceDocumentAsync(ODataServiceDocument serviceDocument) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.ServiceDocument); } @@ -573,7 +573,7 @@ internal virtual void WriteEntityReferenceLinks(ODataEntityReferenceLinks links) /// The entity reference links to write as message payload. /// A task representing the asynchronous writing of the entity reference links. /// It is the responsibility of this method to flush the output before the task finishes. - internal virtual Task WriteEntityReferenceLinksAsync(ODataEntityReferenceLinks links) + internal virtual ValueTask WriteEntityReferenceLinksAsync(ODataEntityReferenceLinks links) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.EntityReferenceLinks); } @@ -595,7 +595,7 @@ internal virtual void WriteEntityReferenceLink(ODataEntityReferenceLink link) /// The link result to write as message payload. /// A running task representing the writing of the link. /// It is the responsibility of this method to flush the output before the task finishes. - internal virtual Task WriteEntityReferenceLinkAsync(ODataEntityReferenceLink link) + internal virtual ValueTask WriteEntityReferenceLinkAsync(ODataEntityReferenceLink link) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.EntityReferenceLink); } @@ -617,7 +617,7 @@ internal virtual void WriteValue(object value) /// The value to write. /// A running task representing the writing of the value. /// It is the responsibility of this method to flush the output before the task finishes. - internal virtual Task WriteValueAsync(object value) + internal virtual ValueTask WriteValueAsync(object value) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Value); } @@ -636,7 +636,7 @@ internal virtual void WriteMetadataDocument() /// /// A task representing the asynchronous operation of writing the metadata document. /// It is the responsibility of this method to flush the output before the task finishes. - internal virtual Task WriteMetadataDocumentAsync() + internal virtual ValueTask WriteMetadataDocumentAsync() { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.MetadataDocument); } diff --git a/src/Microsoft.OData.Core/ODataRawInputContext.cs b/src/Microsoft.OData.Core/ODataRawInputContext.cs index bcae36f7c5..6707e7a0a4 100644 --- a/src/Microsoft.OData.Core/ODataRawInputContext.cs +++ b/src/Microsoft.OData.Core/ODataRawInputContext.cs @@ -94,10 +94,11 @@ internal override ODataAsynchronousReader CreateAsynchronousReader() /// Asynchronously create an . /// /// Task which when completed returns the newly created . - internal override Task CreateAsynchronousReaderAsync() + internal async override ValueTask CreateAsynchronousReaderAsync() { // Note that the reading is actually synchronous since we buffer the entire input when getting the stream from the message. - return TaskUtils.GetTaskForSynchronousOperation(() => this.CreateAsynchronousReaderImplementation()); + ODataAsynchronousReader reader = await TaskUtils.GetTaskForSynchronousOperation(() => this.CreateAsynchronousReaderImplementation()); + return reader; } /// @@ -115,9 +116,10 @@ internal override object ReadValue(IEdmPrimitiveTypeReference expectedPrimitiveT /// /// The expected type reference for the value to be read; null if no expected type is available. /// Task which when completed returns an representing the read value. - internal override Task ReadValueAsync(IEdmPrimitiveTypeReference expectedPrimitiveTypeReference) + internal async override ValueTask ReadValueAsync(IEdmPrimitiveTypeReference expectedPrimitiveTypeReference) { - return this.ReadValueImplementationAsync(expectedPrimitiveTypeReference); + object value = await this.ReadValueImplementationAsync(expectedPrimitiveTypeReference); + return value; } /// diff --git a/src/Microsoft.OData.Core/ODataRawOutputContext.cs b/src/Microsoft.OData.Core/ODataRawOutputContext.cs index be4ba3f99f..8b89070535 100644 --- a/src/Microsoft.OData.Core/ODataRawOutputContext.cs +++ b/src/Microsoft.OData.Core/ODataRawOutputContext.cs @@ -189,7 +189,7 @@ internal override void WriteInStreamError(ODataError error, bool includeDebugInf /// the in-stream error is written. /// It is the responsibility of this method to flush the output before the task finishes. /// - internal override async Task WriteInStreamErrorAsync(ODataError error, bool includeDebugInformation) + internal override async ValueTask WriteInStreamErrorAsync(ODataError error, bool includeDebugInformation) { if (this.outputInStreamErrorListener != null) { @@ -217,11 +217,12 @@ internal override ODataAsynchronousWriter CreateODataAsynchronousWriter() /// /// A running task for the created writer. /// The write must flush the output when it's finished (inside the last Write call). - internal override Task CreateODataAsynchronousWriterAsync() + internal async override ValueTask CreateODataAsynchronousWriterAsync() { this.AssertAsynchronous(); - return TaskUtils.GetTaskForSynchronousOperation(() => this.CreateODataAsynchronousWriterImplementation()); + ODataAsynchronousWriter writer = await TaskUtils.GetTaskForSynchronousOperation(() => this.CreateODataAsynchronousWriterImplementation()); + return writer; } /// @@ -243,7 +244,7 @@ internal override void WriteValue(object value) /// The value to write. /// A running task representing the writing of the value. /// It is the responsibility of this method to flush the output before the task finishes. - internal override async Task WriteValueAsync(object value) + internal override async ValueTask WriteValueAsync(object value) { this.AssertAsynchronous(); diff --git a/src/Microsoft.OData.Core/ODataTextStreamReader.cs b/src/Microsoft.OData.Core/ODataTextStreamReader.cs index d8aa82b535..dfea4af0c9 100644 --- a/src/Microsoft.OData.Core/ODataTextStreamReader.cs +++ b/src/Microsoft.OData.Core/ODataTextStreamReader.cs @@ -52,11 +52,12 @@ public override int Read(char[] buffer, int offset, int count) return this.reader(buffer, offset, count); } - public override Task ReadAsync(char[] buffer, int index, int count) + public async override Task ReadAsync(char[] buffer, int index, int count) { this.AssertAsynchronous(); - return this.asyncReader(buffer, index, count); + int value = await this.asyncReader(buffer, index, count); + return value; } /// diff --git a/src/Microsoft.OData.Core/ODataWriter.cs b/src/Microsoft.OData.Core/ODataWriter.cs index 053f7937cd..af311e5714 100644 --- a/src/Microsoft.OData.Core/ODataWriter.cs +++ b/src/Microsoft.OData.Core/ODataWriter.cs @@ -49,9 +49,9 @@ public ODataWriter Write(ODataResourceSet resourceSet, Action nestedAction) /// Asynchronously start writing a resource set. /// A task instance that represents the asynchronous write operation. /// The resource set or collection to write. - public virtual Task WriteStartAsync(ODataResourceSet resourceSet) + public virtual ValueTask WriteStartAsync(ODataResourceSet resourceSet) { - return TaskUtils.GetTaskForSynchronousOperation( + return TaskUtils.GetValueTaskForSynchronousOperation( (thisParam, resourceSetParam) => thisParam.WriteStart(resourceSetParam), this, resourceSet); @@ -90,9 +90,9 @@ public ODataWriter Write(ODataDeltaResourceSet deltaResourceSet, Action nestedAc /// Asynchronously start writing a resource set. /// A task instance that represents the asynchronous write operation. /// The resource set or collection to write. - public virtual Task WriteStartAsync(ODataDeltaResourceSet deltaResourceSet) + public virtual ValueTask WriteStartAsync(ODataDeltaResourceSet deltaResourceSet) { - return TaskUtils.GetTaskForSynchronousOperation( + return TaskUtils.GetValueTaskForSynchronousOperation( (thisParam, deltaResourceSetParam) => thisParam.WriteStart(deltaResourceSetParam), this, deltaResourceSet); @@ -168,9 +168,9 @@ public ODataWriter Write(ODataDeltaDeletedLink deltaDeletedLink) /// Asynchronously start writing a resource. /// A task instance that represents the asynchronous write operation. /// The resource or item to write. - public virtual Task WriteStartAsync(ODataResource resource) + public virtual ValueTask WriteStartAsync(ODataResource resource) { - return TaskUtils.GetTaskForSynchronousOperation( + return TaskUtils.GetValueTaskForSynchronousOperation( (thisParam, resourceParam) => thisParam.WriteStart(resourceParam), this, resource); @@ -190,9 +190,9 @@ public virtual void WriteStart(ODataDeletedResource deletedResource) /// /// The deleted resource to write. /// A task instance that represents the asynchronous write operation. - public virtual Task WriteStartAsync(ODataDeletedResource deletedResource) + public virtual ValueTask WriteStartAsync(ODataDeletedResource deletedResource) { - return TaskUtils.GetTaskForSynchronousOperation( + return TaskUtils.GetValueTaskForSynchronousOperation( (thisParam, deletedResourceParam) => thisParam.WriteStart(deletedResourceParam), this, deletedResource); @@ -214,9 +214,9 @@ public virtual void WriteDeltaLink(ODataDeltaLink deltaLink) /// /// The delta link to write. /// A task instance that represents the asynchronous write operation. - public virtual Task WriteDeltaLinkAsync(ODataDeltaLink deltaLink) + public virtual ValueTask WriteDeltaLinkAsync(ODataDeltaLink deltaLink) { - return TaskUtils.GetTaskForSynchronousOperation( + return TaskUtils.GetValueTaskForSynchronousOperation( (thisParam, deltaLinkParam) => thisParam.WriteDeltaLink(deltaLinkParam), this, deltaLink); @@ -238,9 +238,9 @@ public virtual void WriteDeltaDeletedLink(ODataDeltaDeletedLink deltaDeletedLink /// /// The delta link to write. /// A task instance that represents the asynchronous write operation. - public virtual Task WriteDeltaDeletedLinkAsync(ODataDeltaDeletedLink deltaDeletedLink) + public virtual ValueTask WriteDeltaDeletedLinkAsync(ODataDeltaDeletedLink deltaDeletedLink) { - return TaskUtils.GetTaskForSynchronousOperation( + return TaskUtils.GetValueTaskForSynchronousOperation( (thisParam, deltaDeletedLinkParam) => thisParam.WriteDeltaDeletedLink(deltaDeletedLinkParam), this, deltaDeletedLink); @@ -277,9 +277,9 @@ public ODataWriter Write(ODataNestedResourceInfo nestedResourceInfo, Action nest /// Asynchronously start writing a nested resource info. /// A task instance that represents the asynchronous write operation. /// The nested resource info to writer. - public virtual Task WriteStartAsync(ODataNestedResourceInfo nestedResourceInfo) + public virtual ValueTask WriteStartAsync(ODataNestedResourceInfo nestedResourceInfo) { - return TaskUtils.GetTaskForSynchronousOperation( + return TaskUtils.GetValueTaskForSynchronousOperation( (thisParam, nestedResourceInfoParam) => thisParam.WriteStart(nestedResourceInfoParam), this, nestedResourceInfo); @@ -305,9 +305,9 @@ public ODataWriter Write(ODataPrimitiveValue primitiveValue) /// Asynchronously write a primitive value within an untyped collection. /// A task instance that represents the asynchronous write operation. /// The primitive value to write. - public virtual Task WritePrimitiveAsync(ODataPrimitiveValue primitiveValue) + public virtual ValueTask WritePrimitiveAsync(ODataPrimitiveValue primitiveValue) { - return TaskUtils.GetTaskForSynchronousOperation( + return TaskUtils.GetValueTaskForSynchronousOperation( (thisParam, primitiveValueParam) => thisParam.WritePrimitive(primitiveValueParam), this, primitiveValue); @@ -348,9 +348,9 @@ public ODataWriter Write(ODataProperty primitiveProperty, Action nestedAction) /// Asynchronously write a primitive property within a resource. /// A task instance that represents the asynchronous write operation. /// The primitive property to write. - public virtual Task WriteStartAsync(ODataPropertyInfo primitiveProperty) + public virtual ValueTask WriteStartAsync(ODataPropertyInfo primitiveProperty) { - return TaskUtils.GetTaskForSynchronousOperation( + return TaskUtils.GetValueTaskForSynchronousOperation( (thisParam, primitivePropertyParam) => thisParam.WriteStart(primitivePropertyParam), this, primitiveProperty); @@ -378,9 +378,9 @@ public ODataWriter WriteStream(ODataBinaryStreamValue stream) /// Asynchronously creates a stream for writing a binary value. /// A stream to write a binary value to. - public virtual Task CreateBinaryWriteStreamAsync() + public virtual ValueTask CreateBinaryWriteStreamAsync() { - return TaskUtils.GetTaskForSynchronousOperation( + return TaskUtils.GetValueTaskForSynchronousOperation( (thisParam) => thisParam.CreateBinaryWriteStream(), this); } @@ -395,9 +395,9 @@ public virtual TextWriter CreateTextWriter() /// Asynchronously creates a TextWriter for writing a string value. /// A TextWriter to write a string value. - public virtual Task CreateTextWriterAsync() + public virtual ValueTask CreateTextWriterAsync() { - return TaskUtils.GetTaskForSynchronousOperation( + return TaskUtils.GetValueTaskForSynchronousOperation( (thisParam) => thisParam.CreateTextWriter(), this); } @@ -408,9 +408,9 @@ public virtual Task CreateTextWriterAsync() /// Asynchronously finish writing a resource set, resource, or nested resource info. /// A task instance that represents the asynchronous write operation. - public virtual Task WriteEndAsync() + public virtual ValueTask WriteEndAsync() { - return TaskUtils.GetTaskForSynchronousOperation( + return TaskUtils.GetValueTaskForSynchronousOperation( (thisParam) => thisParam.WriteEnd(), this); } @@ -435,9 +435,9 @@ public virtual Task WriteEndAsync() /// The will be ignored in that case and the Uri from the will be used /// as the binding URL to be written. /// - public virtual Task WriteEntityReferenceLinkAsync(ODataEntityReferenceLink entityReferenceLink) + public virtual ValueTask WriteEntityReferenceLinkAsync(ODataEntityReferenceLink entityReferenceLink) { - return TaskUtils.GetTaskForSynchronousOperation( + return TaskUtils.GetValueTaskForSynchronousOperation( (thisParam, entityReferenceLinkParam) => thisParam.WriteEntityReferenceLink(entityReferenceLinkParam), this, entityReferenceLink); diff --git a/src/Microsoft.OData.Core/ODataWriterCore.cs b/src/Microsoft.OData.Core/ODataWriterCore.cs index b9f166154f..e54a655900 100644 --- a/src/Microsoft.OData.Core/ODataWriterCore.cs +++ b/src/Microsoft.OData.Core/ODataWriterCore.cs @@ -455,7 +455,7 @@ public sealed override void WriteStart(ODataResourceSet resourceSet) /// /// Resource Set/collection to write. /// A task instance that represents the asynchronous write operation. - public sealed override async Task WriteStartAsync(ODataResourceSet resourceSet) + public sealed override async ValueTask WriteStartAsync(ODataResourceSet resourceSet) { await this.VerifyCanWriteStartResourceSetAsync(false, resourceSet) .ConfigureAwait(false); @@ -478,7 +478,7 @@ public sealed override void WriteStart(ODataDeltaResourceSet deltaResourceSet) /// /// Resource Set/collection to write. /// A task instance that represents the asynchronous write operation. - public sealed override async Task WriteStartAsync(ODataDeltaResourceSet deltaResourceSet) + public sealed override async ValueTask WriteStartAsync(ODataDeltaResourceSet deltaResourceSet) { await this.VerifyCanWriteStartDeltaResourceSetAsync(false, deltaResourceSet) .ConfigureAwait(false); @@ -501,7 +501,7 @@ public sealed override void WriteStart(ODataResource resource) /// /// Resource/item to write. /// A task instance that represents the asynchronous write operation. - public sealed override Task WriteStartAsync(ODataResource resource) + public sealed override ValueTask WriteStartAsync(ODataResource resource) { this.VerifyCanWriteStartResource(false, resource); return this.WriteStartResourceImplementationAsync(resource); @@ -522,7 +522,7 @@ public sealed override void WriteStart(ODataDeletedResource deletedResource) /// /// The delta deleted resource to write. /// A task instance that represents the asynchronous write operation. - public sealed override Task WriteStartAsync(ODataDeletedResource deletedResource) + public sealed override ValueTask WriteStartAsync(ODataDeletedResource deletedResource) { this.VerifyCanWriteStartDeletedResource(false, deletedResource); return this.WriteStartDeletedResourceImplementationAsync(deletedResource); @@ -543,7 +543,7 @@ public override void WriteDeltaLink(ODataDeltaLink deltaLink) /// /// The delta link to write. /// A task instance that represents the asynchronous write operation. - public override Task WriteDeltaLinkAsync(ODataDeltaLink deltaLink) + public override ValueTask WriteDeltaLinkAsync(ODataDeltaLink deltaLink) { this.VerifyCanWriteLink(false, deltaLink); return this.WriteDeltaLinkImplementationAsync(deltaLink); @@ -564,7 +564,7 @@ public override void WriteDeltaDeletedLink(ODataDeltaDeletedLink deltaLink) /// /// The delta link to write. /// A task instance that represents the asynchronous write operation. - public override Task WriteDeltaDeletedLinkAsync(ODataDeltaDeletedLink deltaLink) + public override ValueTask WriteDeltaDeletedLinkAsync(ODataDeltaDeletedLink deltaLink) { this.VerifyCanWriteLink(false, deltaLink); return this.WriteDeltaLinkImplementationAsync(deltaLink); @@ -585,7 +585,7 @@ public sealed override void WritePrimitive(ODataPrimitiveValue primitiveValue) /// /// Primitive value to write. /// A task instance that represents the asynchronous write operation. - public sealed override Task WritePrimitiveAsync(ODataPrimitiveValue primitiveValue) + public sealed override ValueTask WritePrimitiveAsync(ODataPrimitiveValue primitiveValue) { this.VerifyCanWritePrimitive(false, primitiveValue); return this.WritePrimitiveValueImplementationAsync(primitiveValue); @@ -602,7 +602,7 @@ public sealed override void WriteStart(ODataPropertyInfo primitiveProperty) /// Asynchronously write a primitive property within a resource. /// A task instance that represents the asynchronous write operation. /// The primitive property to write. - public sealed override Task WriteStartAsync(ODataPropertyInfo primitiveProperty) + public sealed override ValueTask WriteStartAsync(ODataPropertyInfo primitiveProperty) { this.VerifyCanWriteProperty(false, primitiveProperty); return this.WriteStartPropertyImplementationAsync(primitiveProperty); @@ -619,7 +619,7 @@ public sealed override Stream CreateBinaryWriteStream() /// Asynchronously creates a stream for writing a binary value. /// A task that represents the asynchronous operation. /// The value of the TResult parameter contains a to write a binary value to. - public sealed override Task CreateBinaryWriteStreamAsync() + public sealed override ValueTask CreateBinaryWriteStreamAsync() { this.VerifyCanCreateWriteStream(false); return this.CreateWriteStreamImplementationAsync(); @@ -636,7 +636,7 @@ public sealed override TextWriter CreateTextWriter() /// Asynchronously creates a for writing a string value. /// A task that represents the asynchronous operation. /// The value of the TResult parameter contains a to write a string value to. - public sealed override Task CreateTextWriterAsync() + public sealed override ValueTask CreateTextWriterAsync() { this.VerifyCanCreateWriteStream(false); return this.CreateTextWriterImplementationAsync(); @@ -658,11 +658,11 @@ public sealed override void WriteStart(ODataNestedResourceInfo nestedResourceInf /// /// Navigation link to writer. /// A task instance that represents the asynchronous write operation. - public sealed override Task WriteStartAsync(ODataNestedResourceInfo nestedResourceInfo) + public sealed override ValueTask WriteStartAsync(ODataNestedResourceInfo nestedResourceInfo) { this.VerifyCanWriteStartNestedResourceInfo(false, nestedResourceInfo); // Currently, no asynchronous operation is involved when commencing with writing a nested resource info - return TaskUtils.GetTaskForSynchronousOperation( + return TaskUtils.GetValueTaskForSynchronousOperation( (thisParam, nestedResourceInfoParam) => thisParam.WriteStartNestedResourceInfoImplementation( nestedResourceInfoParam), this, @@ -688,7 +688,7 @@ public sealed override void WriteEnd() /// Asynchronously finish writing a resourceSet/resource/nested resource info. /// /// A task instance that represents the asynchronous write operation. - public sealed override async Task WriteEndAsync() + public sealed override async ValueTask WriteEndAsync() { this.VerifyCanWriteEnd(false); await this.WriteEndImplementationAsync() @@ -729,7 +729,7 @@ public sealed override void WriteEntityReferenceLink(ODataEntityReferenceLink en /// The will be ignored in that case and the Uri from the will be used /// as the binding URL to be written. /// - public sealed override Task WriteEntityReferenceLinkAsync(ODataEntityReferenceLink entityReferenceLink) + public sealed override ValueTask WriteEntityReferenceLinkAsync(ODataEntityReferenceLink entityReferenceLink) { this.VerifyCanWriteEntityReferenceLink(entityReferenceLink, false); return this.WriteEntityReferenceLinkImplementationAsync(entityReferenceLink); @@ -1781,7 +1781,7 @@ private void WriteDeltaLinkImplementation(ODataDeltaLinkBase deltaLink) /// /// Delta (deleted) link to write. /// The task. - private async Task WriteDeltaLinkImplementationAsync(ODataDeltaLinkBase deltaLink) + private async ValueTask WriteDeltaLinkImplementationAsync(ODataDeltaLinkBase deltaLink) { EnterScope(deltaLink is ODataDeltaLink ? WriterState.DeltaLink : WriterState.DeltaDeletedLink, deltaLink); await this.StartDeltaLinkAsync(deltaLink) @@ -1859,12 +1859,12 @@ private void WritePrimitiveValueImplementation(ODataPrimitiveValue primitiveValu /// /// Primitive value to write. /// The task. - private Task WritePrimitiveValueImplementationAsync(ODataPrimitiveValue primitiveValue) + private ValueTask WritePrimitiveValueImplementationAsync(ODataPrimitiveValue primitiveValue) { EnterScope(WriterState.Primitive, primitiveValue); - return InterceptExceptionAsync( - async (thisParam, primiteValueParam) => + return InterceptExceptionValueAsync( + async ValueTask (thisParam, primiteValueParam) => { if (!(CurrentResourceSetValidator == null) && primiteValueParam != null) { @@ -2472,6 +2472,34 @@ private async Task InterceptExceptionAsync(Func action, O } } + /// + /// Catch any exception thrown by the action passed in; in the exception case move the writer into + /// state Error and then rethrow the exception. + /// + /// The action to execute. + /// The item to associate with the new scope if transitioning to state Error. + /// The task. + /// + /// Make sure to only use anonymous functions that don't capture state from the enclosing context, + /// so the compiler optimizes the code to avoid delegate and closure allocations on every call to this method. + /// + private async ValueTask InterceptExceptionValueAsync(Func action, ODataItem currentScopeItem) + { + try + { + await action(this).ConfigureAwait(false); + } + catch + { + if (!IsErrorState(this.State)) + { + this.EnterScope(WriterState.Error, currentScopeItem); + } + + throw; + } + } + /// /// Catch any exception thrown by the action passed in; in the exception case move the writer into /// state Error and then rethrow the exception. @@ -2501,6 +2529,35 @@ private async Task InterceptExceptionAsync(Func + /// Catch any exception thrown by the action passed in; in the exception case move the writer into + /// state Error and then rethrow the exception. + /// + /// The action argument type. + /// The action to execute. + /// The argument value provided to the action. + /// The task. + /// + /// Make sure to only use anonymous functions that don't capture state from the enclosing context, + /// so the compiler optimizes the code to avoid delegate and closure allocations on every call to this method. + /// + private async ValueTask InterceptExceptionValueAsync(Func action, TArg0 arg0) + { + try + { + await action(this, arg0).ConfigureAwait(false); + } + catch + { + if (!IsErrorState(this.State)) + { + this.EnterScope(WriterState.Error, this.CurrentScope.Item); + } + + throw; + } + } + /// /// Increments the nested resource count by one and fails if the new value exceeds the maximum nested resource depth limit. /// @@ -3312,7 +3369,7 @@ await thisParam.StartDeltaResourceSetAsync(deltaResourceSetParam) /// /// Resource/item to write. /// A task that represents the asynchronous write operation. - private async Task WriteStartResourceImplementationAsync(ODataResource resource) + private async ValueTask WriteStartResourceImplementationAsync(ODataResource resource) { await this.StartPayloadInStartStateAsync() .ConfigureAwait(false); @@ -3348,7 +3405,7 @@ await thisParam.StartResourceAsync(resourceParam) /// /// Resource/item to write. /// A task that represents the asynchronous write operation. - private async Task WriteStartDeletedResourceImplementationAsync(ODataDeletedResource resource) + private async ValueTask WriteStartDeletedResourceImplementationAsync(ODataDeletedResource resource) { Debug.Assert(resource != null, "resource != null"); @@ -3380,14 +3437,14 @@ await thisParam.StartDeletedResourceAsync(resourceParam) /// /// Property to write. /// A task that represents the asynchronous write operation. - private Task WriteStartPropertyImplementationAsync(ODataPropertyInfo property) + private ValueTask WriteStartPropertyImplementationAsync(ODataPropertyInfo property) { this.EnterScope(WriterState.Property, property); if (!this.SkipWriting) { - return this.InterceptExceptionAsync( - async (thisParam, propertyParam) => + return this.InterceptExceptionValueAsync( + async ValueTask (thisParam, propertyParam) => { await thisParam.StartPropertyAsync(propertyParam) .ConfigureAwait(false); @@ -3401,7 +3458,7 @@ await thisParam.StartPropertyAsync(propertyParam) }, property); } - return TaskUtils.CompletedTask; + return ValueTask.CompletedTask; } /// @@ -3409,7 +3466,7 @@ await thisParam.StartPropertyAsync(propertyParam) /// /// A task that represents the asynchronous operation. /// The value of the TResult parameter contains the stream for writing the binary. - private async Task CreateWriteStreamImplementationAsync() + private async ValueTask CreateWriteStreamImplementationAsync() { this.EnterScope(WriterState.Stream, null); Stream underlyingStream = await this.StartBinaryStreamAsync() @@ -3423,7 +3480,7 @@ private async Task CreateWriteStreamImplementationAsync() /// /// A task that represents the asynchronous operation. /// The value of the TResult parameter contains the textwriter for writing a string value. - private async Task CreateTextWriterImplementationAsync() + private async ValueTask CreateTextWriterImplementationAsync() { this.EnterScope(WriterState.String, null); TextWriter textWriter = await this.StartTextWriterAsync() @@ -3551,7 +3608,7 @@ await thisParam.LeaveScopeAsync() /// /// The entity reference link to write. /// A task that represents the asynchronous write operation. - private async Task WriteEntityReferenceLinkImplementationAsync(ODataEntityReferenceLink entityReferenceLink) + private async ValueTask WriteEntityReferenceLinkImplementationAsync(ODataEntityReferenceLink entityReferenceLink) { Debug.Assert(entityReferenceLink != null, "entityReferenceLink != null"); diff --git a/src/Microsoft.OData.Core/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/src/Microsoft.OData.Core/PublicAPI/net8.0/PublicAPI.Unshipped.txt index 9d7495947d..c8fb5a70c0 100644 --- a/src/Microsoft.OData.Core/PublicAPI/net8.0/PublicAPI.Unshipped.txt +++ b/src/Microsoft.OData.Core/PublicAPI/net8.0/PublicAPI.Unshipped.txt @@ -1,60 +1,117 @@ +abstract Microsoft.OData.ODataDeltaWriter.FlushAsync() -> System.Threading.Tasks.Task +abstract Microsoft.OData.ODataDeltaWriter.WriteDeltaDeletedEntryAsync(Microsoft.OData.ODataDeltaDeletedEntry deltaDeletedEntry) -> System.Threading.Tasks.ValueTask +abstract Microsoft.OData.ODataDeltaWriter.WriteDeltaDeletedLinkAsync(Microsoft.OData.ODataDeltaDeletedLink deltaDeletedLink) -> System.Threading.Tasks.ValueTask +abstract Microsoft.OData.ODataDeltaWriter.WriteDeltaLinkAsync(Microsoft.OData.ODataDeltaLink deltaLink) -> System.Threading.Tasks.ValueTask +abstract Microsoft.OData.ODataDeltaWriter.WriteEndAsync() -> System.Threading.Tasks.ValueTask +abstract Microsoft.OData.ODataDeltaWriter.WriteStartAsync(Microsoft.OData.ODataDeltaResourceSet deltaResourceSet) -> System.Threading.Tasks.ValueTask +abstract Microsoft.OData.ODataDeltaWriter.WriteStartAsync(Microsoft.OData.ODataNestedResourceInfo nestedResourceInfo) -> System.Threading.Tasks.ValueTask +abstract Microsoft.OData.ODataDeltaWriter.WriteStartAsync(Microsoft.OData.ODataResource deltaResource) -> System.Threading.Tasks.ValueTask +abstract Microsoft.OData.ODataDeltaWriter.WriteStartAsync(Microsoft.OData.ODataResourceSet expandedResourceSet) -> System.Threading.Tasks.ValueTask Microsoft.Extensions.DependencyInjection.ODataServiceCollectionExtensions Microsoft.OData.IServiceCollectionProvider Microsoft.OData.IServiceCollectionProvider.ServiceProvider.get -> System.IServiceProvider Microsoft.OData.Json.DefaultJsonWriterFactory.CreateJsonWriter(System.IO.Stream stream, bool isIeee754Compatible, System.Text.Encoding encoding) -> Microsoft.OData.Json.IJsonWriter -Microsoft.OData.Json.IJsonWriter.EndArrayScopeAsync() -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.EndObjectScopeAsync() -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.EndPaddingFunctionScopeAsync() -> System.Threading.Tasks.Task +Microsoft.OData.Json.IJsonReader.CanStreamAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonReader.CreateReadStreamAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonReader.CreateTextReaderAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonReader.GetValueAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonReader.ReadAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.EndArrayScopeAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.EndObjectScopeAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.EndPaddingFunctionScopeAsync() -> System.Threading.Tasks.ValueTask Microsoft.OData.Json.IJsonWriter.EndStreamValueScope() -> void -Microsoft.OData.Json.IJsonWriter.EndStreamValueScopeAsync() -> System.Threading.Tasks.Task +Microsoft.OData.Json.IJsonWriter.EndStreamValueScopeAsync() -> System.Threading.Tasks.ValueTask Microsoft.OData.Json.IJsonWriter.EndTextWriterValueScope() -> void -Microsoft.OData.Json.IJsonWriter.EndTextWriterValueScopeAsync() -> System.Threading.Tasks.Task +Microsoft.OData.Json.IJsonWriter.EndTextWriterValueScopeAsync() -> System.Threading.Tasks.ValueTask Microsoft.OData.Json.IJsonWriter.FlushAsync() -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.StartArrayScopeAsync() -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.StartObjectScopeAsync() -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.StartPaddingFunctionScopeAsync() -> System.Threading.Tasks.Task +Microsoft.OData.Json.IJsonWriter.StartArrayScopeAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.StartObjectScopeAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.StartPaddingFunctionScopeAsync() -> System.Threading.Tasks.ValueTask Microsoft.OData.Json.IJsonWriter.StartStreamValueScope() -> System.IO.Stream -Microsoft.OData.Json.IJsonWriter.StartStreamValueScopeAsync() -> System.Threading.Tasks.Task +Microsoft.OData.Json.IJsonWriter.StartStreamValueScopeAsync() -> System.Threading.Tasks.ValueTask Microsoft.OData.Json.IJsonWriter.StartTextWriterValueScope(string contentType) -> System.IO.TextWriter -Microsoft.OData.Json.IJsonWriter.StartTextWriterValueScopeAsync(string contentType) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WriteNameAsync(string name) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WritePaddingFunctionNameAsync(string functionName) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WriteRawValueAsync(string rawValue) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WriteValueAsync(bool value) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WriteValueAsync(byte value) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WriteValueAsync(byte[] value) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WriteValueAsync(decimal value) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WriteValueAsync(double value) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WriteValueAsync(float value) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WriteValueAsync(int value) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WriteValueAsync(long value) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WriteValueAsync(Microsoft.OData.Edm.Date value) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WriteValueAsync(Microsoft.OData.Edm.TimeOfDay value) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WriteValueAsync(sbyte value) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WriteValueAsync(short value) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WriteValueAsync(string value) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WriteValueAsync(System.DateTimeOffset value) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WriteValueAsync(System.Guid value) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WriteValueAsync(System.Text.Json.JsonElement value) -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonWriter.WriteValueAsync(System.TimeSpan value) -> System.Threading.Tasks.Task +Microsoft.OData.Json.IJsonWriter.StartTextWriterValueScopeAsync(string contentType) -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.WriteNameAsync(string name) -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.WritePaddingFunctionNameAsync(string functionName) -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.WriteRawValueAsync(string rawValue) -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.WriteValueAsync(bool value) -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.WriteValueAsync(byte value) -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.WriteValueAsync(byte[] value) -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.WriteValueAsync(decimal value) -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.WriteValueAsync(double value) -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.WriteValueAsync(float value) -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.WriteValueAsync(int value) -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.WriteValueAsync(long value) -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.WriteValueAsync(Microsoft.OData.Edm.Date value) -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.WriteValueAsync(Microsoft.OData.Edm.TimeOfDay value) -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.WriteValueAsync(sbyte value) -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.WriteValueAsync(short value) -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.WriteValueAsync(string value) -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.WriteValueAsync(System.DateTimeOffset value) -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.WriteValueAsync(System.Guid value) -> System.Threading.Tasks.ValueTask +Microsoft.OData.Json.IJsonWriter.WriteValueAsync(System.Text.Json.JsonElement value) -> System.Threading.Tasks.ValueTask Microsoft.OData.Json.IJsonReader.CanStream() -> bool -Microsoft.OData.Json.IJsonReader.CanStreamAsync() -> System.Threading.Tasks.Task Microsoft.OData.Json.IJsonReader.CreateReadStream() -> System.IO.Stream -Microsoft.OData.Json.IJsonReader.CreateReadStreamAsync() -> System.Threading.Tasks.Task Microsoft.OData.Json.IJsonReader.CreateTextReader() -> System.IO.TextReader -Microsoft.OData.Json.IJsonReader.CreateTextReaderAsync() -> System.Threading.Tasks.Task Microsoft.OData.Json.IJsonReader.GetValue() -> object -Microsoft.OData.Json.IJsonReader.GetValueAsync() -> System.Threading.Tasks.Task -Microsoft.OData.Json.IJsonReader.ReadAsync() -> System.Threading.Tasks.Task +Microsoft.OData.Json.IJsonWriter.WriteValueAsync(System.TimeSpan value) -> System.Threading.Tasks.ValueTask Microsoft.OData.ODataAsynchronousResponseMessage.ServiceProvider.get -> System.IServiceProvider Microsoft.OData.ODataBatchOperationRequestMessage.ServiceProvider.get -> System.IServiceProvider Microsoft.OData.ODataBatchOperationResponseMessage.ServiceProvider.get -> System.IServiceProvider Microsoft.OData.ODataMessageInfo.ServiceProvider.get -> System.IServiceProvider Microsoft.OData.ODataMessageInfo.ServiceProvider.set -> void +Microsoft.OData.ODataMessageReader.CreateODataAsynchronousReaderAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.CreateODataBatchReaderAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.CreateODataCollectionReaderAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.CreateODataCollectionReaderAsync(Microsoft.OData.Edm.IEdmTypeReference expectedItemTypeReference) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.CreateODataDeltaResourceSetReaderAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.CreateODataDeltaResourceSetReaderAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.CreateODataDeltaResourceSetReaderAsync(Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.CreateODataParameterReaderAsync(Microsoft.OData.Edm.IEdmOperation operation) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.CreateODataResourceReaderAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.CreateODataResourceReaderAsync(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.CreateODataResourceReaderAsync(Microsoft.OData.Edm.IEdmStructuredType resourceType) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.CreateODataResourceSetReaderAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.CreateODataResourceSetReaderAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.CreateODataResourceSetReaderAsync(Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.CreateODataUriParameterResourceReaderAsync(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.CreateODataUriParameterResourceSetReaderAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.DetectPayloadKindAsync() -> System.Threading.Tasks.ValueTask> +Microsoft.OData.ODataMessageReader.ReadEntityReferenceLinkAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.ReadEntityReferenceLinksAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.ReadErrorAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.ReadPropertyAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.ReadPropertyAsync(Microsoft.OData.Edm.IEdmStructuralProperty property) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.ReadPropertyAsync(Microsoft.OData.Edm.IEdmTypeReference expectedPropertyTypeReference) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.ReadServiceDocumentAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageReader.ReadValueAsync(Microsoft.OData.Edm.IEdmTypeReference expectedTypeReference) -> System.Threading.Tasks.ValueTask Microsoft.OData.ODataMessageReaderSettings.EnableReadingKeyAsSegment.get -> bool Microsoft.OData.ODataMessageReaderSettings.EnableReadingKeyAsSegment.set -> void Microsoft.OData.ODataMessageReaderSettings.EnableReadingODataAnnotationWithoutPrefix.get -> bool Microsoft.OData.ODataMessageReaderSettings.EnableReadingODataAnnotationWithoutPrefix.set -> void +Microsoft.OData.ODataMessageWriter.CreateODataAsynchronousWriterAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.CreateODataBatchWriterAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.CreateODataCollectionWriterAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.CreateODataCollectionWriterAsync(Microsoft.OData.Edm.IEdmTypeReference itemTypeReference) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.CreateODataDeltaResourceSetWriterAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.CreateODataDeltaResourceSetWriterAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.CreateODataDeltaResourceSetWriterAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmEntityType entityType) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.CreateODataParameterWriterAsync(Microsoft.OData.Edm.IEdmOperation operation) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.CreateODataResourceSetWriterAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.CreateODataResourceSetWriterAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.CreateODataResourceSetWriterAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType structuredType) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.CreateODataResourceWriterAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.CreateODataResourceWriterAsync(Microsoft.OData.Edm.IEdmNavigationSource navigationSource) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.CreateODataResourceWriterAsync(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.CreateODataUriParameterResourceSetWriterAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySetBase, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.CreateODataUriParameterResourceWriterAsync(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.WriteEntityReferenceLinkAsync(Microsoft.OData.ODataEntityReferenceLink link) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.WriteEntityReferenceLinksAsync(Microsoft.OData.ODataEntityReferenceLinks links) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.WriteErrorAsync(Microsoft.OData.ODataError error, bool includeDebugInformation) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.WriteMetadataDocumentAsync() -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.WritePropertyAsync(Microsoft.OData.ODataProperty property) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.WriteServiceDocumentAsync(Microsoft.OData.ODataServiceDocument serviceDocument) -> System.Threading.Tasks.ValueTask +Microsoft.OData.ODataMessageWriter.WriteValueAsync(object value) -> System.Threading.Tasks.ValueTask Microsoft.OData.ODataMessageWriterSettings.EnableWritingKeyAsSegment.get -> bool Microsoft.OData.ODataMessageWriterSettings.EnableWritingKeyAsSegment.set -> void Microsoft.OData.ODataMessageWriterSettings.GetOmitODataPrefix() -> bool @@ -117,23 +174,14 @@ abstract Microsoft.OData.ODataDeltaReader.ReadAsync() -> System.Threading.Tasks. abstract Microsoft.OData.ODataDeltaReader.State.get -> Microsoft.OData.ODataDeltaReaderState abstract Microsoft.OData.ODataDeltaReader.SubState.get -> Microsoft.OData.ODataReaderState abstract Microsoft.OData.ODataDeltaWriter.Flush() -> void -abstract Microsoft.OData.ODataDeltaWriter.FlushAsync() -> System.Threading.Tasks.Task abstract Microsoft.OData.ODataDeltaWriter.WriteDeltaDeletedEntry(Microsoft.OData.ODataDeltaDeletedEntry deltaDeletedEntry) -> void -abstract Microsoft.OData.ODataDeltaWriter.WriteDeltaDeletedEntryAsync(Microsoft.OData.ODataDeltaDeletedEntry deltaDeletedEntry) -> System.Threading.Tasks.Task abstract Microsoft.OData.ODataDeltaWriter.WriteDeltaDeletedLink(Microsoft.OData.ODataDeltaDeletedLink deltaDeletedLink) -> void -abstract Microsoft.OData.ODataDeltaWriter.WriteDeltaDeletedLinkAsync(Microsoft.OData.ODataDeltaDeletedLink deltaDeletedLink) -> System.Threading.Tasks.Task abstract Microsoft.OData.ODataDeltaWriter.WriteDeltaLink(Microsoft.OData.ODataDeltaLink deltaLink) -> void -abstract Microsoft.OData.ODataDeltaWriter.WriteDeltaLinkAsync(Microsoft.OData.ODataDeltaLink deltaLink) -> System.Threading.Tasks.Task abstract Microsoft.OData.ODataDeltaWriter.WriteEnd() -> void -abstract Microsoft.OData.ODataDeltaWriter.WriteEndAsync() -> System.Threading.Tasks.Task abstract Microsoft.OData.ODataDeltaWriter.WriteStart(Microsoft.OData.ODataDeltaResourceSet deltaResourceSet) -> void abstract Microsoft.OData.ODataDeltaWriter.WriteStart(Microsoft.OData.ODataNestedResourceInfo nestedResourceInfo) -> void abstract Microsoft.OData.ODataDeltaWriter.WriteStart(Microsoft.OData.ODataResource deltaResource) -> void abstract Microsoft.OData.ODataDeltaWriter.WriteStart(Microsoft.OData.ODataResourceSet expandedResourceSet) -> void -abstract Microsoft.OData.ODataDeltaWriter.WriteStartAsync(Microsoft.OData.ODataDeltaResourceSet deltaResourceSet) -> System.Threading.Tasks.Task -abstract Microsoft.OData.ODataDeltaWriter.WriteStartAsync(Microsoft.OData.ODataNestedResourceInfo nestedResourceInfo) -> System.Threading.Tasks.Task -abstract Microsoft.OData.ODataDeltaWriter.WriteStartAsync(Microsoft.OData.ODataResource deltaResource) -> System.Threading.Tasks.Task -abstract Microsoft.OData.ODataDeltaWriter.WriteStartAsync(Microsoft.OData.ODataResourceSet expandedResourceSet) -> System.Threading.Tasks.Task abstract Microsoft.OData.ODataFormat.CreateInputContext(Microsoft.OData.ODataMessageInfo messageInfo, Microsoft.OData.ODataMessageReaderSettings messageReaderSettings) -> Microsoft.OData.ODataInputContext abstract Microsoft.OData.ODataFormat.CreateInputContextAsync(Microsoft.OData.ODataMessageInfo messageInfo, Microsoft.OData.ODataMessageReaderSettings messageReaderSettings) -> System.Threading.Tasks.Task abstract Microsoft.OData.ODataFormat.CreateOutputContext(Microsoft.OData.ODataMessageInfo messageInfo, Microsoft.OData.ODataMessageWriterSettings messageWriterSettings) -> Microsoft.OData.ODataOutputContext @@ -626,39 +674,22 @@ Microsoft.OData.ODataMessageQuotas.ODataMessageQuotas() -> void Microsoft.OData.ODataMessageQuotas.ODataMessageQuotas(Microsoft.OData.ODataMessageQuotas other) -> void Microsoft.OData.ODataMessageReader Microsoft.OData.ODataMessageReader.CreateODataAsynchronousReader() -> Microsoft.OData.ODataAsynchronousReader -Microsoft.OData.ODataMessageReader.CreateODataAsynchronousReaderAsync() -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageReader.CreateODataBatchReader() -> Microsoft.OData.ODataBatchReader -Microsoft.OData.ODataMessageReader.CreateODataBatchReaderAsync() -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageReader.CreateODataCollectionReader() -> Microsoft.OData.ODataCollectionReader Microsoft.OData.ODataMessageReader.CreateODataCollectionReader(Microsoft.OData.Edm.IEdmTypeReference expectedItemTypeReference) -> Microsoft.OData.ODataCollectionReader -Microsoft.OData.ODataMessageReader.CreateODataCollectionReaderAsync() -> System.Threading.Tasks.Task -Microsoft.OData.ODataMessageReader.CreateODataCollectionReaderAsync(Microsoft.OData.Edm.IEdmTypeReference expectedItemTypeReference) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageReader.CreateODataDeltaResourceSetReader() -> Microsoft.OData.ODataReader Microsoft.OData.ODataMessageReader.CreateODataDeltaResourceSetReader(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> Microsoft.OData.ODataReader Microsoft.OData.ODataMessageReader.CreateODataDeltaResourceSetReader(Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> Microsoft.OData.ODataReader -Microsoft.OData.ODataMessageReader.CreateODataDeltaResourceSetReaderAsync() -> System.Threading.Tasks.Task -Microsoft.OData.ODataMessageReader.CreateODataDeltaResourceSetReaderAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.Task -Microsoft.OData.ODataMessageReader.CreateODataDeltaResourceSetReaderAsync(Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageReader.CreateODataParameterReader(Microsoft.OData.Edm.IEdmOperation operation) -> Microsoft.OData.ODataParameterReader -Microsoft.OData.ODataMessageReader.CreateODataParameterReaderAsync(Microsoft.OData.Edm.IEdmOperation operation) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageReader.CreateODataResourceReader() -> Microsoft.OData.ODataReader Microsoft.OData.ODataMessageReader.CreateODataResourceReader(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> Microsoft.OData.ODataReader Microsoft.OData.ODataMessageReader.CreateODataResourceReader(Microsoft.OData.Edm.IEdmStructuredType resourceType) -> Microsoft.OData.ODataReader -Microsoft.OData.ODataMessageReader.CreateODataResourceReaderAsync() -> System.Threading.Tasks.Task -Microsoft.OData.ODataMessageReader.CreateODataResourceReaderAsync(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> System.Threading.Tasks.Task -Microsoft.OData.ODataMessageReader.CreateODataResourceReaderAsync(Microsoft.OData.Edm.IEdmStructuredType resourceType) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageReader.CreateODataResourceSetReader() -> Microsoft.OData.ODataReader Microsoft.OData.ODataMessageReader.CreateODataResourceSetReader(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> Microsoft.OData.ODataReader Microsoft.OData.ODataMessageReader.CreateODataResourceSetReader(Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> Microsoft.OData.ODataReader -Microsoft.OData.ODataMessageReader.CreateODataResourceSetReaderAsync() -> System.Threading.Tasks.Task -Microsoft.OData.ODataMessageReader.CreateODataResourceSetReaderAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.Task -Microsoft.OData.ODataMessageReader.CreateODataResourceSetReaderAsync(Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageReader.CreateODataUriParameterResourceReader(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> Microsoft.OData.ODataReader -Microsoft.OData.ODataMessageReader.CreateODataUriParameterResourceReaderAsync(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageReader.CreateODataUriParameterResourceSetReader(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> Microsoft.OData.ODataReader -Microsoft.OData.ODataMessageReader.CreateODataUriParameterResourceSetReaderAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageReader.DetectPayloadKind() -> System.Collections.Generic.IEnumerable -Microsoft.OData.ODataMessageReader.DetectPayloadKindAsync() -> System.Threading.Tasks.Task> Microsoft.OData.ODataMessageReader.Dispose() -> void Microsoft.OData.ODataMessageReader.ODataMessageReader(Microsoft.OData.IODataRequestMessage requestMessage) -> void Microsoft.OData.ODataMessageReader.ODataMessageReader(Microsoft.OData.IODataRequestMessage requestMessage, Microsoft.OData.ODataMessageReaderSettings settings) -> void @@ -667,24 +698,16 @@ Microsoft.OData.ODataMessageReader.ODataMessageReader(Microsoft.OData.IODataResp Microsoft.OData.ODataMessageReader.ODataMessageReader(Microsoft.OData.IODataResponseMessage responseMessage, Microsoft.OData.ODataMessageReaderSettings settings) -> void Microsoft.OData.ODataMessageReader.ODataMessageReader(Microsoft.OData.IODataResponseMessage responseMessage, Microsoft.OData.ODataMessageReaderSettings settings, Microsoft.OData.Edm.IEdmModel model) -> void Microsoft.OData.ODataMessageReader.ReadEntityReferenceLink() -> Microsoft.OData.ODataEntityReferenceLink -Microsoft.OData.ODataMessageReader.ReadEntityReferenceLinkAsync() -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageReader.ReadEntityReferenceLinks() -> Microsoft.OData.ODataEntityReferenceLinks -Microsoft.OData.ODataMessageReader.ReadEntityReferenceLinksAsync() -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageReader.ReadError() -> Microsoft.OData.ODataError -Microsoft.OData.ODataMessageReader.ReadErrorAsync() -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageReader.ReadMetadataDocument() -> Microsoft.OData.Edm.IEdmModel Microsoft.OData.ODataMessageReader.ReadMetadataDocument(Microsoft.OData.Edm.Csdl.CsdlReaderSettingsBase csdlReaderSettings) -> Microsoft.OData.Edm.IEdmModel Microsoft.OData.ODataMessageReader.ReadMetadataDocument(System.Func getReferencedModelReaderFunc) -> Microsoft.OData.Edm.IEdmModel Microsoft.OData.ODataMessageReader.ReadProperty() -> Microsoft.OData.ODataProperty Microsoft.OData.ODataMessageReader.ReadProperty(Microsoft.OData.Edm.IEdmStructuralProperty property) -> Microsoft.OData.ODataProperty Microsoft.OData.ODataMessageReader.ReadProperty(Microsoft.OData.Edm.IEdmTypeReference expectedPropertyTypeReference) -> Microsoft.OData.ODataProperty -Microsoft.OData.ODataMessageReader.ReadPropertyAsync() -> System.Threading.Tasks.Task -Microsoft.OData.ODataMessageReader.ReadPropertyAsync(Microsoft.OData.Edm.IEdmStructuralProperty property) -> System.Threading.Tasks.Task -Microsoft.OData.ODataMessageReader.ReadPropertyAsync(Microsoft.OData.Edm.IEdmTypeReference expectedPropertyTypeReference) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageReader.ReadServiceDocument() -> Microsoft.OData.ODataServiceDocument -Microsoft.OData.ODataMessageReader.ReadServiceDocumentAsync() -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageReader.ReadValue(Microsoft.OData.Edm.IEdmTypeReference expectedTypeReference) -> object -Microsoft.OData.ODataMessageReader.ReadValueAsync(Microsoft.OData.Edm.IEdmTypeReference expectedTypeReference) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageReaderSettings Microsoft.OData.ODataMessageReaderSettings.ArrayPool.get -> Microsoft.OData.Buffers.ICharArrayPool Microsoft.OData.ODataMessageReaderSettings.ArrayPool.set -> void @@ -723,37 +746,21 @@ Microsoft.OData.ODataMessageReaderSettings.Version.get -> Microsoft.OData.ODataV Microsoft.OData.ODataMessageReaderSettings.Version.set -> void Microsoft.OData.ODataMessageWriter Microsoft.OData.ODataMessageWriter.CreateODataAsynchronousWriter() -> Microsoft.OData.ODataAsynchronousWriter -Microsoft.OData.ODataMessageWriter.CreateODataAsynchronousWriterAsync() -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageWriter.CreateODataBatchWriter() -> Microsoft.OData.ODataBatchWriter -Microsoft.OData.ODataMessageWriter.CreateODataBatchWriterAsync() -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageWriter.CreateODataCollectionWriter() -> Microsoft.OData.ODataCollectionWriter Microsoft.OData.ODataMessageWriter.CreateODataCollectionWriter(Microsoft.OData.Edm.IEdmTypeReference itemTypeReference) -> Microsoft.OData.ODataCollectionWriter -Microsoft.OData.ODataMessageWriter.CreateODataCollectionWriterAsync() -> System.Threading.Tasks.Task -Microsoft.OData.ODataMessageWriter.CreateODataCollectionWriterAsync(Microsoft.OData.Edm.IEdmTypeReference itemTypeReference) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageWriter.CreateODataDeltaResourceSetWriter() -> Microsoft.OData.ODataWriter Microsoft.OData.ODataMessageWriter.CreateODataDeltaResourceSetWriter(Microsoft.OData.Edm.IEdmEntitySetBase entitySet) -> Microsoft.OData.ODataWriter Microsoft.OData.ODataMessageWriter.CreateODataDeltaResourceSetWriter(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> Microsoft.OData.ODataWriter -Microsoft.OData.ODataMessageWriter.CreateODataDeltaResourceSetWriterAsync() -> System.Threading.Tasks.Task -Microsoft.OData.ODataMessageWriter.CreateODataDeltaResourceSetWriterAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet) -> System.Threading.Tasks.Task -Microsoft.OData.ODataMessageWriter.CreateODataDeltaResourceSetWriterAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmEntityType entityType) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageWriter.CreateODataParameterWriter(Microsoft.OData.Edm.IEdmOperation operation) -> Microsoft.OData.ODataParameterWriter -Microsoft.OData.ODataMessageWriter.CreateODataParameterWriterAsync(Microsoft.OData.Edm.IEdmOperation operation) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageWriter.CreateODataResourceSetWriter() -> Microsoft.OData.ODataWriter Microsoft.OData.ODataMessageWriter.CreateODataResourceSetWriter(Microsoft.OData.Edm.IEdmEntitySetBase entitySet) -> Microsoft.OData.ODataWriter Microsoft.OData.ODataMessageWriter.CreateODataResourceSetWriter(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> Microsoft.OData.ODataWriter -Microsoft.OData.ODataMessageWriter.CreateODataResourceSetWriterAsync() -> System.Threading.Tasks.Task -Microsoft.OData.ODataMessageWriter.CreateODataResourceSetWriterAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet) -> System.Threading.Tasks.Task -Microsoft.OData.ODataMessageWriter.CreateODataResourceSetWriterAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType structuredType) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageWriter.CreateODataResourceWriter() -> Microsoft.OData.ODataWriter Microsoft.OData.ODataMessageWriter.CreateODataResourceWriter(Microsoft.OData.Edm.IEdmNavigationSource navigationSource) -> Microsoft.OData.ODataWriter Microsoft.OData.ODataMessageWriter.CreateODataResourceWriter(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> Microsoft.OData.ODataWriter -Microsoft.OData.ODataMessageWriter.CreateODataResourceWriterAsync() -> System.Threading.Tasks.Task -Microsoft.OData.ODataMessageWriter.CreateODataResourceWriterAsync(Microsoft.OData.Edm.IEdmNavigationSource navigationSource) -> System.Threading.Tasks.Task -Microsoft.OData.ODataMessageWriter.CreateODataResourceWriterAsync(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageWriter.CreateODataUriParameterResourceSetWriter(Microsoft.OData.Edm.IEdmEntitySetBase entitySetBase, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> Microsoft.OData.ODataWriter -Microsoft.OData.ODataMessageWriter.CreateODataUriParameterResourceSetWriterAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySetBase, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageWriter.CreateODataUriParameterResourceWriter(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> Microsoft.OData.ODataWriter -Microsoft.OData.ODataMessageWriter.CreateODataUriParameterResourceWriterAsync(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageWriter.Dispose() -> void Microsoft.OData.ODataMessageWriter.DisposeAsync() -> System.Threading.Tasks.ValueTask Microsoft.OData.ODataOutputContext.DisposeAsync() -> System.Threading.Tasks.ValueTask @@ -764,19 +771,12 @@ Microsoft.OData.ODataMessageWriter.ODataMessageWriter(Microsoft.OData.IODataResp Microsoft.OData.ODataMessageWriter.ODataMessageWriter(Microsoft.OData.IODataResponseMessage responseMessage, Microsoft.OData.ODataMessageWriterSettings settings) -> void Microsoft.OData.ODataMessageWriter.ODataMessageWriter(Microsoft.OData.IODataResponseMessage responseMessage, Microsoft.OData.ODataMessageWriterSettings settings, Microsoft.OData.Edm.IEdmModel model) -> void Microsoft.OData.ODataMessageWriter.WriteEntityReferenceLink(Microsoft.OData.ODataEntityReferenceLink link) -> void -Microsoft.OData.ODataMessageWriter.WriteEntityReferenceLinkAsync(Microsoft.OData.ODataEntityReferenceLink link) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageWriter.WriteEntityReferenceLinks(Microsoft.OData.ODataEntityReferenceLinks links) -> void -Microsoft.OData.ODataMessageWriter.WriteEntityReferenceLinksAsync(Microsoft.OData.ODataEntityReferenceLinks links) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageWriter.WriteError(Microsoft.OData.ODataError error, bool includeDebugInformation) -> void -Microsoft.OData.ODataMessageWriter.WriteErrorAsync(Microsoft.OData.ODataError error, bool includeDebugInformation) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageWriter.WriteMetadataDocument() -> void -Microsoft.OData.ODataMessageWriter.WriteMetadataDocumentAsync() -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageWriter.WriteProperty(Microsoft.OData.ODataProperty property) -> void -Microsoft.OData.ODataMessageWriter.WritePropertyAsync(Microsoft.OData.ODataProperty property) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageWriter.WriteServiceDocument(Microsoft.OData.ODataServiceDocument serviceDocument) -> void -Microsoft.OData.ODataMessageWriter.WriteServiceDocumentAsync(Microsoft.OData.ODataServiceDocument serviceDocument) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageWriter.WriteValue(object value) -> void -Microsoft.OData.ODataMessageWriter.WriteValueAsync(object value) -> System.Threading.Tasks.Task Microsoft.OData.ODataMessageWriterSettings Microsoft.OData.ODataMessageWriterSettings.AlwaysAddTypeAnnotationsForDerivedTypes.get -> bool Microsoft.OData.ODataMessageWriterSettings.AlwaysAddTypeAnnotationsForDerivedTypes.set -> void @@ -2306,45 +2306,45 @@ virtual Microsoft.OData.ODataBatchReader.ReadAtStartImplementationAsync() -> Sys virtual Microsoft.OData.ODataBatchWriter.OnInStreamErrorAsync() -> System.Threading.Tasks.Task virtual Microsoft.OData.ODataBatchWriter.StreamDisposedAsync() -> System.Threading.Tasks.Task virtual Microsoft.OData.ODataInputContext.CreateCollectionReader(Microsoft.OData.Edm.IEdmTypeReference expectedItemTypeReference) -> Microsoft.OData.ODataCollectionReader -virtual Microsoft.OData.ODataInputContext.CreateCollectionReaderAsync(Microsoft.OData.Edm.IEdmTypeReference expectedItemTypeReference) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataInputContext.CreateCollectionReaderAsync(Microsoft.OData.Edm.IEdmTypeReference expectedItemTypeReference) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataInputContext.CreateDeltaResourceSetReader(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> Microsoft.OData.ODataReader -virtual Microsoft.OData.ODataInputContext.CreateDeltaResourceSetReaderAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataInputContext.CreateDeltaResourceSetReaderAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataInputContext.CreateParameterReader(Microsoft.OData.Edm.IEdmOperation operation) -> Microsoft.OData.ODataParameterReader -virtual Microsoft.OData.ODataInputContext.CreateParameterReaderAsync(Microsoft.OData.Edm.IEdmOperation operation) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataInputContext.CreateParameterReaderAsync(Microsoft.OData.Edm.IEdmOperation operation) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataInputContext.CreateResourceReader(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> Microsoft.OData.ODataReader -virtual Microsoft.OData.ODataInputContext.CreateResourceReaderAsync(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataInputContext.CreateResourceReaderAsync(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataInputContext.CreateResourceSetReader(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> Microsoft.OData.ODataReader -virtual Microsoft.OData.ODataInputContext.CreateResourceSetReaderAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataInputContext.CreateResourceSetReaderAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataInputContext.CreateUriParameterResourceReader(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> Microsoft.OData.ODataReader -virtual Microsoft.OData.ODataInputContext.CreateUriParameterResourceReaderAsync(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataInputContext.CreateUriParameterResourceReaderAsync(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataInputContext.CreateUriParameterResourceSetReader(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> Microsoft.OData.ODataReader -virtual Microsoft.OData.ODataInputContext.CreateUriParameterResourceSetReaderAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataInputContext.CreateUriParameterResourceSetReaderAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType expectedResourceType) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataInputContext.Dispose(bool disposing) -> void virtual Microsoft.OData.ODataInputContext.ReadError() -> Microsoft.OData.ODataError -virtual Microsoft.OData.ODataInputContext.ReadErrorAsync() -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataInputContext.ReadErrorAsync() -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataInputContext.ReadProperty(Microsoft.OData.Edm.IEdmStructuralProperty edmStructuralProperty, Microsoft.OData.Edm.IEdmTypeReference expectedPropertyTypeReference) -> Microsoft.OData.ODataProperty -virtual Microsoft.OData.ODataInputContext.ReadPropertyAsync(Microsoft.OData.Edm.IEdmStructuralProperty edmStructuralProperty, Microsoft.OData.Edm.IEdmTypeReference expectedPropertyTypeReference) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataInputContext.ReadPropertyAsync(Microsoft.OData.Edm.IEdmStructuralProperty edmStructuralProperty, Microsoft.OData.Edm.IEdmTypeReference expectedPropertyTypeReference) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataMediaTypeResolver.GetMediaTypeFormats(Microsoft.OData.ODataPayloadKind payloadKind) -> System.Collections.Generic.IEnumerable virtual Microsoft.OData.ODataOutputContext.CreateODataCollectionWriter(Microsoft.OData.Edm.IEdmTypeReference itemTypeReference) -> Microsoft.OData.ODataCollectionWriter -virtual Microsoft.OData.ODataOutputContext.CreateODataCollectionWriterAsync(Microsoft.OData.Edm.IEdmTypeReference itemTypeReference) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataOutputContext.CreateODataCollectionWriterAsync(Microsoft.OData.Edm.IEdmTypeReference itemTypeReference) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataOutputContext.CreateODataDeltaResourceSetWriter(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> Microsoft.OData.ODataWriter -virtual Microsoft.OData.ODataOutputContext.CreateODataDeltaResourceSetWriterAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType entityType) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataOutputContext.CreateODataDeltaResourceSetWriterAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType entityType) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataOutputContext.CreateODataParameterWriter(Microsoft.OData.Edm.IEdmOperation operation) -> Microsoft.OData.ODataParameterWriter -virtual Microsoft.OData.ODataOutputContext.CreateODataParameterWriterAsync(Microsoft.OData.Edm.IEdmOperation operation) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataOutputContext.CreateODataParameterWriterAsync(Microsoft.OData.Edm.IEdmOperation operation) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataOutputContext.CreateODataResourceSetWriter(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> Microsoft.OData.ODataWriter -virtual Microsoft.OData.ODataOutputContext.CreateODataResourceSetWriterAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType entityType) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataOutputContext.CreateODataResourceSetWriterAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType entityType) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataOutputContext.CreateODataResourceWriter(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> Microsoft.OData.ODataWriter -virtual Microsoft.OData.ODataOutputContext.CreateODataResourceWriterAsync(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataOutputContext.CreateODataResourceWriterAsync(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataOutputContext.CreateODataUriParameterResourceSetWriter(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> Microsoft.OData.ODataWriter -virtual Microsoft.OData.ODataOutputContext.CreateODataUriParameterResourceSetWriterAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataOutputContext.CreateODataUriParameterResourceSetWriterAsync(Microsoft.OData.Edm.IEdmEntitySetBase entitySet, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataOutputContext.CreateODataUriParameterResourceWriter(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> Microsoft.OData.ODataWriter -virtual Microsoft.OData.ODataOutputContext.CreateODataUriParameterResourceWriterAsync(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataOutputContext.CreateODataUriParameterResourceWriterAsync(Microsoft.OData.Edm.IEdmNavigationSource navigationSource, Microsoft.OData.Edm.IEdmStructuredType resourceType) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataOutputContext.Dispose(bool disposing) -> void virtual Microsoft.OData.ODataOutputContext.DisposeAsyncCore() -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataOutputContext.WriteError(Microsoft.OData.ODataError odataError, bool includeDebugInformation) -> void -virtual Microsoft.OData.ODataOutputContext.WriteErrorAsync(Microsoft.OData.ODataError odataError, bool includeDebugInformation) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataOutputContext.WriteErrorAsync(Microsoft.OData.ODataError odataError, bool includeDebugInformation) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataOutputContext.WriteProperty(Microsoft.OData.ODataProperty odataProperty) -> void -virtual Microsoft.OData.ODataOutputContext.WritePropertyAsync(Microsoft.OData.ODataProperty odataProperty) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataOutputContext.WritePropertyAsync(Microsoft.OData.ODataProperty odataProperty) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataParameterReader.CreateCollectionReaderAsync() -> System.Threading.Tasks.Task virtual Microsoft.OData.ODataParameterReader.CreateResourceReaderAsync() -> System.Threading.Tasks.Task virtual Microsoft.OData.ODataParameterReader.CreateResourceSetReaderAsync() -> System.Threading.Tasks.Task @@ -2357,27 +2357,27 @@ virtual Microsoft.OData.ODataReader.CreateReadStreamAsync() -> System.Threading. virtual Microsoft.OData.ODataReader.CreateTextReader() -> System.IO.TextReader virtual Microsoft.OData.ODataReader.CreateTextReaderAsync() -> System.Threading.Tasks.Task virtual Microsoft.OData.ODataWriter.CreateBinaryWriteStream() -> System.IO.Stream -virtual Microsoft.OData.ODataWriter.CreateBinaryWriteStreamAsync() -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataWriter.CreateBinaryWriteStreamAsync() -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataWriter.CreateTextWriter() -> System.IO.TextWriter -virtual Microsoft.OData.ODataWriter.CreateTextWriterAsync() -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataWriter.CreateTextWriterAsync() -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataWriter.FlushAsync() -> System.Threading.Tasks.Task virtual Microsoft.OData.ODataWriter.WriteDeltaDeletedLink(Microsoft.OData.ODataDeltaDeletedLink deltaDeletedLink) -> void -virtual Microsoft.OData.ODataWriter.WriteDeltaDeletedLinkAsync(Microsoft.OData.ODataDeltaDeletedLink deltaDeletedLink) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataWriter.WriteDeltaDeletedLinkAsync(Microsoft.OData.ODataDeltaDeletedLink deltaDeletedLink) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataWriter.WriteDeltaLink(Microsoft.OData.ODataDeltaLink deltaLink) -> void -virtual Microsoft.OData.ODataWriter.WriteDeltaLinkAsync(Microsoft.OData.ODataDeltaLink deltaLink) -> System.Threading.Tasks.Task -virtual Microsoft.OData.ODataWriter.WriteEndAsync() -> System.Threading.Tasks.Task -virtual Microsoft.OData.ODataWriter.WriteEntityReferenceLinkAsync(Microsoft.OData.ODataEntityReferenceLink entityReferenceLink) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataWriter.WriteDeltaLinkAsync(Microsoft.OData.ODataDeltaLink deltaLink) -> System.Threading.Tasks.ValueTask +virtual Microsoft.OData.ODataWriter.WriteEndAsync() -> System.Threading.Tasks.ValueTask +virtual Microsoft.OData.ODataWriter.WriteEntityReferenceLinkAsync(Microsoft.OData.ODataEntityReferenceLink entityReferenceLink) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataWriter.WritePrimitive(Microsoft.OData.ODataPrimitiveValue primitiveValue) -> void -virtual Microsoft.OData.ODataWriter.WritePrimitiveAsync(Microsoft.OData.ODataPrimitiveValue primitiveValue) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataWriter.WritePrimitiveAsync(Microsoft.OData.ODataPrimitiveValue primitiveValue) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.ODataWriter.WriteStart(Microsoft.OData.ODataDeletedResource deletedResource) -> void virtual Microsoft.OData.ODataWriter.WriteStart(Microsoft.OData.ODataDeltaResourceSet deltaResourceSet) -> void virtual Microsoft.OData.ODataWriter.WriteStart(Microsoft.OData.ODataPropertyInfo primitiveProperty) -> void -virtual Microsoft.OData.ODataWriter.WriteStartAsync(Microsoft.OData.ODataDeletedResource deletedResource) -> System.Threading.Tasks.Task -virtual Microsoft.OData.ODataWriter.WriteStartAsync(Microsoft.OData.ODataDeltaResourceSet deltaResourceSet) -> System.Threading.Tasks.Task -virtual Microsoft.OData.ODataWriter.WriteStartAsync(Microsoft.OData.ODataNestedResourceInfo nestedResourceInfo) -> System.Threading.Tasks.Task -virtual Microsoft.OData.ODataWriter.WriteStartAsync(Microsoft.OData.ODataPropertyInfo primitiveProperty) -> System.Threading.Tasks.Task -virtual Microsoft.OData.ODataWriter.WriteStartAsync(Microsoft.OData.ODataResource resource) -> System.Threading.Tasks.Task -virtual Microsoft.OData.ODataWriter.WriteStartAsync(Microsoft.OData.ODataResourceSet resourceSet) -> System.Threading.Tasks.Task +virtual Microsoft.OData.ODataWriter.WriteStartAsync(Microsoft.OData.ODataDeletedResource deletedResource) -> System.Threading.Tasks.ValueTask +virtual Microsoft.OData.ODataWriter.WriteStartAsync(Microsoft.OData.ODataDeltaResourceSet deltaResourceSet) -> System.Threading.Tasks.ValueTask +virtual Microsoft.OData.ODataWriter.WriteStartAsync(Microsoft.OData.ODataNestedResourceInfo nestedResourceInfo) -> System.Threading.Tasks.ValueTask +virtual Microsoft.OData.ODataWriter.WriteStartAsync(Microsoft.OData.ODataPropertyInfo primitiveProperty) -> System.Threading.Tasks.ValueTask +virtual Microsoft.OData.ODataWriter.WriteStartAsync(Microsoft.OData.ODataResource resource) -> System.Threading.Tasks.ValueTask +virtual Microsoft.OData.ODataWriter.WriteStartAsync(Microsoft.OData.ODataResourceSet resourceSet) -> System.Threading.Tasks.ValueTask virtual Microsoft.OData.UriParser.ODataUriResolver.EnableCaseInsensitive.get -> bool virtual Microsoft.OData.UriParser.ODataUriResolver.EnableCaseInsensitive.set -> void virtual Microsoft.OData.UriParser.ODataUriResolver.EnableNoDollarQueryOptions.get -> bool diff --git a/src/Microsoft.OData.Core/StreamReaderDelegate.cs b/src/Microsoft.OData.Core/StreamReaderDelegate.cs index ec3b9d11e0..0f3e6f3ba0 100644 --- a/src/Microsoft.OData.Core/StreamReaderDelegate.cs +++ b/src/Microsoft.OData.Core/StreamReaderDelegate.cs @@ -36,5 +36,5 @@ namespace Microsoft.OData /// or 0 if at the end of the stream and no data was read. /// The number will be less than or equal to the parameter, /// depending on whether the data is available within the stream. - internal delegate Task AsyncStreamReaderDelegate(char[] chars, int offset, int maxLength); + internal delegate ValueTask AsyncStreamReaderDelegate(char[] chars, int offset, int maxLength); } diff --git a/src/Microsoft.OData.Core/TaskUtils.cs b/src/Microsoft.OData.Core/TaskUtils.cs index 730421fb57..afcabdf30c 100644 --- a/src/Microsoft.OData.Core/TaskUtils.cs +++ b/src/Microsoft.OData.Core/TaskUtils.cs @@ -421,6 +421,155 @@ internal static Task GetTaskForSynchronousOperation( } } + /// + /// Returns an already completed task for the specified synchronous operation. + /// + /// The synchronous operation to perform. + /// An already completed task. If the succeeded this will be a successfully completed task, + /// otherwise it will be a faulted task holding the exception thrown. + /// The advantage of this method over CompletedTask property is that if the fails + /// this method returns a faulted task, instead of throwing an exception. + internal static ValueTask GetValueTaskForSynchronousOperation(Action synchronousOperation) + { + Debug.Assert(synchronousOperation != null, "synchronousOperation != null"); + + try + { + synchronousOperation(); + return ValueTask.CompletedTask; + } + catch (Exception e) + { + if (!ExceptionUtils.IsCatchableExceptionType(e)) + { + throw; + } + + return ValueTask.FromException(e); + } + } + + /// + /// Returns an already completed task for the specified synchronous operation. + /// + /// The delegate first argument type. + /// The delegate second argument type. + /// The synchronous operation to perform. + /// The first argument value provided to the delegate. + /// The second argument value provided to the delegate. + /// + /// An already completed task. If the + /// succeeded this will be a successfully completed task, + /// otherwise it will be a faulted task holding the exception thrown. + /// + /// + /// The advantage of this method over property + /// is that if the fails + /// this method returns a faulted task, instead of throwing an exception. + /// + internal static ValueTask GetValueTaskForSynchronousOperation( + Action synchronousOperation, + TArg1 arg1, + TArg2 arg2) + { + Debug.Assert(synchronousOperation != null, "synchronousOperation != null"); + + try + { + synchronousOperation(arg1, arg2); + return ValueTask.CompletedTask; + } + catch (Exception e) + { + if (!ExceptionUtils.IsCatchableExceptionType(e)) + { + throw; + } + + return ValueTask.FromException(e); + } + } + + /// + /// Returns an already completed task for the specified synchronous operation. + /// + /// The delegate argument type. + /// The synchronous operation to perform. + /// The argument value provided to the delegate. + /// + /// An already completed task. If the + /// succeeded this will be a successfully completed task, + /// otherwise it will be a faulted task holding the exception thrown. + /// + /// + /// The advantage of this method over property + /// is that if the fails + /// this method returns a faulted task, instead of throwing an exception. + /// + internal static ValueTask GetValueTaskForSynchronousOperation( + Action synchronousOperation, + TArg arg) + { + Debug.Assert(synchronousOperation != null, "synchronousOperation != null"); + + try + { + synchronousOperation(arg); + return ValueTask.CompletedTask; + } + catch (Exception e) + { + if (!ExceptionUtils.IsCatchableExceptionType(e)) + { + throw; + } + + return ValueTask.FromException(e); + } + } + + /// + /// Returns an already completed task for the specified synchronous operation. + /// + /// The type of the result returned by the operation. This MUST NOT be a Task type. + /// The delegate first argument type. + /// The synchronous operation to perform. + /// The first argument value provided to the delegate. + /// + /// An already completed task. If the + /// succeeded this will be a successfully completed task, + /// otherwise it will be a faulted task holding the exception thrown. + /// + /// + /// The advantage of this method over property + /// is that if the fails + /// this method returns a faulted task, instead of throwing an exception. + /// + internal static ValueTask GetValueTaskForSynchronousOperation( + Func synchronousOperation, + TArg arg) + { + Debug.Assert(synchronousOperation != null, "synchronousOperation != null"); + Debug.Assert(!typeof(Task).IsAssignableFrom(typeof(TResult)), + "This method doesn't support operations returning Task instances."); + + try + { + TResult result = synchronousOperation(arg); + return ValueTask.FromResult(result); + } + catch (Exception e) + { + if (!ExceptionUtils.IsCatchableExceptionType(e)) + { + throw; + } + + return ValueTask.FromException(e); + } + } + + /// /// Returns an already completed task for the specified synchronous operation. /// diff --git a/src/Microsoft.OData.Edm/Microsoft.OData.Edm.csproj b/src/Microsoft.OData.Edm/Microsoft.OData.Edm.csproj index f9f6b95195..33cfd0aba7 100644 --- a/src/Microsoft.OData.Edm/Microsoft.OData.Edm.csproj +++ b/src/Microsoft.OData.Edm/Microsoft.OData.Edm.csproj @@ -1,7 +1,7 @@  - net8.0 + net8.0 Microsoft.OData.Edm Microsoft.OData.Edm $(AssemblyName).xml diff --git a/src/Microsoft.Spatial/Microsoft.Spatial.csproj b/src/Microsoft.Spatial/Microsoft.Spatial.csproj index ef616b13b5..cd7b3a0361 100644 --- a/src/Microsoft.Spatial/Microsoft.Spatial.csproj +++ b/src/Microsoft.Spatial/Microsoft.Spatial.csproj @@ -1,6 +1,6 @@  - net8.0 + net8.0 Microsoft.Spatial Microsoft.Spatial diff --git a/test/Common/Microsoft.Test.OData.DependencyInjection/Microsoft.Test.OData.DependencyInjection.csproj b/test/Common/Microsoft.Test.OData.DependencyInjection/Microsoft.Test.OData.DependencyInjection.csproj index 7fe1e22d22..c40c5027c6 100644 --- a/test/Common/Microsoft.Test.OData.DependencyInjection/Microsoft.Test.OData.DependencyInjection.csproj +++ b/test/Common/Microsoft.Test.OData.DependencyInjection/Microsoft.Test.OData.DependencyInjection.csproj @@ -1,7 +1,7 @@  Microsoft.Test.OData.DependencyInjection - net8.0 + net8.0 Private true false diff --git a/test/FunctionalTests/Microsoft.OData.Client.Tests/Microsoft.OData.Client.Tests.csproj b/test/FunctionalTests/Microsoft.OData.Client.Tests/Microsoft.OData.Client.Tests.csproj index b1b942ea00..d4abb3248b 100644 --- a/test/FunctionalTests/Microsoft.OData.Client.Tests/Microsoft.OData.Client.Tests.csproj +++ b/test/FunctionalTests/Microsoft.OData.Client.Tests/Microsoft.OData.Client.Tests.csproj @@ -4,7 +4,7 @@ AnyCPU false Microsoft.OData.Client.Tests - net8.0 + net8.0 ..\..\..\..\sln\ true false diff --git a/test/FunctionalTests/Microsoft.OData.Core.Tests/Json/BufferingJsonReaderTests.cs b/test/FunctionalTests/Microsoft.OData.Core.Tests/Json/BufferingJsonReaderTests.cs index acbedd406e..d5b885a1f4 100644 --- a/test/FunctionalTests/Microsoft.OData.Core.Tests/Json/BufferingJsonReaderTests.cs +++ b/test/FunctionalTests/Microsoft.OData.Core.Tests/Json/BufferingJsonReaderTests.cs @@ -136,7 +136,7 @@ public async Task ReadInStreamErrorPropertyAsync_ThrowsExceptionForODataErrorRea // Act var exception = await Assert.ThrowsAsync( - () => bufferingReader.ReadAsync()); + async () => await bufferingReader.ReadAsync()); // Assert var error = exception.Error; @@ -361,7 +361,7 @@ public async Task ReadInStreamErrorPropertyAsync_SkipsNonSupportedPropertiesInIn // Act var exception = await Assert.ThrowsAsync( - () => bufferingReader.ReadAsync()); + async () => await bufferingReader.ReadAsync()); // Assert var error = exception.Error; @@ -393,7 +393,7 @@ public async Task ReadInStreamErrorPropertyAsync_SkipsNonSupportedPropertiesInEr // Act var exception = await Assert.ThrowsAsync( - () => bufferingReader.ReadAsync()); + async () => await bufferingReader.ReadAsync()); // Assert var error = exception.Error; diff --git a/test/FunctionalTests/Microsoft.OData.Core.Tests/Json/JsonWriterAsyncTests.cs b/test/FunctionalTests/Microsoft.OData.Core.Tests/Json/JsonWriterAsyncTests.cs index 66dd3983ad..f4eeacd1ea 100644 --- a/test/FunctionalTests/Microsoft.OData.Core.Tests/Json/JsonWriterAsyncTests.cs +++ b/test/FunctionalTests/Microsoft.OData.Core.Tests/Json/JsonWriterAsyncTests.cs @@ -391,14 +391,14 @@ public Task WriteNameAsyncUsesProvidedCharArrayPool() // Note: CharArrayPool is used if string has special chars // This test is mostly theoretical since special characters are not allowed in names return SetupJsonWriterRunTestAndVerifyRentAsync( - (jsonWriter) => jsonWriter.WriteNameAsync("foo\tbar")); + async (jsonWriter) => await jsonWriter.WriteNameAsync("foo\tbar")); } [Fact] public Task WriteStringValueUsesProvidedCharArrayPool() { return SetupJsonWriterRunTestAndVerifyRentAsync( - (jsonWriter) => jsonWriter.WriteValueAsync("foo\tbar")); + async (jsonWriter) => await jsonWriter.WriteValueAsync("foo\tbar")); } private async Task SetupJsonWriterRunTestAndVerifyRentAsync(Func func) diff --git a/test/FunctionalTests/Microsoft.OData.Core.Tests/Json/MockJsonWriter.cs b/test/FunctionalTests/Microsoft.OData.Core.Tests/Json/MockJsonWriter.cs index 1f685c05d2..91999589cc 100644 --- a/test/FunctionalTests/Microsoft.OData.Core.Tests/Json/MockJsonWriter.cs +++ b/test/FunctionalTests/Microsoft.OData.Core.Tests/Json/MockJsonWriter.cs @@ -99,80 +99,80 @@ public void WriteRawValue(string rawValue) public void Flush() => throw new NotImplementedException(); - public Task StartPaddingFunctionScopeAsync() => throw new NotImplementedException(); + public ValueTask StartPaddingFunctionScopeAsync() => throw new NotImplementedException(); - public Task EndPaddingFunctionScopeAsync() => throw new NotImplementedException(); + public ValueTask EndPaddingFunctionScopeAsync() => throw new NotImplementedException(); - public Task StartObjectScopeAsync() => throw new NotImplementedException(); + public ValueTask StartObjectScopeAsync() => throw new NotImplementedException(); - public Task EndObjectScopeAsync() => throw new NotImplementedException(); + public ValueTask EndObjectScopeAsync() => throw new NotImplementedException(); - public Task StartArrayScopeAsync() => throw new NotImplementedException(); + public ValueTask StartArrayScopeAsync() => throw new NotImplementedException(); - public Task EndArrayScopeAsync() => throw new NotImplementedException(); + public ValueTask EndArrayScopeAsync() => throw new NotImplementedException(); - public Task WriteNameAsync(string name) + public ValueTask WriteNameAsync(string name) { Assert.NotNull(this.WriteNameVerifier); this.WriteNameVerifier(name); - return TaskUtils.CompletedTask; + return ValueTask.CompletedTask; } - public Task WritePaddingFunctionNameAsync(string functionName) => throw new NotImplementedException(); + public ValueTask WritePaddingFunctionNameAsync(string functionName) => throw new NotImplementedException(); - public Task WriteValueAsync(bool value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(bool value) => throw new NotImplementedException(); - public Task WriteValueAsync(int value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(int value) => throw new NotImplementedException(); - public Task WriteValueAsync(float value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(float value) => throw new NotImplementedException(); - public Task WriteValueAsync(short value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(short value) => throw new NotImplementedException(); - public Task WriteValueAsync(long value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(long value) => throw new NotImplementedException(); - public Task WriteValueAsync(double value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(double value) => throw new NotImplementedException(); - public Task WriteValueAsync(Guid value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(Guid value) => throw new NotImplementedException(); - public Task WriteValueAsync(decimal value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(decimal value) => throw new NotImplementedException(); - public Task WriteValueAsync(DateTimeOffset value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(DateTimeOffset value) => throw new NotImplementedException(); - public Task WriteValueAsync(TimeSpan value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(TimeSpan value) => throw new NotImplementedException(); - public Task WriteValueAsync(byte value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(byte value) => throw new NotImplementedException(); - public Task WriteValueAsync(sbyte value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(sbyte value) => throw new NotImplementedException(); - public Task WriteValueAsync(string value) + public ValueTask WriteValueAsync(string value) { Assert.NotNull(this.WriteValueVerifier); this.WriteValueVerifier(value); - return TaskUtils.CompletedTask; + return ValueTask.CompletedTask; } - public Task WriteValueAsync(byte[] value) + public ValueTask WriteValueAsync(byte[] value) { Assert.NotNull(this.WriteValueVerifier); this.WriteValueVerifier(Convert.ToBase64String(value)); - return TaskUtils.CompletedTask; + return ValueTask.CompletedTask; } - public Task WriteValueAsync(Date value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(Date value) => throw new NotImplementedException(); - public Task WriteValueAsync(TimeOfDay value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(TimeOfDay value) => throw new NotImplementedException(); - public Task WriteRawValueAsync(string rawValue) + public ValueTask WriteRawValueAsync(string rawValue) { Assert.NotNull(this.WriteValueVerifier); this.WriteValueVerifier(rawValue); - return TaskUtils.CompletedTask; + return ValueTask.CompletedTask; } public Task FlushAsync() => throw new NotImplementedException(); #if NETCOREAPP - public Task WriteValueAsync(JsonElement value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(JsonElement value) => throw new NotImplementedException(); #endif public Stream StartStreamValueScope() => throw new NotImplementedException(); @@ -183,12 +183,12 @@ public Task WriteRawValueAsync(string rawValue) public void EndTextWriterValueScope() => throw new NotImplementedException(); - public Task StartStreamValueScopeAsync() => throw new NotImplementedException(); + public ValueTask StartStreamValueScopeAsync() => throw new NotImplementedException(); - public Task StartTextWriterValueScopeAsync(string contentType) => throw new NotImplementedException(); + public ValueTask StartTextWriterValueScopeAsync(string contentType) => throw new NotImplementedException(); - public Task EndStreamValueScopeAsync() => throw new NotImplementedException(); + public ValueTask EndStreamValueScopeAsync() => throw new NotImplementedException(); - public Task EndTextWriterValueScopeAsync() => throw new NotImplementedException(); + public ValueTask EndTextWriterValueScopeAsync() => throw new NotImplementedException(); } } \ No newline at end of file diff --git a/test/FunctionalTests/Microsoft.OData.Core.Tests/JsonLight/ODataJsonLightOutputContextTests.cs b/test/FunctionalTests/Microsoft.OData.Core.Tests/JsonLight/ODataJsonLightOutputContextTests.cs index aed94e2d0e..360dc6da3d 100644 --- a/test/FunctionalTests/Microsoft.OData.Core.Tests/JsonLight/ODataJsonLightOutputContextTests.cs +++ b/test/FunctionalTests/Microsoft.OData.Core.Tests/JsonLight/ODataJsonLightOutputContextTests.cs @@ -480,7 +480,7 @@ public async Task WritePropertyAsync() }; var result = await SetupJsonLightOutputContextAndRunTestAsync( - (jsonLightOutputContext) => jsonLightOutputContext.WritePropertyAsync(property)); + async (jsonLightOutputContext) => await jsonLightOutputContext.WritePropertyAsync(property)); Assert.Equal( "{\"@odata.context\":\"http://tempuri.org/$metadata#Edm.Int32\",\"@Is.LuckyNumber\":true,\"value\":13}", @@ -499,7 +499,7 @@ public async Task WriteSpatialPropertyAsync() }; var result = await SetupJsonLightOutputContextAndRunTestAsync( - (jsonLightOutputContext) => jsonLightOutputContext.WritePropertyAsync(geographyProperty)); + async (jsonLightOutputContext) => await jsonLightOutputContext.WritePropertyAsync(geographyProperty)); Assert.Equal( "{\"@odata.context\":\"http://tempuri.org/$metadata#Edm.GeographyPoint\"," + @@ -533,7 +533,7 @@ public async Task WriteSpatialCollectionPropertyAsync() }; var result = await SetupJsonLightOutputContextAndRunTestAsync( - (jsonLightOutputContext) => jsonLightOutputContext.WritePropertyAsync(geographyCollectionProperty)); + async (jsonLightOutputContext) => await jsonLightOutputContext.WritePropertyAsync(geographyCollectionProperty)); Assert.Equal( "{\"@odata.context\":\"http://tempuri.org/$metadata#Collection(Edm.Geography)\"," + @@ -604,7 +604,7 @@ public async Task WriteEntityReferenceLinkAsync(bool writingResponse) }; var result = await SetupJsonLightOutputContextAndRunTestAsync( - (jsonLightOutputContext) => jsonLightOutputContext.WriteEntityReferenceLinkAsync(entityReferenceLink), + async (jsonLightOutputContext) => await jsonLightOutputContext.WriteEntityReferenceLinkAsync(entityReferenceLink), writingResponse); Assert.Equal( @@ -627,7 +627,7 @@ public async Task WriteEntityReferenceLinksAsync(bool writingResponse) }; var result = await SetupJsonLightOutputContextAndRunTestAsync( - (jsonLightOutputContext) => jsonLightOutputContext.WriteEntityReferenceLinksAsync(entityReferenceLinks), + async (jsonLightOutputContext) => await jsonLightOutputContext.WriteEntityReferenceLinksAsync(entityReferenceLinks), writingResponse); Assert.Equal( @@ -649,7 +649,7 @@ public async Task WriteServiceDocumentAsync() }; var result = await SetupJsonLightOutputContextAndRunTestAsync( - (jsonLightOutputContext) => jsonLightOutputContext.WriteServiceDocumentAsync(serviceDocument)); + async (jsonLightOutputContext) => await jsonLightOutputContext.WriteServiceDocumentAsync(serviceDocument)); Assert.Equal( "{\"@odata.context\":\"http://tempuri.org/$metadata\"," + @@ -663,7 +663,7 @@ public async Task WriteServiceDocumentAsync() public async Task WriteErrorAsync() { var result = await SetupJsonLightOutputContextAndRunTestAsync( - (jsonLightOutputContext) => jsonLightOutputContext.WriteErrorAsync(this.nullReferenceError, /*includeDebugInformation*/ false)); + async (jsonLightOutputContext) => await jsonLightOutputContext.WriteErrorAsync(this.nullReferenceError, /*includeDebugInformation*/ false)); Assert.Equal( "{\"error\":{\"code\":\"NRE\",\"message\":\"Object reference not set to an instance of an object\",\"@Is.Error\":true}}", @@ -818,6 +818,20 @@ private async Task SetupJsonLightOutputContextAndRunTestAsync( return await new StreamReader(this.stream).ReadToEndAsync(); } + //private async ValueTask SetupJsonLightOutputContextAndRunTestAsync( + // Func func, + // bool writingResponse = true) + //{ + // this.stream = new AsyncStream(this.stream); + // var messageInfo = CreateMessageInfo(this.model, asynchronous: true, writingResponse: writingResponse); + // var jsonLightOutputContext = new ODataJsonLightOutputContext(messageInfo, this.messageWriterSettings); + + // await func(jsonLightOutputContext); + + // this.stream.Position = 0; + // return await new StreamReader(this.stream).ReadToEndAsync(); + //} + private ODataMessageInfo CreateMessageInfo(IEdmModel model, bool asynchronous = true, bool writingResponse = true) { return new ODataMessageInfo diff --git a/test/FunctionalTests/Microsoft.OData.Core.Tests/JsonLight/ODataJsonLightSerializerTests.cs b/test/FunctionalTests/Microsoft.OData.Core.Tests/JsonLight/ODataJsonLightSerializerTests.cs index 4fea060317..d2c956013f 100644 --- a/test/FunctionalTests/Microsoft.OData.Core.Tests/JsonLight/ODataJsonLightSerializerTests.cs +++ b/test/FunctionalTests/Microsoft.OData.Core.Tests/JsonLight/ODataJsonLightSerializerTests.cs @@ -368,9 +368,9 @@ public async Task WriteTopLevelPayloadAsync_WritesTopLevelPayload() (jsonLightSerializer) => { return jsonLightSerializer.WriteTopLevelPayloadAsync( - () => + async () => { - return jsonLightSerializer.JsonWriter.WriteValueAsync(13); + await jsonLightSerializer.JsonWriter.WriteValueAsync(13); }); }); diff --git a/test/FunctionalTests/Microsoft.OData.Core.Tests/JsonLight/ODataJsonLightWriterTests.cs b/test/FunctionalTests/Microsoft.OData.Core.Tests/JsonLight/ODataJsonLightWriterTests.cs index 13cf06c22f..da3f3ab63c 100644 --- a/test/FunctionalTests/Microsoft.OData.Core.Tests/JsonLight/ODataJsonLightWriterTests.cs +++ b/test/FunctionalTests/Microsoft.OData.Core.Tests/JsonLight/ODataJsonLightWriterTests.cs @@ -2194,7 +2194,7 @@ public async Task WriteEndAsync_ThrowsExceptionForBinaryStreamNotDisposed() /// then flushes and reads the stream back as a string for customized verification. /// private async Task SetupJsonLightWriterAndRunTestAsync( - Func func, + Func func, IEdmNavigationSource navigationSource, IEdmStructuredType resourceType, bool writingResourceSet = false, diff --git a/test/FunctionalTests/Microsoft.OData.Core.Tests/JsonLight/ReorderingJsonReaderTests.cs b/test/FunctionalTests/Microsoft.OData.Core.Tests/JsonLight/ReorderingJsonReaderTests.cs index 681c19d72e..6cb2712758 100644 --- a/test/FunctionalTests/Microsoft.OData.Core.Tests/JsonLight/ReorderingJsonReaderTests.cs +++ b/test/FunctionalTests/Microsoft.OData.Core.Tests/JsonLight/ReorderingJsonReaderTests.cs @@ -502,7 +502,7 @@ public async Task CreateTextStreamAsync_ThrowsExceptionForReaderNotOnPropertyNod var exception = await Assert.ThrowsAsync( () => SetupReorderingJsonReaderAndRunTestAsync( payload, - (reorderingReader) => reorderingReader.CreateTextReaderAsync())); + async (reorderingReader) => await reorderingReader.CreateTextReaderAsync())); Assert.Equal( ErrorStrings.JsonReader_CannotCreateTextReader, diff --git a/test/FunctionalTests/Microsoft.OData.Core.Tests/Microsoft.OData.Core.Tests.csproj b/test/FunctionalTests/Microsoft.OData.Core.Tests/Microsoft.OData.Core.Tests.csproj index cb3034cf0d..31f9e884b5 100644 --- a/test/FunctionalTests/Microsoft.OData.Core.Tests/Microsoft.OData.Core.Tests.csproj +++ b/test/FunctionalTests/Microsoft.OData.Core.Tests/Microsoft.OData.Core.Tests.csproj @@ -3,7 +3,7 @@ Debug AnyCPU Microsoft.OData.Core.Tests - net8.0 + net8.0 40 2.0 false diff --git a/test/FunctionalTests/Microsoft.OData.Core.Tests/ODataBinaryStreamReaderTests.cs b/test/FunctionalTests/Microsoft.OData.Core.Tests/ODataBinaryStreamReaderTests.cs index 1d2ab752af..39eb88536e 100644 --- a/test/FunctionalTests/Microsoft.OData.Core.Tests/ODataBinaryStreamReaderTests.cs +++ b/test/FunctionalTests/Microsoft.OData.Core.Tests/ODataBinaryStreamReaderTests.cs @@ -35,7 +35,7 @@ private int ReadChars(char[] chars, int offset, int maxLength) return bytesRead; } - private async Task ReadCharsAsync(char[] chars, int offset, int maxLength) + private async ValueTask ReadCharsAsync(char[] chars, int offset, int maxLength) { var buffer = new byte[maxLength]; int bytesRead = await this.stream.ReadAsync(buffer, offset, maxLength); diff --git a/test/FunctionalTests/Microsoft.OData.Core.Tests/ODataMessageWriterTests.cs b/test/FunctionalTests/Microsoft.OData.Core.Tests/ODataMessageWriterTests.cs index 77e0c7541f..859939cbc3 100644 --- a/test/FunctionalTests/Microsoft.OData.Core.Tests/ODataMessageWriterTests.cs +++ b/test/FunctionalTests/Microsoft.OData.Core.Tests/ODataMessageWriterTests.cs @@ -300,7 +300,7 @@ public async Task SupportsODataUtf8JsonWriterAsync() string output = await WriteAndGetPayloadAsync( model, "application/json", - (writer) => writer.WritePropertyAsync(new ODataProperty() + async (writer) => await writer.WritePropertyAsync(new ODataProperty() { Name = "Name", Value = "This is a test ия" @@ -326,7 +326,7 @@ public async Task WhenInjectingODataUtf8JsonWriterFactoryAsync_CreatesWriterUsin EdmModel model = new EdmModel(); // Act - Func writePropertyAsync = (writer) => writer.WritePropertyAsync(new ODataProperty() + Func writePropertyAsync = async (writer) => await writer.WritePropertyAsync(new ODataProperty() { Name = "Name", Value = "This is a test ия" diff --git a/test/FunctionalTests/Microsoft.OData.Core.Tests/ODataRawOutputContextTests.cs b/test/FunctionalTests/Microsoft.OData.Core.Tests/ODataRawOutputContextTests.cs index 33c1915621..bcab02110c 100644 --- a/test/FunctionalTests/Microsoft.OData.Core.Tests/ODataRawOutputContextTests.cs +++ b/test/FunctionalTests/Microsoft.OData.Core.Tests/ODataRawOutputContextTests.cs @@ -45,7 +45,7 @@ public ODataRawOutputContextTests() public async Task WriteValueAsync() { var result = await SetupRawOutputContextAndRunTestAsync( - (rawOutputContext) => rawOutputContext.WriteValueAsync("foobar")); + async (rawOutputContext) => await rawOutputContext.WriteValueAsync("foobar")); Assert.Equal("foobar", result); } diff --git a/test/FunctionalTests/Microsoft.OData.Core.Tests/ODataTextStreamReaderTests.cs b/test/FunctionalTests/Microsoft.OData.Core.Tests/ODataTextStreamReaderTests.cs index 5adbe1ca7d..1b8ace6bf2 100644 --- a/test/FunctionalTests/Microsoft.OData.Core.Tests/ODataTextStreamReaderTests.cs +++ b/test/FunctionalTests/Microsoft.OData.Core.Tests/ODataTextStreamReaderTests.cs @@ -35,7 +35,7 @@ private int ReadChars(char[] chars, int offset, int maxLength) return bytesRead; } - private async Task ReadCharsAsync(char[] chars, int offset, int maxLength) + private async ValueTask ReadCharsAsync(char[] chars, int offset, int maxLength) { var buffer = new byte[maxLength]; int bytesRead = await this.stream.ReadAsync(buffer, offset, maxLength); diff --git a/test/FunctionalTests/Microsoft.OData.Core.Tests/ScenarioTests/Roundtrip/JsonReaderWriterInjectionTests.cs b/test/FunctionalTests/Microsoft.OData.Core.Tests/ScenarioTests/Roundtrip/JsonReaderWriterInjectionTests.cs index a09dc2d3f5..82e0930eeb 100644 --- a/test/FunctionalTests/Microsoft.OData.Core.Tests/ScenarioTests/Roundtrip/JsonReaderWriterInjectionTests.cs +++ b/test/FunctionalTests/Microsoft.OData.Core.Tests/ScenarioTests/Roundtrip/JsonReaderWriterInjectionTests.cs @@ -473,25 +473,25 @@ public void Flush() this.textWriter.Flush(); } - public Task StartPaddingFunctionScopeAsync() => throw new NotImplementedException(); + public ValueTask StartPaddingFunctionScopeAsync() => throw new NotImplementedException(); - public Task EndPaddingFunctionScopeAsync() => throw new NotImplementedException(); + public ValueTask EndPaddingFunctionScopeAsync() => throw new NotImplementedException(); - public Task StartObjectScopeAsync() + public async ValueTask StartObjectScopeAsync() { - return this.textWriter.WriteAsync('<'); + await this.textWriter.WriteAsync('<'); } - public Task EndObjectScopeAsync() + public async ValueTask EndObjectScopeAsync() { - return this.textWriter.WriteAsync('>'); + await this.textWriter.WriteAsync('>'); } - public Task StartArrayScopeAsync() => throw new NotImplementedException(); + public ValueTask StartArrayScopeAsync() => throw new NotImplementedException(); - public Task EndArrayScopeAsync() => throw new NotImplementedException(); + public ValueTask EndArrayScopeAsync() => throw new NotImplementedException(); - public async Task WriteNameAsync(string name) + public async ValueTask WriteNameAsync(string name) { if (name.StartsWith("@odata.")) { @@ -501,47 +501,47 @@ public async Task WriteNameAsync(string name) await this.textWriter.WriteAsync(string.Format("\"{0}\":", name)); } - public Task WritePaddingFunctionNameAsync(string functionName) => throw new NotImplementedException(); + public ValueTask WritePaddingFunctionNameAsync(string functionName) => throw new NotImplementedException(); - public Task WriteValueAsync(bool value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(bool value) => throw new NotImplementedException(); - public Task WriteValueAsync(int value) + public async ValueTask WriteValueAsync(int value) { - return this.textWriter.WriteAsync(string.Format("{0},", value)); + await this.textWriter.WriteAsync(string.Format("{0},", value)); } - public Task WriteValueAsync(float value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(float value) => throw new NotImplementedException(); - public Task WriteValueAsync(short value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(short value) => throw new NotImplementedException(); - public Task WriteValueAsync(long value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(long value) => throw new NotImplementedException(); - public Task WriteValueAsync(double value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(double value) => throw new NotImplementedException(); - public Task WriteValueAsync(Guid value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(Guid value) => throw new NotImplementedException(); - public Task WriteValueAsync(decimal value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(decimal value) => throw new NotImplementedException(); - public Task WriteValueAsync(DateTimeOffset value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(DateTimeOffset value) => throw new NotImplementedException(); - public Task WriteValueAsync(TimeSpan value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(TimeSpan value) => throw new NotImplementedException(); - public Task WriteValueAsync(byte value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(byte value) => throw new NotImplementedException(); - public Task WriteValueAsync(sbyte value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(sbyte value) => throw new NotImplementedException(); - public Task WriteValueAsync(string value) + public async ValueTask WriteValueAsync(string value) { - return this.textWriter.WriteAsync(string.Format("\"{0}\",", value)); + await this.textWriter.WriteAsync(string.Format("\"{0}\",", value)); } - public Task WriteValueAsync(byte[] value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(byte[] value) => throw new NotImplementedException(); - public Task WriteValueAsync(Date value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(Date value) => throw new NotImplementedException(); - public Task WriteValueAsync(TimeOfDay value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(TimeOfDay value) => throw new NotImplementedException(); - public Task WriteRawValueAsync(string rawValue) => throw new NotImplementedException(); + public ValueTask WriteRawValueAsync(string rawValue) => throw new NotImplementedException(); public Task FlushAsync() { @@ -549,7 +549,7 @@ public Task FlushAsync() } #if NETCOREAPP - public Task WriteValueAsync(JsonElement value) => throw new NotImplementedException(); + public ValueTask WriteValueAsync(JsonElement value) => throw new NotImplementedException(); #endif public Stream StartStreamValueScope() => throw new NotImplementedException(); @@ -560,13 +560,13 @@ public Task FlushAsync() public void EndTextWriterValueScope() => throw new NotImplementedException(); - public Task StartStreamValueScopeAsync() => throw new NotImplementedException(); + public ValueTask StartStreamValueScopeAsync() => throw new NotImplementedException(); - public Task StartTextWriterValueScopeAsync(string contentType) => throw new NotImplementedException(); + public ValueTask StartTextWriterValueScopeAsync(string contentType) => throw new NotImplementedException(); - public Task EndStreamValueScopeAsync() => throw new NotImplementedException(); + public ValueTask EndStreamValueScopeAsync() => throw new NotImplementedException(); - public Task EndTextWriterValueScopeAsync() => throw new NotImplementedException(); + public ValueTask EndTextWriterValueScopeAsync() => throw new NotImplementedException(); } private class TestJsonReader : IJsonReader @@ -638,21 +638,21 @@ public bool Read() return true; } - public Task ReadAsync() => throw new NotImplementedException(); + public ValueTask ReadAsync() => throw new NotImplementedException(); public bool CanStream() => throw new NotImplementedException(); - public Task CanStreamAsync() => throw new NotImplementedException(); + public ValueTask CanStreamAsync() => throw new NotImplementedException(); public Stream CreateReadStream() => throw new NotImplementedException(); - public Task CreateReadStreamAsync() => throw new NotImplementedException(); + public ValueTask CreateReadStreamAsync() => throw new NotImplementedException(); public TextReader CreateTextReader() => throw new NotImplementedException(); - public Task CreateTextReaderAsync() => throw new NotImplementedException(); + public ValueTask CreateTextReaderAsync() => throw new NotImplementedException(); - public Task GetValueAsync() => throw new NotImplementedException(); + public ValueTask GetValueAsync() => throw new NotImplementedException(); } } } diff --git a/test/FunctionalTests/Microsoft.OData.Core.Tests/ScenarioTests/Writer/JsonLight/ODataJsonLightInheritComplexCollectionWriterTests.cs b/test/FunctionalTests/Microsoft.OData.Core.Tests/ScenarioTests/Writer/JsonLight/ODataJsonLightInheritComplexCollectionWriterTests.cs index 14fbcd4e41..f887a1e80d 100644 --- a/test/FunctionalTests/Microsoft.OData.Core.Tests/ScenarioTests/Writer/JsonLight/ODataJsonLightInheritComplexCollectionWriterTests.cs +++ b/test/FunctionalTests/Microsoft.OData.Core.Tests/ScenarioTests/Writer/JsonLight/ODataJsonLightInheritComplexCollectionWriterTests.cs @@ -11,6 +11,7 @@ using Microsoft.OData.JsonLight; using Microsoft.OData.Edm; using Xunit; +using System.Threading.Tasks; namespace Microsoft.OData.Tests.ScenarioTests.Writer.JsonLight { @@ -223,21 +224,20 @@ private static void WriteAndValidateSync(IEdmTypeReference itemTypeReference, OD ValidateWrittenPayload(stream, expectedPayload); } - private static void WriteAndValidateAsync(IEdmTypeReference itemTypeReference, ODataResourceSet collectionStart, IEnumerable items, string expectedPayload, bool writingResponse) + private static async Task WriteAndValidateAsync(IEdmTypeReference itemTypeReference, ODataResourceSet collectionStart, IEnumerable items, string expectedPayload, bool writingResponse) { MemoryStream stream = new MemoryStream(); var outputContext = CreateJsonLightOutputContext(stream, writingResponse, synchronous: false); - var createODataWriterTask = outputContext.CreateODataResourceSetWriterAsync(null, itemTypeReference == null ? null : itemTypeReference.ToStructuredType()); - createODataWriterTask.Wait(); - var odataWriter = createODataWriterTask.Result; - odataWriter.WriteStartAsync(collectionStart).Wait(); + + var odataWriter = await outputContext.CreateODataResourceSetWriterAsync(null, itemTypeReference == null ? null : itemTypeReference.ToStructuredType()); + await odataWriter.WriteStartAsync(collectionStart); foreach (ODataResource item in items) { - odataWriter.WriteStartAsync(item).Wait(); - odataWriter.WriteEndAsync().Wait(); + await odataWriter.WriteStartAsync(item); + await odataWriter.WriteEndAsync(); } - odataWriter.WriteEndAsync().Wait(); + await odataWriter.WriteEndAsync(); ValidateWrittenPayload(stream, expectedPayload); } diff --git a/test/FunctionalTests/Microsoft.OData.Edm.Tests/Microsoft.OData.Edm.Tests.csproj b/test/FunctionalTests/Microsoft.OData.Edm.Tests/Microsoft.OData.Edm.Tests.csproj index c8abb9bcc8..3c57f69d9d 100644 --- a/test/FunctionalTests/Microsoft.OData.Edm.Tests/Microsoft.OData.Edm.Tests.csproj +++ b/test/FunctionalTests/Microsoft.OData.Edm.Tests/Microsoft.OData.Edm.Tests.csproj @@ -4,7 +4,7 @@ AnyCPU true Microsoft.OData.Edm.Tests - net8.0 + net8.0 true false false diff --git a/test/FunctionalTests/Microsoft.OData.TestCommon/Microsoft.OData.TestCommon.csproj b/test/FunctionalTests/Microsoft.OData.TestCommon/Microsoft.OData.TestCommon.csproj index 263ff072be..e11c5719d2 100644 --- a/test/FunctionalTests/Microsoft.OData.TestCommon/Microsoft.OData.TestCommon.csproj +++ b/test/FunctionalTests/Microsoft.OData.TestCommon/Microsoft.OData.TestCommon.csproj @@ -1,7 +1,7 @@  Microsoft.OData.TestCommon - net8.0 + net8.0 true false false diff --git a/test/FunctionalTests/Microsoft.Spatial.Tests/Microsoft.Spatial.Tests.csproj b/test/FunctionalTests/Microsoft.Spatial.Tests/Microsoft.Spatial.Tests.csproj index 23b6800ffb..74e6e8d3c2 100644 --- a/test/FunctionalTests/Microsoft.Spatial.Tests/Microsoft.Spatial.Tests.csproj +++ b/test/FunctionalTests/Microsoft.Spatial.Tests/Microsoft.Spatial.Tests.csproj @@ -4,7 +4,7 @@ AnyCPU true Microsoft.Spatial.Tests - net8.0 + net8.0 true false false diff --git a/test/PerformanceTests/ComponentTests/Common/InMemoryMessage.cs b/test/PerformanceTests/ComponentTests/Common/InMemoryMessage.cs index 029bf4eb45..6142cb0d47 100644 --- a/test/PerformanceTests/ComponentTests/Common/InMemoryMessage.cs +++ b/test/PerformanceTests/ComponentTests/Common/InMemoryMessage.cs @@ -15,7 +15,7 @@ namespace Microsoft.OData.Performance /// Based on file with same name in test\FunctionalTests\Microsoft.OData.Core.Tests directory, which /// is not part of the ComponentTests project. /// - public class InMemoryMessage : IODataRequestMessage, IODataResponseMessage, IContainerProvider, IDisposable + public class InMemoryMessage : IODataRequestMessage, IODataResponseMessage, IServiceCollectionProvider, IDisposable { private readonly Dictionary headers; @@ -37,7 +37,7 @@ public IEnumerable> Headers public Stream Stream { get; set; } - public IServiceProvider Container { get; set; } + public IServiceProvider ServiceProvider { get; set; } public string GetHeader(string headerName) { diff --git a/test/PerformanceTests/ComponentTests/Common/ODataMessageHelper.cs b/test/PerformanceTests/ComponentTests/Common/ODataMessageHelper.cs index d15f27efae..7127445c19 100644 --- a/test/PerformanceTests/ComponentTests/Common/ODataMessageHelper.cs +++ b/test/PerformanceTests/ComponentTests/Common/ODataMessageHelper.cs @@ -8,9 +8,9 @@ namespace Microsoft.OData.Performance { using System; using System.IO; + using Microsoft.Extensions.DependencyInjection; using Microsoft.OData; using Microsoft.OData.Edm; - using Microsoft.OData.Performance.Common; /// /// Helper class to create ODataMessageReader and ODataMessageWriter @@ -34,18 +34,18 @@ public static class ODataMessageHelper /// /// Action callback to configure DI services. /// Instance of the DI container - private static IServiceProvider GetSharedContainer(Action configureServices = null) + private static IServiceProvider GetSharedContainer(Action configureServices = null) { if (container == null) { - var builder = new TestContainerBuilder(); - builder.AddDefaultODataServices(); + var serviceCollection = new ServiceCollection(); + serviceCollection.AddDefaultODataServices(); if (configureServices != null) { - configureServices(builder); + configureServices(serviceCollection); } - container = builder.BuildContainer(); + container = serviceCollection.BuildServiceProvider(); } return container; @@ -95,14 +95,14 @@ public static ODataMessageReader CreateMessageReader(Stream messageStream, IEdmM if (messageKind == ODataMessageKind.Request) { var message = new StreamBasedRequestMessage(messageStream); - message.Container = GetSharedContainer(); + message.ServiceProvider = GetSharedContainer(); message.SetHeader(ODataConstants.ContentTypeHeader, ContentType); return new ODataMessageReader(message, settings, model); } else { var message = new StreamBasedResponseMessage(messageStream); - message.Container = GetSharedContainer(); + message.ServiceProvider = GetSharedContainer(); message.SetHeader(ODataConstants.ContentTypeHeader, ContentType); return new ODataMessageReader(message, settings, model); } @@ -118,7 +118,7 @@ public static ODataMessageReader CreateMessageReader(Stream messageStream, IEdmM { var settings = CreateMessageReaderSettings(true); var message = new StreamBasedRequestMessage(messageStream); - message.Container = GetSharedContainer(); + message.ServiceProvider = GetSharedContainer(); message.SetHeader(ODataConstants.ContentTypeHeader, ContentType); return new ODataMessageReader(message, settings, model); } @@ -162,16 +162,16 @@ private static ODataMessageWriterSettings CreateMessageWriterSettings(bool isFul /// Whether turn on FullValidation /// Action callback to configure DI services. /// Instance of ODataMessageWriter - public static ODataMessageWriter CreateMessageWriter(Stream stream, IEdmModel model, ODataMessageKind messageKind, bool isFullValidation, Action configureServices = null) + public static ODataMessageWriter CreateMessageWriter(Stream stream, IEdmModel model, ODataMessageKind messageKind, bool isFullValidation, Action configureServices = null) { var settings = CreateMessageWriterSettings(isFullValidation); if (messageKind == ODataMessageKind.Request) { - return new ODataMessageWriter(new StreamBasedRequestMessage(stream) { Container = GetSharedContainer(configureServices) }, settings, model); + return new ODataMessageWriter(new StreamBasedRequestMessage(stream) { ServiceProvider = GetSharedContainer(configureServices) }, settings, model); } - return new ODataMessageWriter(new StreamBasedResponseMessage(stream) { Container = GetSharedContainer(configureServices) }, settings, model); + return new ODataMessageWriter(new StreamBasedResponseMessage(stream) { ServiceProvider = GetSharedContainer(configureServices) }, settings, model); } /// @@ -181,10 +181,10 @@ public static ODataMessageWriter CreateMessageWriter(Stream stream, IEdmModel mo /// Edm model /// Action callback to configure DI services. /// Instance of ODataMessageWriter - public static ODataMessageWriter CreateMessageWriter(Stream stream, IEdmModel model, Action configureServices = null) + public static ODataMessageWriter CreateMessageWriter(Stream stream, IEdmModel model, Action configureServices = null) { var settings = CreateMessageWriterSettings(true); - return new ODataMessageWriter(new StreamBasedRequestMessage(stream) { Container = GetSharedContainer(configureServices) }, settings, model); + return new ODataMessageWriter(new StreamBasedRequestMessage(stream) { ServiceProvider = GetSharedContainer(configureServices) }, settings, model); } #endregion } diff --git a/test/PerformanceTests/ComponentTests/Common/StreamBasedRequestMessage.cs b/test/PerformanceTests/ComponentTests/Common/StreamBasedRequestMessage.cs index a7f967d381..3e54ae8199 100644 --- a/test/PerformanceTests/ComponentTests/Common/StreamBasedRequestMessage.cs +++ b/test/PerformanceTests/ComponentTests/Common/StreamBasedRequestMessage.cs @@ -15,7 +15,7 @@ namespace Microsoft.OData.Performance /// /// An OData Request Message backed by a Stream. /// - public class StreamBasedRequestMessage : IODataRequestMessageAsync, IContainerProvider + public class StreamBasedRequestMessage : IODataRequestMessageAsync, IServiceCollectionProvider { private readonly Stream _stream; private readonly IDictionary _headers; @@ -88,6 +88,6 @@ public Uri Url } } - public IServiceProvider Container { get; set; } + public IServiceProvider ServiceProvider { get; set; } } } diff --git a/test/PerformanceTests/ComponentTests/Common/StreamBasedResponseMessage.cs b/test/PerformanceTests/ComponentTests/Common/StreamBasedResponseMessage.cs index e9df68a9af..ee4ae658f2 100644 --- a/test/PerformanceTests/ComponentTests/Common/StreamBasedResponseMessage.cs +++ b/test/PerformanceTests/ComponentTests/Common/StreamBasedResponseMessage.cs @@ -15,7 +15,7 @@ namespace Microsoft.OData.Performance /// /// An OData Response Message backed by a Stream. /// - public class StreamBasedResponseMessage : IODataResponseMessageAsync, IContainerProvider + public class StreamBasedResponseMessage : IODataResponseMessageAsync, IServiceCollectionProvider { private readonly Stream _stream; private readonly IDictionary _headers; @@ -66,6 +66,6 @@ public Stream GetStream() return _stream; } - public IServiceProvider Container { get; set; } + public IServiceProvider ServiceProvider { get; set; } } } diff --git a/test/PerformanceTests/ComponentTests/Common/TestContainerBuilder.cs b/test/PerformanceTests/ComponentTests/Common/TestContainerBuilder.cs deleted file mode 100644 index 37006a2a92..0000000000 --- a/test/PerformanceTests/ComponentTests/Common/TestContainerBuilder.cs +++ /dev/null @@ -1,64 +0,0 @@ -//--------------------------------------------------------------------- -// -// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. -// -//--------------------------------------------------------------------- - -namespace Microsoft.OData.Performance.Common -{ - using System; - using System.Diagnostics; - using Microsoft.Extensions.DependencyInjection; - - public class TestContainerBuilder : IContainerBuilder - { - private readonly IServiceCollection services = new ServiceCollection(); - - public IContainerBuilder AddService( - OData.ServiceLifetime lifetime, - Type serviceType, - Type implementationType) - { - Debug.Assert(serviceType != null, "serviceType != null"); - Debug.Assert(implementationType != null, "implementationType != null"); - - services.Add(new ServiceDescriptor( - serviceType, implementationType, TranslateServiceLifetime(lifetime))); - - return this; - } - - public IContainerBuilder AddService( - OData.ServiceLifetime lifetime, - Type serviceType, - Func implementationFactory) - { - Debug.Assert(serviceType != null, "serviceType != null"); - Debug.Assert(implementationFactory != null, "implementationFactory != null"); - - services.Add(new ServiceDescriptor( - serviceType, implementationFactory, TranslateServiceLifetime(lifetime))); - - return this; - } - - public IServiceProvider BuildContainer() - { - return services.BuildServiceProvider(); - } - - private static ServiceLifetime TranslateServiceLifetime( - OData.ServiceLifetime lifetime) - { - switch (lifetime) - { - case OData.ServiceLifetime.Scoped: - return ServiceLifetime.Scoped; - case OData.ServiceLifetime.Singleton: - return ServiceLifetime.Singleton; - default: - return ServiceLifetime.Transient; - } - } - } -} \ No newline at end of file diff --git a/test/PerformanceTests/ComponentTests/Microsoft.OData.Performance.ComponentTests.csproj b/test/PerformanceTests/ComponentTests/Microsoft.OData.Performance.ComponentTests.csproj index 306a4e9f7a..30c60c48c7 100644 --- a/test/PerformanceTests/ComponentTests/Microsoft.OData.Performance.ComponentTests.csproj +++ b/test/PerformanceTests/ComponentTests/Microsoft.OData.Performance.ComponentTests.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net8.0 @@ -29,8 +29,8 @@ - - + + diff --git a/test/PerformanceTests/ComponentTests/Microsoft.OData.Performance.ComponentTests.sln b/test/PerformanceTests/ComponentTests/Microsoft.OData.Performance.ComponentTests.sln new file mode 100644 index 0000000000..cf975c1650 --- /dev/null +++ b/test/PerformanceTests/ComponentTests/Microsoft.OData.Performance.ComponentTests.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34728.123 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OData.Performance.ComponentTests", "Microsoft.OData.Performance.ComponentTests.csproj", "{9EBA72FF-AC4D-44FF-A91F-0E7807900613}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9EBA72FF-AC4D-44FF-A91F-0E7807900613}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9EBA72FF-AC4D-44FF-A91F-0E7807900613}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9EBA72FF-AC4D-44FF-A91F-0E7807900613}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9EBA72FF-AC4D-44FF-A91F-0E7807900613}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {551F3CD4-51B0-4E2B-82CC-7860F9F1DB45} + EndGlobalSection +EndGlobal diff --git a/test/PerformanceTests/ComponentTests/ODataWriter/JsonElementPropertyTests.cs b/test/PerformanceTests/ComponentTests/ODataWriter/JsonElementPropertyTests.cs index 038bb68bcd..b4b18596cc 100644 --- a/test/PerformanceTests/ComponentTests/ODataWriter/JsonElementPropertyTests.cs +++ b/test/PerformanceTests/ComponentTests/ODataWriter/JsonElementPropertyTests.cs @@ -12,6 +12,7 @@ using System.Linq; using System.Xml; using Microsoft.OData.Json; +using Microsoft.Extensions.DependencyInjection; namespace Microsoft.OData.Performance.Writer { @@ -73,10 +74,10 @@ public void WriteParsedJsonWithoutJsonElementValues_Utf8JsonWriter() WriteParsedJsonWithoutJsonElementValues(ConfigureUtf8JsonWriter); } - private static void ConfigureUtf8JsonWriter(IContainerBuilder builder) => - builder.AddService(ServiceLifetime.Singleton, _ => DefaultStreamBasedJsonWriterFactory.Default); + private static void ConfigureUtf8JsonWriter(IServiceCollection builder) => + builder.AddSingleton(ODataUtf8JsonWriterFactory.Default); - private void WriteParsedJsonWithJsonElementValues(Action configureServices = null) + private void WriteParsedJsonWithJsonElementValues(Action configureServices = null) { using (var messageWriter = ODataMessageHelper.CreateMessageWriter(WriteStream, Model, ODataMessageKind.Response, enableValidation, configureServices)) { @@ -129,7 +130,7 @@ private void WriteParsedJsonWithJsonElementValues(Action conf } } - private void WriteParsedJsonWithoutJsonElementValues(Action configureServices = null) + private void WriteParsedJsonWithoutJsonElementValues(Action configureServices = null) { using (var messageWriter = ODataMessageHelper.CreateMessageWriter(WriteStream, Model, ODataMessageKind.Response, enableValidation, configureServices)) { diff --git a/test/PerformanceTests/SerializationComparisonsTests/ExperimentTests/ExperimentTests.csproj b/test/PerformanceTests/SerializationComparisonsTests/ExperimentTests/ExperimentTests.csproj index 38c7e3bca5..37d2241aa4 100644 --- a/test/PerformanceTests/SerializationComparisonsTests/ExperimentTests/ExperimentTests.csproj +++ b/test/PerformanceTests/SerializationComparisonsTests/ExperimentTests/ExperimentTests.csproj @@ -1,7 +1,7 @@ - net8.0;net6.0;netcoreapp3.1 + net8.0 false diff --git a/test/PerformanceTests/SerializationComparisonsTests/ExperimentTests/WriterTests.cs b/test/PerformanceTests/SerializationComparisonsTests/ExperimentTests/WriterTests.cs index b51dd75884..ad136cfe53 100644 --- a/test/PerformanceTests/SerializationComparisonsTests/ExperimentTests/WriterTests.cs +++ b/test/PerformanceTests/SerializationComparisonsTests/ExperimentTests/WriterTests.cs @@ -19,11 +19,6 @@ public class WriterTests private readonly static IEnumerable customerData = CustomerDataSet.GetCustomers(4); private readonly static WriterCollection> writers = DefaultWriterCollection.Create(); public static IEnumerable WriterNames { get; } = writers.GetWriterNames() - .Where(n => !n.Contains("NoOp")) - .Select(n => new string[] { n }); - - public static IEnumerable NoOpWriterNames { get; } = writers.GetWriterNames() - .Where(n => n.Contains("NoOp")) .Select(n => new string[] { n }); [Theory] @@ -44,21 +39,6 @@ public async Task WriterWritesCustomersCollectionPayload(string writerName) Assert.Equal(NormalizeJsonText(expectedOutput), NormalizeJsonText(actualOutput)); } - [Theory] - [MemberData(nameof(NoOpWriterNames))] - public async Task NoOpWritersShouldNotWriteContent(string writerName) - { - using var stream = new MemoryStream(); - var writer = writers.GetWriter(writerName); - - await writer.WritePayloadAsync(customerData, stream, includeRawValues: true); - - stream.Seek(0, SeekOrigin.Begin); - using var reader = new StreamReader(stream); - string output = await reader.ReadToEndAsync(); - Assert.Equal(string.Empty, output); - } - /// /// Normalizes the differences between JSON text encoded /// by Utf8JsonWriter and OData's JsonWriter, to make diff --git a/test/PerformanceTests/SerializationComparisonsTests/JsonWriterBenchmarks/JsonWriterBenchmarks.csproj b/test/PerformanceTests/SerializationComparisonsTests/JsonWriterBenchmarks/JsonWriterBenchmarks.csproj index af755234fb..deea2ed10a 100644 --- a/test/PerformanceTests/SerializationComparisonsTests/JsonWriterBenchmarks/JsonWriterBenchmarks.csproj +++ b/test/PerformanceTests/SerializationComparisonsTests/JsonWriterBenchmarks/JsonWriterBenchmarks.csproj @@ -2,7 +2,7 @@ Exe - net8.0;net6.0;netcoreapp3.1 + net8.0 diff --git a/test/PerformanceTests/SerializationComparisonsTests/Lib/ContainerBuilder.cs b/test/PerformanceTests/SerializationComparisonsTests/Lib/ContainerBuilder.cs deleted file mode 100644 index 6808abef01..0000000000 --- a/test/PerformanceTests/SerializationComparisonsTests/Lib/ContainerBuilder.cs +++ /dev/null @@ -1,65 +0,0 @@ -//--------------------------------------------------------------------- -// -// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. -// -//--------------------------------------------------------------------- - -using System; -using Microsoft.Extensions.DependencyInjection; -using OData = Microsoft.OData; - -namespace ExperimentsLib -{ - /// - /// Implementation of for - /// dependency injection. - /// - internal class ContainerBuilder : OData.IContainerBuilder - { - private readonly ServiceCollection services = new ServiceCollection(); - - /// - public OData.IContainerBuilder AddService(OData.ServiceLifetime lifetime, Type serviceType, Type implementationType) - { - switch (lifetime) - { - case OData.ServiceLifetime.Transient: - this.services.AddTransient(serviceType, implementationType); - break; - case OData.ServiceLifetime.Singleton: - this.services.AddSingleton(serviceType, implementationType); - break; - case OData.ServiceLifetime.Scoped: - this.services.AddScoped(serviceType, implementationType); - break; - } - - return this; - } - - /// - public OData.IContainerBuilder AddService(OData.ServiceLifetime lifetime, Type serviceType, Func implementationFactory) - { - switch (lifetime) - { - case OData.ServiceLifetime.Transient: - this.services.AddTransient(serviceType, implementationFactory); - break; - case OData.ServiceLifetime.Singleton: - this.services.AddSingleton(serviceType, implementationFactory); - break; - case OData.ServiceLifetime.Scoped: - this.services.AddScoped(serviceType, implementationFactory); - break; - } - - return this; - } - - /// - public IServiceProvider BuildContainer() - { - return this.services.BuildServiceProvider(); - } - } -} diff --git a/test/PerformanceTests/SerializationComparisonsTests/Lib/ExperimentsLib.csproj b/test/PerformanceTests/SerializationComparisonsTests/Lib/ExperimentsLib.csproj index f2bf8a8fcd..6736e824cd 100644 --- a/test/PerformanceTests/SerializationComparisonsTests/Lib/ExperimentsLib.csproj +++ b/test/PerformanceTests/SerializationComparisonsTests/Lib/ExperimentsLib.csproj @@ -1,11 +1,11 @@  - net8.0;net6.0;netcoreapp3.1 + net8.0 - + diff --git a/test/PerformanceTests/SerializationComparisonsTests/Lib/NoopJsonWriter.cs b/test/PerformanceTests/SerializationComparisonsTests/Lib/NoopJsonWriter.cs index 390c3ac5e2..1eb71bc8f6 100644 --- a/test/PerformanceTests/SerializationComparisonsTests/Lib/NoopJsonWriter.cs +++ b/test/PerformanceTests/SerializationComparisonsTests/Lib/NoopJsonWriter.cs @@ -5,6 +5,7 @@ //--------------------------------------------------------------------- using System; +using System.IO; using System.Text.Json; using System.Threading.Tasks; using Microsoft.OData.Edm; @@ -17,33 +18,51 @@ namespace ExperimentsLib /// It does not write any output. It's meant to help evaluate /// the overhead of higher-level libraries without the cost of JsonWriter. /// - public class NoopJsonWriter : IJsonWriter, IJsonWriterAsync + public class NoopJsonWriter : IJsonWriter { public void EndArrayScope() { } - public Task EndArrayScopeAsync() + public ValueTask EndArrayScopeAsync() { - return Task.CompletedTask; + return ValueTask.CompletedTask; } public void EndObjectScope() { } - public Task EndObjectScopeAsync() + public ValueTask EndObjectScopeAsync() { - return Task.CompletedTask; + return ValueTask.CompletedTask; } public void EndPaddingFunctionScope() { } - public Task EndPaddingFunctionScopeAsync() + public ValueTask EndPaddingFunctionScopeAsync() { - return Task.CompletedTask; + return ValueTask.CompletedTask; + } + + public void EndStreamValueScope() + { + } + + public ValueTask EndStreamValueScopeAsync() + { + return ValueTask.CompletedTask; + } + + public void EndTextWriterValueScope() + { + } + + public ValueTask EndTextWriterValueScopeAsync() + { + return ValueTask.CompletedTask; } public void Flush() @@ -59,54 +78,74 @@ public void StartArrayScope() { } - public Task StartArrayScopeAsync() + public ValueTask StartArrayScopeAsync() { - return Task.CompletedTask; + return ValueTask.CompletedTask; } public void StartObjectScope() { } - public Task StartObjectScopeAsync() + public ValueTask StartObjectScopeAsync() { - return Task.CompletedTask; + return ValueTask.CompletedTask; } public void StartPaddingFunctionScope() { } - public Task StartPaddingFunctionScopeAsync() + public ValueTask StartPaddingFunctionScopeAsync() { - return Task.CompletedTask; + return ValueTask.CompletedTask; + } + + public Stream StartStreamValueScope() + { + throw new NotImplementedException(); + } + + public ValueTask StartStreamValueScopeAsync() + { + throw new NotImplementedException(); + } + + public TextWriter StartTextWriterValueScope(string contentType) + { + throw new NotImplementedException(); + } + + public ValueTask StartTextWriterValueScopeAsync(string contentType) + { + throw new NotImplementedException(); } public void WriteName(string name) { } - public Task WriteNameAsync(string name) + public ValueTask WriteNameAsync(string name) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } public void WritePaddingFunctionName(string functionName) { } - public Task WritePaddingFunctionNameAsync(string functionName) + public ValueTask WritePaddingFunctionNameAsync(string functionName) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } public void WriteRawValue(string rawValue) { } - public Task WriteRawValueAsync(string rawValue) + public ValueTask WriteRawValueAsync(string rawValue) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } public void WriteValue(bool value) @@ -178,89 +217,89 @@ public void WriteValue(JsonElement value) { } - public Task WriteValueAsync(bool value) + public ValueTask WriteValueAsync(bool value) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } - public Task WriteValueAsync(int value) + public ValueTask WriteValueAsync(int value) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } - public Task WriteValueAsync(float value) + public ValueTask WriteValueAsync(float value) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } - public Task WriteValueAsync(short value) + public ValueTask WriteValueAsync(short value) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } - public Task WriteValueAsync(long value) + public ValueTask WriteValueAsync(long value) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } - public Task WriteValueAsync(double value) + public ValueTask WriteValueAsync(double value) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } - public Task WriteValueAsync(Guid value) + public ValueTask WriteValueAsync(Guid value) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } - public Task WriteValueAsync(decimal value) + public ValueTask WriteValueAsync(decimal value) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } - public Task WriteValueAsync(DateTimeOffset value) + public ValueTask WriteValueAsync(DateTimeOffset value) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } - public Task WriteValueAsync(TimeSpan value) + public ValueTask WriteValueAsync(TimeSpan value) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } - public Task WriteValueAsync(byte value) + public ValueTask WriteValueAsync(byte value) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } - public Task WriteValueAsync(sbyte value) + public ValueTask WriteValueAsync(sbyte value) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } - public Task WriteValueAsync(string value) + public ValueTask WriteValueAsync(string value) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } - public Task WriteValueAsync(byte[] value) + public ValueTask WriteValueAsync(byte[] value) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } - public Task WriteValueAsync(Date value) + public ValueTask WriteValueAsync(Date value) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } - public Task WriteValueAsync(TimeOfDay value) + public ValueTask WriteValueAsync(TimeOfDay value) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } - public Task WriteValueAsync(JsonElement value) + public ValueTask WriteValueAsync(JsonElement value) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } } } diff --git a/test/PerformanceTests/SerializationComparisonsTests/Lib/NoopJsonWriterFactory.cs b/test/PerformanceTests/SerializationComparisonsTests/Lib/NoopJsonWriterFactory.cs index 90a516ac0b..946dd82f73 100644 --- a/test/PerformanceTests/SerializationComparisonsTests/Lib/NoopJsonWriterFactory.cs +++ b/test/PerformanceTests/SerializationComparisonsTests/Lib/NoopJsonWriterFactory.cs @@ -5,6 +5,7 @@ //--------------------------------------------------------------------- using System.IO; +using System.Text; using Microsoft.OData.Json; namespace ExperimentsLib @@ -13,16 +14,11 @@ namespace ExperimentsLib /// Implementation of that returns /// a that does nothing. /// - public class NoopJsonWriterFactory : IJsonWriterFactory, IJsonWriterFactoryAsync + public class NoopJsonWriterFactory : IJsonWriterFactory { - public IJsonWriterAsync CreateAsynchronousJsonWriter(TextWriter textWriter, bool isIeee754Compatible) + public IJsonWriter CreateJsonWriter(Stream stream, bool isIeee754Compatible, Encoding encoding) { - return new NoopJsonWriter(); - } - - public IJsonWriter CreateJsonWriter(TextWriter textWriter, bool isIeee754Compatible) - { - return new NoopJsonWriter(); + throw new System.NotImplementedException(); } } } diff --git a/test/PerformanceTests/SerializationComparisonsTests/Lib/ODataMessage.cs b/test/PerformanceTests/SerializationComparisonsTests/Lib/ODataMessage.cs index 5611d1c0cb..013cf22cba 100644 --- a/test/PerformanceTests/SerializationComparisonsTests/Lib/ODataMessage.cs +++ b/test/PerformanceTests/SerializationComparisonsTests/Lib/ODataMessage.cs @@ -16,7 +16,7 @@ namespace ExperimentsLib /// Implementation of used to pass /// the response message to the . /// - public class ODataMessage : IODataResponseMessageAsync, IContainerProvider, IDisposable + public class ODataMessage : IODataResponseMessageAsync, IServiceCollectionProvider, IDisposable { private readonly Dictionary headers; @@ -38,7 +38,7 @@ public IEnumerable> Headers public Stream Stream { get; set; } - public IServiceProvider Container { get; set; } + public IServiceProvider ServiceProvider { get; set; } public string GetHeader(string headerName) { diff --git a/test/PerformanceTests/SerializationComparisonsTests/Lib/WriterHelpers.cs b/test/PerformanceTests/SerializationComparisonsTests/Lib/WriterHelpers.cs index ea066fccf2..8ac233dd9f 100644 --- a/test/PerformanceTests/SerializationComparisonsTests/Lib/WriterHelpers.cs +++ b/test/PerformanceTests/SerializationComparisonsTests/Lib/WriterHelpers.cs @@ -7,6 +7,7 @@ using System; using System.IO; using System.Text; +using Microsoft.Extensions.DependencyInjection; using Microsoft.OData; using Microsoft.OData.Json; @@ -19,25 +20,25 @@ public static class WriterHelpers public static IJsonWriter CreateODataJsonWriter(this Stream stream, Encoding encoding = null) { return jsonWriterFactory.CreateJsonWriter( - new StreamWriter(stream, encoding ?? Encoding.UTF8), false); + stream, false, encoding ?? Encoding.UTF8); } - public static IJsonWriterAsync CreateODataJsonWriterAsync(this Stream stream, Encoding encoding = null) + public static IJsonWriter CreateODataJsonWriterAsync(this Stream stream, Encoding encoding = null) { - return jsonWriterFactory.CreateAsynchronousJsonWriter( - new StreamWriter(stream, encoding ?? Encoding.UTF8), false); + return jsonWriterFactory.CreateJsonWriter( + stream, false, encoding ?? Encoding.UTF8); } public static IJsonWriter CreateODataUtf8JsonWriter(this Stream stream, Encoding encoding = null) { - DefaultStreamBasedJsonWriterFactory factory = DefaultStreamBasedJsonWriterFactory.Default; + ODataUtf8JsonWriterFactory factory = ODataUtf8JsonWriterFactory.Default; return factory.CreateJsonWriter(stream, false, encoding ?? Encoding.UTF8); } - public static IJsonWriterAsync CreateODataUtf8JsonWriterAsync(this Stream stream, Encoding encoding = null) + public static IJsonWriter CreateODataUtf8JsonWriterAsync(this Stream stream, Encoding encoding = null) { - DefaultStreamBasedJsonWriterFactory factory = DefaultStreamBasedJsonWriterFactory.Default; - return factory.CreateAsynchronousJsonWriter(stream, false, encoding ?? Encoding.UTF8); + ODataUtf8JsonWriterFactory factory = ODataUtf8JsonWriterFactory.Default; + return factory.CreateJsonWriter(stream, false, encoding ?? Encoding.UTF8); } public static IODataResponseMessage CreateJsonWriterMessage(this Stream stream, string charset = "UTF-8") @@ -51,35 +52,33 @@ public static IODataResponseMessage CreateNoopMessage(this Stream stream) return stream.CreateODataMessage(services => { - services.AddService(ServiceLifetime.Singleton, _ => factory); - services.AddService(ServiceLifetime.Singleton, _ => factory); + services.AddSingleton(factory); }); } public static IODataResponseMessage CreateUtf8JsonWriterMessage(this Stream stream, string charset="UTF-8") { - DefaultStreamBasedJsonWriterFactory factory = DefaultStreamBasedJsonWriterFactory.Default; + IJsonWriterFactory factory = ODataUtf8JsonWriterFactory.Default; + - IContainerBuilder services = new ContainerBuilder(); - services.AddDefaultODataServices(); return stream.CreateODataMessage(services => { - services.AddService(ServiceLifetime.Singleton, _ => factory); + services.AddSingleton(factory); }, charset); } - public static IODataResponseMessage CreateODataMessage(this Stream stream, Action configure = null, string charset = "UTF-8") + public static IODataResponseMessage CreateODataMessage(this Stream stream, Action configure = null, string charset = "UTF-8") { - DefaultStreamBasedJsonWriterFactory factory = DefaultStreamBasedJsonWriterFactory.Default; - - IContainerBuilder services = new ContainerBuilder(); + ServiceCollection services = new ServiceCollection(); services.AddDefaultODataServices(); + + configure?.Invoke(services); ODataMessage message = new ODataMessage { Stream = stream, - Container = services.BuildContainer() + ServiceProvider = services.BuildServiceProvider() }; message.SetHeader("Content-Type", $"application/json; charset={charset}"); diff --git a/test/PerformanceTests/SerializationComparisonsTests/TestServer/TestServer.csproj b/test/PerformanceTests/SerializationComparisonsTests/TestServer/TestServer.csproj index f2aa3aa28f..303ce10a53 100644 --- a/test/PerformanceTests/SerializationComparisonsTests/TestServer/TestServer.csproj +++ b/test/PerformanceTests/SerializationComparisonsTests/TestServer/TestServer.csproj @@ -1,7 +1,7 @@  - net6.0;net8.0 + net8.0 diff --git a/tools/perf/ResultsComparer/src/ResultsComparer/ResultsComparer.csproj b/tools/perf/ResultsComparer/src/ResultsComparer/ResultsComparer.csproj index 270b1fa7ca..13993c55f2 100644 --- a/tools/perf/ResultsComparer/src/ResultsComparer/ResultsComparer.csproj +++ b/tools/perf/ResultsComparer/src/ResultsComparer/ResultsComparer.csproj @@ -1,8 +1,7 @@  Exe - $(PERFLAB_TARGET_FRAMEWORKS) - net5.0 + net8.0 latest diff --git a/tools/perf/ResultsComparer/test/ResultsComparer.Tests/ResultsComparer.Tests.csproj b/tools/perf/ResultsComparer/test/ResultsComparer.Tests/ResultsComparer.Tests.csproj index cc9fedeaf2..d53128ca67 100644 --- a/tools/perf/ResultsComparer/test/ResultsComparer.Tests/ResultsComparer.Tests.csproj +++ b/tools/perf/ResultsComparer/test/ResultsComparer.Tests/ResultsComparer.Tests.csproj @@ -1,7 +1,7 @@  - net5.0 + net8.0 false