Skip to content
Closed
Show file tree
Hide file tree
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
11 changes: 0 additions & 11 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,3 @@ csharp_preserve_single_line_blocks = true
[*.vb]
# Modifier preferences
visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion


# Verify settings
[*.{received,verified}.{txt,xml,json}]
charset = "utf-8-bom"
end_of_line = lf
indent_size = unset
indent_style = unset
insert_final_newline = false
tab_width = unset
trim_trailing_whitespace = false
3 changes: 0 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,3 @@
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

# VerifyTests
*.verified.txt text eol=lf working-tree-encoding=UTF-8
2 changes: 1 addition & 1 deletion .github/workflows/auto-merge-dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2.2.0
uses: dependabot/fetch-metadata@v2.1.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v4
- name: Login to GitHub package feed
uses: docker/login-action@v3.3.0
uses: docker/login-action@v3.2.0
with:
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
Expand All @@ -30,13 +30,13 @@ jobs:
id: getversion
- name: Push to GitHub Packages - Nightly
if: ${{ github.ref == 'refs/heads/vnext' }}
uses: docker/build-push-action@v6.5.0
uses: docker/build-push-action@v6.1.0
with:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly
- name: Push to GitHub Packages - Release
if: ${{ github.ref == 'refs/heads/master' }}
uses: docker/build-push-action@v6.5.0
uses: docker/build-push-action@v6.1.0
with:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }}
7 changes: 0 additions & 7 deletions Microsoft.OpenApi.sln
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Hidi", "s
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.OpenApi.Hidi.Tests", "test\Microsoft.OpenApi.Hidi.Tests\Microsoft.OpenApi.Hidi.Tests.csproj", "{D8F799DD-04AC-4A13-B344-45A5B944450A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.OpenApi.Trimming.Tests", "test\Microsoft.OpenApi.Trimming.Tests\Microsoft.OpenApi.Trimming.Tests.csproj", "{1D2E0C6E-B103-4CB6-912E-D56FA1501296}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -70,10 +68,6 @@ Global
{D8F799DD-04AC-4A13-B344-45A5B944450A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D8F799DD-04AC-4A13-B344-45A5B944450A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D8F799DD-04AC-4A13-B344-45A5B944450A}.Release|Any CPU.Build.0 = Release|Any CPU
{1D2E0C6E-B103-4CB6-912E-D56FA1501296}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D2E0C6E-B103-4CB6-912E-D56FA1501296}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D2E0C6E-B103-4CB6-912E-D56FA1501296}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D2E0C6E-B103-4CB6-912E-D56FA1501296}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -87,7 +81,6 @@ Global
{AD79B61D-88CF-497C-9ED5-41AE3867C5AC} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A}
{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE} = {E546B92F-20A8-49C3-8323-4B25BB78F3E1}
{D8F799DD-04AC-4A13-B344-45A5B944450A} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A}
{1D2E0C6E-B103-4CB6-912E-D56FA1501296} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9F171EFC-0DB5-4B10-ABFA-AF48D52CC565}
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ In order to test the validity of an OpenApi document, we avail the following too

5. Copy and paste your OpenAPI descriptions in the **Input Content** window or paste the path to the descriptions file in the **Input File** textbox and click on `Convert` to render the results.

# Build Status

