Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Released Hidi #1873

Merged
merged 18 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
83c9278
Use ConcurrentDictionary For Improving GetEnumFromDisplayName
Aug 31, 2024
dfd6aeb
Merge pull request #1809 from Mahdigln/GetEnumFromDisplayName
MaggieKimani1 Oct 8, 2024
34de044
Bump System.Text.Json from 8.0.4 to 8.0.5
dependabot[bot] Oct 8, 2024
41b0f36
Bump Microsoft.Windows.Compatibility from 8.0.8 to 8.0.10
dependabot[bot] Oct 8, 2024
51e2cd1
Merge pull request #1864 from microsoft/dependabot/nuget/Microsoft.Wi…
baywet Oct 8, 2024
5e6e1b3
Merge pull request #1862 from microsoft/dependabot/nuget/System.Text.…
andrueastman Oct 9, 2024
a3b0011
Bump Microsoft.Extensions.Logging and Microsoft.Extensions.Logging.Ab…
dependabot[bot] Oct 9, 2024
ca39123
Merge pull request #1863 from microsoft/dependabot/nuget/multi-852bd6…
andrueastman Oct 9, 2024
ab886ef
Bump Microsoft.Extensions.Logging.Console from 8.0.0 to 8.0.1
dependabot[bot] Oct 9, 2024
eda44a9
Merge pull request #1867 from microsoft/dependabot/nuget/Microsoft.Ex…
baywet Oct 10, 2024
90b51e5
Bump Microsoft.Extensions.Logging.Debug from 8.0.0 to 8.0.1
dependabot[bot] Oct 10, 2024
81114ec
Merge pull request #1868 from microsoft/dependabot/nuget/Microsoft.Ex…
baywet Oct 10, 2024
dbf9beb
Bump Microsoft.OpenApi.OData from 2.0.0-preview.3 to 2.0.0-preview.4
dependabot[bot] Oct 10, 2024
11ff30b
Merge pull request #1869 from microsoft/dependabot/nuget/Microsoft.Op…
baywet Oct 11, 2024
9245685
ci: removes zengin since he doesn't have access to the repo anymore
baywet Oct 11, 2024
581a107
Merge pull request #1870 from microsoft/baywet-patch-1
baywet Oct 11, 2024
a27f1ef
Bumps conversion lib and hidi versions
irvinesunday Oct 11, 2024
36a4f35
Merge pull request #1871 from microsoft/is/bump-up-hidi
irvinesunday Oct 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @irvinesunday @darrelmiller @zengin @gavinbarron @millicentachieng @MaggieKimani1 @andrueastman
* @irvinesunday @darrelmiller @gavinbarron @millicentachieng @MaggieKimani1 @andrueastman
14 changes: 7 additions & 7 deletions src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Nullable>enable</Nullable>
<ToolCommandName>hidi</ToolCommandName>
<PackageOutputPath>./../../artifacts</PackageOutputPath>
<Version>1.4.11</Version>
<Version>1.4.12</Version>
<Description>OpenAPI.NET CLI tool for slicing OpenAPI documents</Description>
<SignAssembly>true</SignAssembly>
<!-- https://github.com/dotnet/sourcelink/blob/main/docs/README.md#embeduntrackedsources -->
Expand All @@ -29,23 +29,23 @@

<ItemGroup>
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.11.20">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="Microsoft.OData.Edm" Version="8.0.2" />
<PackageReference Include="Microsoft.OpenApi.OData" Version="2.0.0-preview.3" />
<PackageReference Include="Microsoft.OpenApi.OData" Version="2.0.0-preview.5" />
<PackageReference Include="Microsoft.OpenApi.ApiManifest" Version="0.5.0-preview" />
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
<!--STJ
required until Microsoft.Extensions.Logging.Console and Microsoft.Extensions.Configuration.Json
update their dependencies -->
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.8" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.10" />
<!-- Microsoft.Windows.Compatibility 8.0.8 depends on 8.0.0 this dependency can be removed once they update theirs -->
<PackageReference Include="System.Formats.Asn1" Version="8.0.1" />
</ItemGroup>
Expand Down
22 changes: 15 additions & 7 deletions src/Microsoft.OpenApi/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System;
using System.Collections.Concurrent;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using Microsoft.OpenApi.Attributes;
Expand All @@ -13,6 +13,8 @@ namespace Microsoft.OpenApi.Extensions
/// </summary>
public static class StringExtensions
{
private static readonly ConcurrentDictionary<Type, ConcurrentDictionary<string, object>> EnumDisplayCache = new();

/// <summary>
/// Gets the enum value based on the given enum type and display name.
/// </summary>
Expand All @@ -21,22 +23,28 @@ public static class StringExtensions
{
var type = typeof(T);
if (!type.IsEnum)
{
return default;
}

var displayMap = EnumDisplayCache.GetOrAdd(type, _ => new ConcurrentDictionary<string, object>(StringComparer.OrdinalIgnoreCase));

if (displayMap.TryGetValue(displayName, out var cachedValue))
return (T)cachedValue;


foreach (var field in type.GetFields(BindingFlags.Public | BindingFlags.Static))
{
var displayAttribute = (DisplayAttribute)field.GetCustomAttribute(typeof(DisplayAttribute));
if (displayAttribute != null && displayAttribute.Name == displayName)
var displayAttribute = field.GetCustomAttribute<DisplayAttribute>();
if (displayAttribute != null && displayAttribute.Name.Equals(displayName, StringComparison.OrdinalIgnoreCase))
{
return (T)field.GetValue(null);
var enumValue = (T)field.GetValue(null);
displayMap.TryAdd(displayName, enumValue);
return enumValue;
}
}

return default;
}
internal static string ToFirstCharacterLowerCase(this string input)
=> string.IsNullOrEmpty(input) ? string.Empty : char.ToLowerInvariant(input[0]) + input.Substring(1);
=> string.IsNullOrEmpty(input) ? string.Empty : char.ToLowerInvariant(input[0]) + input.Substring(1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" PrivateAssets="all" />
<!--STJ required until Microsoft.Extensions.Logging.Console and Microsoft.Extensions.Configuration.Json update their dependencies -->
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading