Skip to content
Merged
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
7 changes: 2 additions & 5 deletions src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public PropertyNode this[string key]
{
get
{
YamlNode node;
if (this._node.Children.TryGetValue(new YamlScalarNode(key), out node))
if (this._node.Children.TryGetValue(new YamlScalarNode(key), out var node))
{
return new PropertyNode(Context, key, node);
}
Expand Down Expand Up @@ -192,9 +191,7 @@ public T GetReferencedObject<T>(ReferenceType referenceType, string referenceId)

public string GetReferencePointer()
{
YamlNode refNode;

if (!_node.Children.TryGetValue(new YamlScalarNode("$ref"), out refNode))
if (!_node.Children.TryGetValue(new YamlScalarNode("$ref"), out var refNode))
{
return null;
}
Expand Down
5 changes: 1 addition & 4 deletions src/Microsoft.OpenApi.Readers/ParseNodes/PropertyNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ public void ParseField<T>(
IDictionary<string, Action<T, ParseNode>> fixedFields,
IDictionary<Func<string, bool>, Action<T, string, ParseNode>> patternFields)
{
Action<T, ParseNode> fixedFieldMap;
var found = fixedFields.TryGetValue(Name, out fixedFieldMap);

if (fixedFieldMap != null)
if (fixedFields.TryGetValue(Name, out var fixedFieldMap))
{
try
{
Expand Down
3 changes: 1 addition & 2 deletions src/Microsoft.OpenApi.Readers/ParsingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ public void StartObject(string objectName)
/// <returns>If method returns false a loop was detected and the key is not added.</returns>
public bool PushLoop(string loopId, string key)
{
Stack<string> stack;
if (!_loopStacks.TryGetValue(loopId, out stack))
if (!_loopStacks.TryGetValue(loopId, out var stack))
{
stack = new Stack<string>();
_loopStacks.Add(loopId, stack);
Expand Down
3 changes: 1 addition & 2 deletions src/Microsoft.OpenApi/Services/LoopDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ internal class LoopDetector
/// <returns>If method returns false a loop was detected and the key is not added.</returns>
public bool PushLoop<T>(T key)
{
Stack<object> stack;
if (!_loopStacks.TryGetValue(typeof(T), out stack))
if (!_loopStacks.TryGetValue(typeof(T), out var stack))
{
stack = new Stack<object>();
_loopStacks.Add(typeof(T), stack);
Expand Down
3 changes: 1 addition & 2 deletions src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ public sealed class ValidationRuleSet : IEnumerable<ValidationRule>
/// <returns>Either the rules related to the type, or an empty list.</returns>
public IList<ValidationRule> FindRules(Type type)
{
IList<ValidationRule> results = null;
_rules.TryGetValue(type, out results);
_rules.TryGetValue(type, out var results);
return results ?? _emptyRules;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ public void ParseStringContactFragmentShouldSucceed()
}
""";
var reader = new OpenApiStringReader();
var diagnostic = new OpenApiDiagnostic();

// Act
var contact = reader.ReadFragment<OpenApiContact>(input, OpenApiSpecVersion.OpenApi2_0, out diagnostic);
var contact = reader.ReadFragment<OpenApiContact>(input, OpenApiSpecVersion.OpenApi2_0, out var diagnostic);

// Assert
diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ public void ParseStringContactFragmentShouldSucceed()
}
""";
var reader = new OpenApiStringReader();
var diagnostic = new OpenApiDiagnostic();

// Act
var contact = reader.ReadFragment<OpenApiContact>(input, OpenApiSpecVersion.OpenApi3_0, out diagnostic);
var contact = reader.ReadFragment<OpenApiContact>(input, OpenApiSpecVersion.OpenApi3_0, out var diagnostic);

// Assert
diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic());
Expand Down
15 changes: 5 additions & 10 deletions test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ public void ParsePrimitiveSchemaFragmentShouldSucceed()
{
using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "primitiveSchema.yaml"));
var reader = new OpenApiStreamReader();
var diagnostic = new OpenApiDiagnostic();

// Act
var schema = reader.ReadFragment<OpenApiSchema>(stream, OpenApiSpecVersion.OpenApi3_0, out diagnostic);
var schema = reader.ReadFragment<OpenApiSchema>(stream, OpenApiSpecVersion.OpenApi3_0, out var diagnostic);

// Assert
diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic());
Expand All @@ -79,10 +78,9 @@ public void ParsePrimitiveStringSchemaFragmentShouldSucceed()
}
""";
var reader = new OpenApiStringReader();
var diagnostic = new OpenApiDiagnostic();

// Act
var schema = reader.ReadFragment<OpenApiSchema>(input, OpenApiSpecVersion.OpenApi3_0, out diagnostic);
var schema = reader.ReadFragment<OpenApiSchema>(input, OpenApiSpecVersion.OpenApi3_0, out var diagnostic);

// Assert
diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic());
Expand All @@ -107,10 +105,9 @@ public void ParseExampleStringFragmentShouldSucceed()
}
""";
var reader = new OpenApiStringReader();
var diagnostic = new OpenApiDiagnostic();

// Act
var openApiAny = reader.ReadFragment<IOpenApiAny>(input, OpenApiSpecVersion.OpenApi3_0, out diagnostic);
var openApiAny = reader.ReadFragment<IOpenApiAny>(input, OpenApiSpecVersion.OpenApi3_0, out var diagnostic);

// Assert
diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic());
Expand Down Expand Up @@ -138,10 +135,9 @@ public void ParseEnumFragmentShouldSucceed()
]
""";
var reader = new OpenApiStringReader();
var diagnostic = new OpenApiDiagnostic();

// Act
var openApiAny = reader.ReadFragment<IOpenApiAny>(input, OpenApiSpecVersion.OpenApi3_0, out diagnostic);
var openApiAny = reader.ReadFragment<IOpenApiAny>(input, OpenApiSpecVersion.OpenApi3_0, out var diagnostic);

// Assert
diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic());
Expand Down Expand Up @@ -214,10 +210,9 @@ public void ParsePathFragmentShouldSucceed()
description: Ok
""";
var reader = new OpenApiStringReader();
var diagnostic = new OpenApiDiagnostic();

// Act
var openApiAny = reader.ReadFragment<OpenApiPathItem>(input, OpenApiSpecVersion.OpenApi3_0, out diagnostic);
var openApiAny = reader.ReadFragment<OpenApiPathItem>(input, OpenApiSpecVersion.OpenApi3_0, out var diagnostic);

// Assert
diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic());
Expand Down