|**master**|
|--|
|[![Build status](https://ci.appveyor.com/api/projects/status/9l6hly3vjeu0tmtx/branch/master?svg=true)](https://ci.appveyor.com/project/MicrosoftOpenAPINETAdmin/openapi-net-54e7i/branch/master)|

# Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.6.16</Version>
<Version>1.6.15</Version>
<Description>OpenAPI.NET Readers for JSON and YAML documents</Description>
<SignAssembly>true</SignAssembly>
<!-- https://github.com/dotnet/sourcelink/blob/main/docs/README.md#embeduntrackedsources -->
Expand Down
11 changes: 4 additions & 7 deletions src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.OpenApi.Interfaces;
Expand Down Expand Up @@ -42,7 +41,7 @@ public OpenApiStreamReader(OpenApiReaderSettings settings = null)
/// <returns>Instance of newly created OpenApiDocument.</returns>
public OpenApiDocument Read(Stream input, out OpenApiDiagnostic diagnostic)
{
using var reader = new StreamReader(input, Encoding.UTF8, true, 4096, _settings.LeaveStreamOpen);
using var reader = new StreamReader(input, default, true, -1, _settings.LeaveStreamOpen);
return new OpenApiTextReaderReader(_settings).Read(reader, out diagnostic);
}

Expand All @@ -55,7 +54,6 @@ public OpenApiDocument Read(Stream input, out OpenApiDiagnostic diagnostic)
public async Task<ReadResult> ReadAsync(Stream input, CancellationToken cancellationToken = default)
{
MemoryStream bufferedStream;
int bufferSize = 4096;
if (input is MemoryStream stream)
{
bufferedStream = stream;
Expand All @@ -65,12 +63,11 @@ public async Task<ReadResult> ReadAsync(Stream input, CancellationToken cancella
// Buffer stream so that OpenApiTextReaderReader can process it synchronously
// YamlDocument doesn't support async reading.
bufferedStream = new();
bufferSize = 81920;
await input.CopyToAsync(bufferedStream, bufferSize, cancellationToken);
await input.CopyToAsync(bufferedStream, 81920, cancellationToken);
bufferedStream.Position = 0;
}

using var reader = new StreamReader(bufferedStream, Encoding.UTF8, true, bufferSize, _settings.LeaveStreamOpen);
using var reader = new StreamReader(bufferedStream, default, true, -1, _settings.LeaveStreamOpen);
return await new OpenApiTextReaderReader(_settings).ReadAsync(reader, cancellationToken);
}

Expand All @@ -83,7 +80,7 @@ public async Task<ReadResult> ReadAsync(Stream input, CancellationToken cancella
/// <returns>Instance of newly created OpenApiDocument</returns>
public T ReadFragment<T>(Stream input, OpenApiSpecVersion version, out OpenApiDiagnostic diagnostic) where T : IOpenApiReferenceable
{
using var reader = new StreamReader(input, Encoding.UTF8, true, 4096, _settings.LeaveStreamOpen);
using var reader = new StreamReader(input, default, true, -1, _settings.LeaveStreamOpen);
return new OpenApiTextReaderReader(_settings).ReadFragment<T>(reader, version, out diagnostic);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.421302" PrivateAssets="all" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.7" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.6" />
</ItemGroup>
<ItemGroup>
<Resource Include="Themes\Metro\HowToApplyTheme.txt" />
Expand Down
27 changes: 1 addition & 26 deletions src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;

namespace Microsoft.OpenApi.Any
{
/// <summary>
/// Contains logic for cloning objects through copy constructors.
/// </summary>
public class OpenApiAnyCloneHelper

Check warning on line 11 in src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs

View workflow job for this annotation

GitHub Actions / Build

Add a 'protected' constructor or the 'static' keyword to the class declaration. (https://rules.sonarsource.com/csharp/RSPEC-1118)
{
/// <summary>
/// Clones an instance of <see cref="IOpenApiAny"/> object from the copy constructor
/// </summary>
/// <param name="obj">The object instance.</param>
/// <returns>A clone copy or the object itself.</returns>
[Obsolete("Use native AoT-friendly generic overload of CloneFromCopyConstructor instead.")]
[RequiresUnreferencedCode("CloneFromCopyConstructor is not trim-compatible. Recommended to use native AoT-friendly type-specific overloads of CloneFromCopyConstructor instead.")]
public static IOpenApiAny CloneFromCopyConstructor(IOpenApiAny obj)
{
if (obj != null)
Expand All @@ -35,27 +32,5 @@

return obj;
}

/// <summary>
/// Clones an instance of <see cref="IOpenApiAny"/> object from the copy constructor
/// </summary>
/// <param name="obj">The object instance.</param>
/// <returns>A clone copy or the object itself.</returns>
public static T CloneFromCopyConstructor<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>(T obj) where T : IOpenApiAny
{
if (obj != null)
{
foreach (var ci in typeof(T).GetConstructors())
{
var pi = ci.GetParameters();
if (pi.Length == 1 && pi[0].ParameterType == typeof(T))
{
return (T)ci.Invoke([obj]);
}
}
}

return obj;
}
}
}
4 changes: 0 additions & 4 deletions src/Microsoft.OpenApi/Any/OpenApiArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ public OpenApiArray() { }
public OpenApiArray(OpenApiArray array)
{
AnyType = array.AnyType;
foreach (var item in array)
{
Add(OpenApiAnyCloneHelper.CloneFromCopyConstructor<IOpenApiAny>(item));
}
}

/// <summary>
Expand Down
4 changes: 0 additions & 4 deletions src/Microsoft.OpenApi/Any/OpenApiObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ public OpenApiObject() { }
public OpenApiObject(OpenApiObject obj)
{
AnyType = obj.AnyType;
foreach (var key in obj.Keys)
{
this[key] = OpenApiAnyCloneHelper.CloneFromCopyConstructor<IOpenApiAny>(obj[key]);
}
}

/// <summary>
Expand Down
Loading
Loading