Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@

foreach (var item in customXMLAttributesMapping)
{
string attributeName = item.Key.Split(':').Last(); // example, 'ags:IsHidden' --> 'IsHidden'

Check warning on line 184 in src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs

View workflow job for this annotation

GitHub Actions / Build

Indexing at Count-1 should be used instead of the "Enumerable" extension method "Last" (https://rules.sonarsource.com/csharp/RSPEC-6608)

Check warning on line 184 in src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs

View workflow job for this annotation

GitHub Actions / Build

Indexing at Count-1 should be used instead of the "Enumerable" extension method "Last" (https://rules.sonarsource.com/csharp/RSPEC-6608)
string extensionName = item.Value;
var customXMLAttribute = model.DirectValueAnnotationsManager.GetDirectValueAnnotations(element)?
.Where(x => x.Name.Equals(attributeName, StringComparison.OrdinalIgnoreCase))?

Check warning on line 187 in src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs

View workflow job for this annotation

GitHub Actions / Build

Remove this unnecessary check for null. (https://rules.sonarsource.com/csharp/RSPEC-2589)

Check warning on line 187 in src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs

View workflow job for this annotation

GitHub Actions / Build

Remove this unnecessary check for null. (https://rules.sonarsource.com/csharp/RSPEC-2589)
.FirstOrDefault()?.Value as EdmStringConstant;
var attributeValue = customXMLAttribute?.Value;

Expand Down Expand Up @@ -212,7 +212,7 @@
IEnumerable<IEdmAction>? actions = null)
{
string baseTypeName = baseType.FullTypeName();
bool isBaseTypeEntity = Constants.EntityName.Equals(baseTypeName?.Split('.').Last(), StringComparison.OrdinalIgnoreCase);

Check warning on line 215 in src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs

View workflow job for this annotation

GitHub Actions / Build

Indexing at Count-1 should be used instead of the "Enumerable" extension method "Last" (https://rules.sonarsource.com/csharp/RSPEC-6608)

Check warning on line 215 in src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs

View workflow job for this annotation

GitHub Actions / Build

Indexing at Count-1 should be used instead of the "Enumerable" extension method "Last" (https://rules.sonarsource.com/csharp/RSPEC-6608)

if (!string.IsNullOrEmpty(baseTypeName) && !isBaseTypeEntity)
{
Expand All @@ -238,7 +238,8 @@
if (isReferencedInAction) return true;

// Recursively check the base type
return model.IsBaseTypeReferencedAsTypeInModel(baseType.BaseType, structuredTypes, actions);
if (baseType.BaseType is not null)
return model.IsBaseTypeReferencedAsTypeInModel(baseType.BaseType, structuredTypes, actions);
}

return false;
Expand Down Expand Up @@ -334,7 +335,7 @@
return false;
}

ODataSegment lastSecondSegment = path.Segments.ElementAt(path.Count - secondLastSegmentIndex);

Check warning on line 338 in src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs

View workflow job for this annotation

GitHub Actions / Build

Indexing should be used instead of the "Enumerable" extension method "ElementAt" (https://rules.sonarsource.com/csharp/RSPEC-6608)

Check warning on line 338 in src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs

View workflow job for this annotation

GitHub Actions / Build

Indexing should be used instead of the "Enumerable" extension method "ElementAt" (https://rules.sonarsource.com/csharp/RSPEC-6608)
var boundEntityType = lastSecondSegment?.EntityTypeFromPathSegment();

var operationEntityType = lastSegment.EntityTypeFromOperationSegment();
Expand Down
Loading