Skip to content

Commit 06b54c3

Browse files
committed
Fix build, address feedback, and remove Readers from trim tests
1 parent 7f7c54a commit 06b54c3

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static IOpenApiAny CloneFromCopyConstructor(IOpenApiAny obj)
5050
var pi = ci.GetParameters();
5151
if (pi.Length == 1 && pi[0].ParameterType == typeof(T))
5252
{
53-
return (IOpenApiAny)ci.Invoke([obj]);
53+
return (T)ci.Invoke([obj]);
5454
}
5555
}
5656
}

src/Microsoft.OpenApi/Extensions/EnumExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public static class EnumExtensions
2323
/// <returns>
2424
/// The attribute of the specified type or null.
2525
/// </returns>
26+
[Obsolete("GetAttributeOfType<T> is deprecated and will be removed in a future release.")]
2627
[RequiresUnreferencedCode("GetAttributeOfType is not trim-compatible. Recommended to use native AoT-friendly type-specific overloads of GetDisplayName instead.")]
2728
public static T GetAttributeOfType<T>(this Enum enumValue) where T : Attribute
2829
{

src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,13 @@ IEnumerator IEnumerable.GetEnumerator()
185185
private static ValidationRuleSet BuildDefaultRuleSet()
186186
{
187187
var ruleSet = new ValidationRuleSet();
188+
var validationRuleType = typeof(ValidationRule);
188189

189190
var ruleTypeProperties = GetValidationRuleTypes();
190191

191192
foreach (var property in ruleTypeProperties)
192193
{
193-
if (!typeof(ValidationRule).IsAssignableFrom(property.PropertyType))
194+
if (!validationRuleType.IsAssignableFrom(property.PropertyType))
194195
{
195196
continue;
196197
}

test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace Microsoft.OpenApi.Any
2424
public OpenApiAnyCloneHelper() { }
2525
[System.Obsolete("Use native AoT-friendly generic overload of CloneFromCopyConstructor instead.")]
2626
public static Microsoft.OpenApi.Any.IOpenApiAny CloneFromCopyConstructor(Microsoft.OpenApi.Any.IOpenApiAny obj) { }
27-
public static Microsoft.OpenApi.Any.IOpenApiAny CloneFromCopyConstructor<T>(T obj)
27+
public static T CloneFromCopyConstructor<T>(T obj)
2828
where T : Microsoft.OpenApi.Any.IOpenApiAny { }
2929
}
3030
public class OpenApiArray : System.Collections.Generic.List<Microsoft.OpenApi.Any.IOpenApiAny>, Microsoft.OpenApi.Any.IOpenApiAny, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtension
@@ -249,6 +249,7 @@ namespace Microsoft.OpenApi.Extensions
249249
{
250250
public static class EnumExtensions
251251
{
252+
[System.Obsolete("GetAttributeOfType<T> is deprecated and will be removed in a future release.")]
252253
public static T GetAttributeOfType<T>(this System.Enum enumValue)
253254
where T : System.Attribute { }
254255
public static string GetDisplayName(this Microsoft.OpenApi.Models.ParameterLocation parameterLocation) { }

test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,4 @@
1515
<TrimmerRootAssembly Include="Microsoft.OpenApi" />
1616
</ItemGroup>
1717

18-
<ItemGroup>
19-
<ProjectReference Include="..\..\src\Microsoft.OpenApi.Readers\Microsoft.OpenApi.Readers.csproj" />
20-
<TrimmerRootAssembly Include="Microsoft.OpenApi.Readers" />
21-
</ItemGroup>
22-
2318
</Project>

0 commit comments

Comments
 (0)