Skip to content

Commit 46c1490

Browse files
authored
Merge pull request #563 from microsoft/dependabot/nuget/Microsoft.OData.Edm-8.0.0
Bump Microsoft.OData.Edm from 7.21.3 to 8.0.0
2 parents a660ed9 + 107de46 commit 46c1490

File tree

68 files changed

+447
-594
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+447
-594
lines changed

src/Microsoft.OpenApi.OData.Reader/Common/EdmModelHelper.cs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -189,22 +189,22 @@ s is ODataOperationSegment ||
189189
previousTypeCastSegmentId = "As" + Utils.UpperFirstChar(schemaElement.Name);
190190
items.Add(previousTypeCastSegmentId);
191191
}
192-
else if (segment is ODataOperationSegment operationSegment)
193-
{
194-
// Navigation property generated via composable function
195-
items.Add(operationSegment.Identifier);
192+
else if (segment is ODataOperationSegment operationSegment)
193+
{
194+
// Navigation property generated via composable function
195+
items.Add(operationSegment.Identifier);
196196
}
197-
else if (segment is ODataKeySegment keySegment && keySegment.IsAlternateKey)
198-
{
199-
// We'll consider alternate keys in the operation id to eliminate potential duplicates with operation id of primary path
200-
if (segment == segments.Last())
201-
{
202-
items.Add("By" + string.Join("", keySegment.Identifier.Split(',').Select(static x => Utils.UpperFirstChar(x))));
203-
}
204-
else
205-
{
206-
items.Add(keySegment.Identifier);
207-
}
197+
else if (segment is ODataKeySegment keySegment && keySegment.IsAlternateKey)
198+
{
199+
// We'll consider alternate keys in the operation id to eliminate potential duplicates with operation id of primary path
200+
if (segment == segments.Last())
201+
{
202+
items.Add("By" + string.Join("", keySegment.Identifier.Split(',').Select(static x => Utils.UpperFirstChar(x))));
203+
}
204+
else
205+
{
206+
items.Add(keySegment.Identifier);
207+
}
208208
}
209209
}
210210

@@ -366,29 +366,29 @@ internal static string GenerateODataTypeCastPathOperationIdPrefix(ODataPath path
366366
}
367367
else if (secondLastSegment is ODataKeySegment keySegment)
368368
{
369-
if (isIndexedCollValuedNavProp)
370-
{
371-
operationId = GenerateNavigationPropertyPathOperationId(path, "Get");
369+
if (isIndexedCollValuedNavProp)
370+
{
371+
operationId = GenerateNavigationPropertyPathOperationId(path, "Get");
372+
}
373+
else
374+
{
375+
string entityTypeName = keySegment.EntityType.Name;
376+
string getPrefix = includeListOrGetPrefix ? "Get" : null;
377+
string operationName = $"{getPrefix}{Utils.UpperFirstChar(entityTypeName)}";
378+
if (keySegment.IsAlternateKey)
379+
{
380+
string alternateKeyName = string.Join("", keySegment.Identifier.Split(',').Select(static x => Utils.UpperFirstChar(x)));
381+
operationName = $"{operationName}By{alternateKeyName}";
382+
}
383+
operationId = (entitySet != null) ? entitySet.Name : singleton.Name;
384+
operationId += $".{entityTypeName}.{operationName}";
372385
}
373-
else
374-
{
375-
string entityTypeName = keySegment.EntityType.Name;
376-
string getPrefix = includeListOrGetPrefix ? "Get" : null;
377-
string operationName = $"{getPrefix}{Utils.UpperFirstChar(entityTypeName)}";
378-
if (keySegment.IsAlternateKey)
379-
{
380-
string alternateKeyName = string.Join("", keySegment.Identifier.Split(',').Select(static x => Utils.UpperFirstChar(x)));
381-
operationName = $"{operationName}By{alternateKeyName}";
382-
}
383-
operationId = (entitySet != null) ? entitySet.Name : singleton.Name;
384-
operationId += $".{entityTypeName}.{operationName}";
385-
}
386386
}
387387
else if (secondLastSegment is ODataNavigationSourceSegment)
388388
{
389389
operationId = (entitySet != null)
390-
? entitySet.Name + "." + entitySet.EntityType().Name + $".{(includeListOrGetPrefix ? "List" : null)}" + Utils.UpperFirstChar(entitySet.EntityType().Name)
391-
: singleton.Name + "." + singleton.EntityType().Name + $".{(includeListOrGetPrefix ? "Get" : null)}" + Utils.UpperFirstChar(singleton.EntityType().Name);
390+
? entitySet.Name + "." + entitySet.EntityType.Name + $".{(includeListOrGetPrefix ? "List" : null)}" + Utils.UpperFirstChar(entitySet.EntityType.Name)
391+
: singleton.Name + "." + singleton.EntityType.Name + $".{(includeListOrGetPrefix ? "Get" : null)}" + Utils.UpperFirstChar(singleton.EntityType.Name);
392392
}
393393

394394
return operationId;

src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ internal static IEdmEntityType EntityTypeFromPathSegment(this ODataSegment segme
261261
case ODataNavigationPropertySegment navPropSegment:
262262
return navPropSegment.EntityType;
263263
case ODataNavigationSourceSegment navSourceSegment when navSourceSegment.NavigationSource is IEdmEntitySet entitySet:
264-
return entitySet.EntityType();
264+
return entitySet.EntityType;
265265
case ODataNavigationSourceSegment navSourceSegment when navSourceSegment.NavigationSource is IEdmSingleton singleton:
266-
return singleton.EntityType();
266+
return singleton.EntityType;
267267
case ODataKeySegment keySegment:
268268
return keySegment.EntityType;
269269
case ODataOperationSegment:

src/Microsoft.OpenApi.OData.Reader/Edm/EdmAnnotationExtensions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ internal static class EdmVocabularyAnnotationExtensions
5757
IEdmNavigationSource navigationSource = target as IEdmNavigationSource;
5858
if (navigationSource != null)
5959
{
60-
IEdmEntityType entityType = navigationSource.EntityType();
60+
IEdmEntityType entityType = navigationSource.EntityType;
6161
value = model.GetBoolean(entityType, term);
6262
}
6363
}
@@ -109,7 +109,7 @@ public static string GetString(this IEdmModel model, IEdmVocabularyAnnotatable t
109109
IEdmNavigationSource navigationSource = target as IEdmNavigationSource;
110110
if (navigationSource != null)
111111
{
112-
IEdmEntityType entityType = navigationSource.EntityType();
112+
IEdmEntityType entityType = navigationSource.EntityType;
113113
value = model.GetString(entityType, term);
114114
}
115115
}
@@ -165,7 +165,7 @@ public static T GetRecord<T>(this IEdmModel model, IEdmVocabularyAnnotatable tar
165165
IEdmNavigationSource navigationSource = target as IEdmNavigationSource;
166166
if (navigationSource != null)
167167
{
168-
IEdmEntityType entityType = navigationSource.EntityType();
168+
IEdmEntityType entityType = navigationSource.EntityType;
169169
value = model.GetRecord<T>(entityType, term);
170170
}
171171
}
@@ -226,7 +226,7 @@ public static IEnumerable<string> GetCollection(this IEdmModel model, IEdmVocabu
226226
IEdmNavigationSource navigationSource = target as IEdmNavigationSource;
227227
if (navigationSource != null)
228228
{
229-
IEdmEntityType entityType = navigationSource.EntityType();
229+
IEdmEntityType entityType = navigationSource.EntityType;
230230
value = model.GetCollection(entityType, term);
231231
}
232232
}
@@ -282,7 +282,7 @@ public static IEnumerable<T> GetCollection<T>(this IEdmModel model, IEdmVocabula
282282
IEdmNavigationSource navigationSource = target as IEdmNavigationSource;
283283
if (navigationSource != null)
284284
{
285-
IEdmEntityType entityType = navigationSource.EntityType();
285+
IEdmEntityType entityType = navigationSource.EntityType;
286286
value = model.GetCollection<T>(entityType, term);
287287
}
288288
}

src/Microsoft.OpenApi.OData.Reader/Edm/EdmModelExtensions.cs

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ public static IDictionary<IEdmEntityType, IList<IEdmNavigationSource>> LoadAllNa
8080
{
8181
Action<IEdmNavigationSource, IDictionary<IEdmEntityType, IList<IEdmNavigationSource>>> action = (ns, dic) =>
8282
{
83-
if (!dic.TryGetValue(ns.EntityType(), out IList<IEdmNavigationSource> value))
83+
if (!dic.TryGetValue(ns.EntityType, out IList<IEdmNavigationSource> value))
8484
{
8585
value = new List<IEdmNavigationSource>();
86-
dic[ns.EntityType()] = value;
86+
dic[ns.EntityType] = value;
8787
}
8888

8989
value.Add(ns);
@@ -145,43 +145,6 @@ public static IEnumerable<IEdmComplexType> FindAllBaseTypes(this IEdmComplexType
145145
}
146146
}
147147

148-
/// <summary>
149-
/// Checks if the <paramref name="baseType"/> is assignable to <paramref name="subtype"/>.
150-
/// In other words, if <paramref name="subtype"/> is a subtype of <paramref name="baseType"/> or not.
151-
/// </summary>
152-
/// <param name="baseType">Type of the base type.</param>
153-
/// <param name="subtype">Type of the sub type.</param>
154-
/// <returns>true, if the <paramref name="baseType"/> is assignable to <paramref name="subtype"/>. Otherwise returns false.</returns>
155-
[Obsolete]
156-
public static bool IsAssignableFrom(this IEdmEntityType baseType, IEdmEntityType subtype)
157-
{
158-
Utils.CheckArgumentNull(baseType, nameof(baseType));
159-
Utils.CheckArgumentNull(subtype, nameof(subtype));
160-
161-
if (baseType.TypeKind != subtype.TypeKind)
162-
{
163-
return false;
164-
}
165-
166-
if (subtype.IsEquivalentTo(baseType))
167-
{
168-
return true;
169-
}
170-
171-
IEdmStructuredType structuredSubType = subtype;
172-
while (structuredSubType != null)
173-
{
174-
if (structuredSubType.IsEquivalentTo(baseType))
175-
{
176-
return true;
177-
}
178-
179-
structuredSubType = structuredSubType.BaseType;
180-
}
181-
182-
return false;
183-
}
184-
185148
/// <summary>
186149
/// Check whether the operation is overload in the model.
187150
/// </summary>
@@ -215,8 +178,8 @@ public static bool OperationTargetsMultiplePaths(this IEdmModel model, IEdmOpera
215178

216179
IEdmTypeReference bindingParameterType = operation.Parameters.First().Type;
217180

218-
return model.EntityContainer.EntitySets().Select(static x => x.EntityType())
219-
.Concat(model.EntityContainer.Singletons().Select(static x => x.EntityType()))
181+
return model.EntityContainer.EntitySets().Select(static x => x.EntityType)
182+
.Concat(model.EntityContainer.Singletons().Select(static x => x.EntityType))
220183
.Where(x => x.FullName().Equals(bindingParameterType.FullName(), StringComparison.OrdinalIgnoreCase)).Count() > 1;
221184
}
222185

src/Microsoft.OpenApi.OData.Reader/Edm/ODataNavigationSourceSegment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public ODataNavigationSourceSegment(IEdmNavigationSource navigationSource)
3131
public IEdmNavigationSource NavigationSource { get; }
3232

3333
/// <inheritdoc />
34-
public override IEdmEntityType EntityType => NavigationSource.EntityType();
34+
public override IEdmEntityType EntityType => NavigationSource.EntityType;
3535

3636
/// <inheritdoc />
3737
public override string Identifier { get => NavigationSource.Name; }

src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ private void RetrieveNavigationSourcePaths(IEdmNavigationSource navigationSource
243243
AppendPath(path.Clone());
244244

245245
IEdmEntitySet entitySet = navigationSource as IEdmEntitySet;
246-
IEdmEntityType entityType = navigationSource.EntityType();
246+
IEdmEntityType entityType = navigationSource.EntityType;
247247
CountRestrictionsType count = null;
248248
bool? indexableByKey = false;
249249

@@ -923,14 +923,14 @@ private List<IEdmEntityType> GetAllEntitiesForOperation(IEdmTypeReference bindin
923923
var firstEntityType = bindingType.AsEntity().EntityDefinition();
924924

925925
bool filter(IEdmNavigationSource z) =>
926-
z.EntityType() != firstEntityType &&
927-
z.EntityType().FindAllBaseTypes().Contains(firstEntityType);
926+
z.EntityType != firstEntityType &&
927+
z.EntityType.FindAllBaseTypes().Contains(firstEntityType);
928928

929929
return new IEdmEntityType[] { firstEntityType }
930930
.Union(_model.EntityContainer.EntitySets()
931-
.Where(filter).Select(x => x.EntityType())) //Search all EntitySets
931+
.Where(filter).Select(x => x.EntityType)) //Search all EntitySets
932932
.Union(_model.EntityContainer.Singletons()
933-
.Where(filter).Select(x => x.EntityType())) //Search all singletons
933+
.Where(filter).Select(x => x.EntityType)) //Search all singletons
934934
.Distinct()
935935
.ToList();
936936
}
@@ -1082,7 +1082,7 @@ private void AppendBoundOperationOnDerived(
10821082
}
10831083
else
10841084
{
1085-
ODataPath newPath = new ODataPath(new ODataNavigationSourceSegment(ns), new ODataKeySegment(ns.EntityType()),
1085+
ODataPath newPath = new ODataPath(new ODataNavigationSourceSegment(ns), new ODataKeySegment(ns.EntityType),
10861086
new ODataTypeCastSegment(bindingEntityType , _model),
10871087
new ODataOperationSegment(edmOperation, isEscapedFunction, _model));
10881088
AppendPath(newPath);

src/Microsoft.OpenApi.OData.Reader/Edm/ODataSegment.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,6 @@ public string GetPathHash(OpenApiConvertSettings settings, ODataPath path = defa
127127
/// <returns>The path item name.</returns>
128128
public abstract string GetPathItemName(OpenApiConvertSettings settings, HashSet<string> parameters);
129129

130-
/// <summary>
131-
/// Provides any deprecation information for the segment.
132-
/// </summary>
133-
[Obsolete("This property never returned any value or was used by the library.")]
134-
public Microsoft.OpenApi.OData.OpenApiExtensions.OpenApiDeprecationExtension Deprecation { get; set; }
135130
/// <summary>
136131
/// Returns the list of <see cref="IEdmVocabularyAnnotatable"/> this segment refers to.
137132
/// </summary>

0 commit comments

Comments
 (0)