From 7c3a965fc01cc325c37c8119f89f5df554e4b3fa Mon Sep 17 00:00:00 2001 From: David Bond Date: Sun, 12 Dec 2021 21:52:35 +0000 Subject: [PATCH 1/2] Deprecated public calls with unused parameters Removed unused internal parameters --- .../Adapter/ResponseReaderBase.cs | 6 +++++ .../Cache/ITypeCache.cs | 11 +++++++++- .../Cache/TypeCache.cs | 12 ++++++++-- .../Cache/TypeCacheResolver.cs | 8 ++++++- .../Extensions/TypeExtensions.cs | 8 ++++++- .../GlobalSuppressions.cs | 22 +++++++++++++++++-- .../SimplePluralizer.cs | 4 ++-- 7 files changed, 62 insertions(+), 9 deletions(-) diff --git a/src/Simple.OData.Client.Core/Adapter/ResponseReaderBase.cs b/src/Simple.OData.Client.Core/Adapter/ResponseReaderBase.cs index 3b0a799d..c888e8bf 100644 --- a/src/Simple.OData.Client.Core/Adapter/ResponseReaderBase.cs +++ b/src/Simple.OData.Client.Core/Adapter/ResponseReaderBase.cs @@ -56,7 +56,13 @@ public async Task AssignBatchActionResultsAsync(IODataClient client, protected abstract void ConvertEntry(ResponseNode entryNode, object entry); + [Obsolete("The feed annotations are ignored. Use the method StartFeed(Stack nodeStack) instead.")] protected void StartFeed(Stack nodeStack, ODataFeedAnnotations feedAnnotations) + { + StartFeed(nodeStack); + } + + protected void StartFeed(Stack nodeStack) { nodeStack.Push(new ResponseNode { diff --git a/src/Simple.OData.Client.Core/Cache/ITypeCache.cs b/src/Simple.OData.Client.Core/Cache/ITypeCache.cs index 4422d4e8..d9088866 100644 --- a/src/Simple.OData.Client.Core/Cache/ITypeCache.cs +++ b/src/Simple.OData.Client.Core/Cache/ITypeCache.cs @@ -130,6 +130,15 @@ public interface ITypeCache /// IEnumerable GetAllFields(Type type); + /// + /// Get a field for a type + /// + /// + /// + /// + [Obsolete("The includeNonPublic field is ignored. Use the method GetAnyField(Type type, string fieldName) instead.")] + FieldInfo GetAnyField(Type type, string fieldName, bool includeNonPublic); + /// /// Get a field for a type /// @@ -137,7 +146,7 @@ public interface ITypeCache /// /// /// - FieldInfo GetAnyField(Type type, string fieldName, bool includeNonPublic = false); + FieldInfo GetAnyField(Type type, string fieldName); /// /// Get declared fields for a type diff --git a/src/Simple.OData.Client.Core/Cache/TypeCache.cs b/src/Simple.OData.Client.Core/Cache/TypeCache.cs index bd249c55..6852d673 100644 --- a/src/Simple.OData.Client.Core/Cache/TypeCache.cs +++ b/src/Simple.OData.Client.Core/Cache/TypeCache.cs @@ -130,9 +130,17 @@ public IEnumerable GetAllFields(Type type) } /// - public FieldInfo GetAnyField(Type type, string fieldName, bool includeNonPublic = false) + + [Obsolete("The includeNonPublic field is ignored. Use the method GetAnyField(Type type, string fieldName) instead.")] + public FieldInfo GetAnyField(Type type, string fieldName, bool includeNonPublic) + { + return GetAnyField(type, fieldName); + } + + /// + public FieldInfo GetAnyField(Type type, string fieldName) { - return Resolver(type).GetAnyField(fieldName, includeNonPublic); + return Resolver(type).GetAnyField(fieldName); } /// diff --git a/src/Simple.OData.Client.Core/Cache/TypeCacheResolver.cs b/src/Simple.OData.Client.Core/Cache/TypeCacheResolver.cs index a05aac18..628608a7 100644 --- a/src/Simple.OData.Client.Core/Cache/TypeCacheResolver.cs +++ b/src/Simple.OData.Client.Core/Cache/TypeCacheResolver.cs @@ -168,7 +168,13 @@ public PropertyInfo GetDeclaredProperty(string propertyName) return TypeInfo.GetDeclaredProperty(propertyName); } - public FieldInfo GetAnyField(string fieldName, bool includeNonPublic = false) + [Obsolete("The includeNonPublic field is ignored. Use the method GetAnyField(string fieldName) instead.")] + public FieldInfo GetAnyField(string fieldName, bool includeNonPublic) + { + return GetAnyField(fieldName); + } + + public FieldInfo GetAnyField(string fieldName) { var currentType = Type; while (currentType != null && currentType != typeof(object)) diff --git a/src/Simple.OData.Client.Core/Extensions/TypeExtensions.cs b/src/Simple.OData.Client.Core/Extensions/TypeExtensions.cs index 5bbc482d..abf21957 100644 --- a/src/Simple.OData.Client.Core/Extensions/TypeExtensions.cs +++ b/src/Simple.OData.Client.Core/Extensions/TypeExtensions.cs @@ -101,7 +101,13 @@ public static IEnumerable GetAllFields(this Type type) return fields.ToArray(); } - public static FieldInfo GetAnyField(this Type type, string fieldName, bool includeNonPublic = false) + [Obsolete("The includeNonPublic field is ignored. Use the method GetAnyField(Type type, string fieldName) instead.")] + public static FieldInfo GetAnyField(this Type type, string fieldName, bool includeNonPublic) + { + return GetAnyField(type, fieldName); + } + + public static FieldInfo GetAnyField(this Type type, string fieldName) { var currentType = type; while (currentType != null && currentType != typeof(object)) diff --git a/src/Simple.OData.Client.Core/GlobalSuppressions.cs b/src/Simple.OData.Client.Core/GlobalSuppressions.cs index 5c0fd238..d4c862cb 100644 --- a/src/Simple.OData.Client.Core/GlobalSuppressions.cs +++ b/src/Simple.OData.Client.Core/GlobalSuppressions.cs @@ -6,15 +6,33 @@ using System.Diagnostics.CodeAnalysis; [assembly: SuppressMessage( - "Style", "IDE0060:Remove unused parameter", + "Style", + "IDE0060:Remove unused parameter", Justification = "Required signature", Scope = "member", Target = "~M:Simple.OData.Client.ODataExpression.op_True(Simple.OData.Client.ODataExpression)~System.Boolean") ] [assembly: SuppressMessage( - "Style", "IDE0060:Remove unused parameter", + "Style", + "IDE0060:Remove unused parameter", + Justification = "Required signature", + Scope = "member", + Target = "~M:Simple.OData.Client.ODataExpression`1.op_True(Simple.OData.Client.ODataExpression`1)~System.Boolean") +] + +[assembly: SuppressMessage( + "Style", + "IDE0060:Remove unused parameter", Justification = "Required signature", Scope = "member", Target = "~M:Simple.OData.Client.ODataExpression.op_False(Simple.OData.Client.ODataExpression)~System.Boolean") ] + +[assembly: SuppressMessage( + "Style", + "IDE0060:Remove unused parameter", + Justification = "Required signature", + Scope = "member", + Target = "~M:Simple.OData.Client.ODataExpression`1.op_False(Simple.OData.Client.ODataExpression`1)~System.Boolean") +] diff --git a/src/Simple.OData.Client.Core/SimplePluralizer.cs b/src/Simple.OData.Client.Core/SimplePluralizer.cs index 98977c0d..8e7a66ba 100644 --- a/src/Simple.OData.Client.Core/SimplePluralizer.cs +++ b/src/Simple.OData.Client.Core/SimplePluralizer.cs @@ -173,7 +173,7 @@ private class Word { public readonly string Singular; public readonly string Plural; - public Word(string singular, string plural, string plural2) + public Word(string singular, string plural) { Singular = singular; Plural = plural; @@ -231,7 +231,7 @@ private static void PopulateLookupTables() p = s; } - var w = new Word(s, p, p2); + var w = new Word(s, p); _specialSingulars.Add(s, w); _specialPlurals.Add(p, w); if (!string.IsNullOrEmpty(p2)) From 1a6fc322f02bc43acf88065fa95c625c7c3e337a Mon Sep 17 00:00:00 2001 From: David Bond Date: Sun, 12 Dec 2021 22:17:22 +0000 Subject: [PATCH 2/2] Resolved internal calls in V3 and V4 ResponseReaders --- src/Simple.OData.Client.V3.Adapter/ResponseReader.cs | 8 ++++---- src/Simple.OData.Client.V4.Adapter/ResponseReader.cs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Simple.OData.Client.V3.Adapter/ResponseReader.cs b/src/Simple.OData.Client.V3.Adapter/ResponseReader.cs index 60c5334f..835e21c1 100644 --- a/src/Simple.OData.Client.V3.Adapter/ResponseReader.cs +++ b/src/Simple.OData.Client.V3.Adapter/ResponseReader.cs @@ -1,11 +1,11 @@ -using Microsoft.Data.Edm; -using Microsoft.Data.OData; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; using System.Threading.Tasks; +using Microsoft.Data.Edm; +using Microsoft.Data.OData; namespace Simple.OData.Client.V3.Adapter { @@ -174,7 +174,7 @@ private ODataResponse ReadResponse(ODataReader odataReader, IODataResponseMessag switch (odataReader.State) { case ODataReaderState.FeedStart: - StartFeed(nodeStack, CreateAnnotations(odataReader.Item as ODataFeed)); + StartFeed(nodeStack); break; case ODataReaderState.FeedEnd: diff --git a/src/Simple.OData.Client.V4.Adapter/ResponseReader.cs b/src/Simple.OData.Client.V4.Adapter/ResponseReader.cs index 78892165..3f3d6d85 100644 --- a/src/Simple.OData.Client.V4.Adapter/ResponseReader.cs +++ b/src/Simple.OData.Client.V4.Adapter/ResponseReader.cs @@ -174,7 +174,7 @@ private ODataResponse ReadResponse(ODataReader odataReader, IODataResponseMessag { case ODataReaderState.ResourceSetStart: case ODataReaderState.DeltaResourceSetStart: - StartFeed(nodeStack, CreateAnnotations(odataReader.Item as ODataResourceSetBase)); + StartFeed(nodeStack); break; case ODataReaderState.ResourceSetEnd: