Skip to content

Commit 1228e75

Browse files
committed
use some expression gets
1 parent 2690da5 commit 1228e75

File tree

10 files changed

+30
-105
lines changed

10 files changed

+30
-105
lines changed

src/Microsoft.OpenApi/Expressions/BodyExpression.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ public override string Expression
5555
/// <summary>
5656
/// Gets the fragment string.
5757
/// </summary>
58-
public string Fragment
59-
{
60-
get
61-
{
62-
return Value;
63-
}
64-
}
58+
public string Fragment { get => Value; }
6559
}
6660
}

src/Microsoft.OpenApi/Expressions/HeaderExpression.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,11 @@ public HeaderExpression(string token)
2626
/// <summary>
2727
/// Gets the expression string.
2828
/// </summary>
29-
public override string Expression
30-
{
31-
get
32-
{
33-
return Header + Value;
34-
}
35-
}
29+
public override string Expression { get => Header + Value; }
3630

3731
/// <summary>
3832
/// Gets the token string.
3933
/// </summary>
40-
public string Token
41-
{
42-
get
43-
{
44-
return Value;
45-
}
46-
}
34+
public string Token { get => Value; }
4735
}
4836
}

src/Microsoft.OpenApi/Expressions/PathExpression.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,11 @@ public PathExpression(string name)
2626
/// <summary>
2727
/// Gets the expression string.
2828
/// </summary>
29-
public override string Expression
30-
{
31-
get
32-
{
33-
return Path + Value;
34-
}
35-
}
29+
public override string Expression { get => Path + Value; }
3630

3731
/// <summary>
3832
/// Gets the name string.
3933
/// </summary>
40-
public string Name
41-
{
42-
get
43-
{
44-
return Value;
45-
}
46-
}
34+
public string Name { get => Value; }
4735
}
4836
}

src/Microsoft.OpenApi/Expressions/QueryExpression.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,11 @@ public QueryExpression(string name)
2626
/// <summary>
2727
/// Gets the expression string.
2828
/// </summary>
29-
public override string Expression
30-
{
31-
get
32-
{
33-
return Query + Value;
34-
}
35-
}
29+
public override string Expression { get => Query + Value; }
3630

3731
/// <summary>
3832
/// Gets the name string.
3933
/// </summary>
40-
public string Name
41-
{
42-
get
43-
{
44-
return Value;
45-
}
46-
}
34+
public string Name { get => Value; }
4735
}
4836
}

src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,7 @@ public virtual void Exit()
4141
/// <summary>
4242
/// Pointer to source of validation error in document
4343
/// </summary>
44-
public string PathString
45-
{
46-
get
47-
{
48-
return "#/" + String.Join("/", _path.Reverse());
49-
}
50-
}
44+
public string PathString { get => "#/" + String.Join("/", _path.Reverse()); }
5145

5246
/// <summary>
5347
/// Visits <see cref="OpenApiDocument"/>

src/Microsoft.OpenApi/Validations/OpenApiValidator.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,12 @@ public OpenApiValidator(ValidationRuleSet ruleSet)
3030
/// <summary>
3131
/// Gets the validation errors.
3232
/// </summary>
33-
public IEnumerable<OpenApiValidatorError> Errors
34-
{
35-
get
36-
{
37-
return _errors;
38-
}
39-
}
33+
public IEnumerable<OpenApiValidatorError> Errors { get => _errors; }
4034

4135
/// <summary>
4236
/// Gets the validation warnings.
4337
/// </summary>
44-
public IEnumerable<OpenApiValidatorWarning> Warnings
45-
{
46-
get
47-
{
48-
return _warnings;
49-
}
50-
}
38+
public IEnumerable<OpenApiValidatorWarning> Warnings { get => _warnings; }
5139

5240
/// <summary>
5341
/// Register an error with the validation context.

src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,7 @@ public ValidationRuleSet(IEnumerable<ValidationRule> rules)
111111
/// </summary>
112112
public IList<ValidationRule> Rules
113113
{
114-
get
115-
{
116-
return _rules.Values.SelectMany(v => v).ToList();
117-
}
114+
get => _rules.Values.SelectMany(v => v).ToList();
118115
}
119116

120117
/// <summary>

src/Microsoft.OpenApi/Writers/Scope.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,7 @@ public Scope(ScopeType type)
4646
/// <summary>
4747
/// Gets the scope type for this scope.
4848
/// </summary>
49-
public ScopeType Type
50-
{
51-
get
52-
{
53-
return _type;
54-
}
55-
}
49+
public ScopeType Type { get => _type; }
5650

5751
/// <summary>
5852
/// Get/Set the whether it is in previous array scope.

test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,10 @@ public void WriteOpenApiDateTimeAsJsonWorks(string inputString, bool produceTers
180180

181181
public static IEnumerable<object[]> BooleanInputs
182182
{
183-
get
184-
{
185-
return
186-
from input in new [] { true, false }
187-
from shouldBeTerse in shouldProduceTerseOutputValues
188-
select new object[] { input, shouldBeTerse };
189-
}
183+
get =>
184+
from input in new [] { true, false }
185+
from shouldBeTerse in shouldProduceTerseOutputValues
186+
select new object[] { input, shouldBeTerse };
190187
}
191188

192189
[Theory]

test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterSpecialCharacterTests.cs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,20 @@ public class OpenApiWriterSpecialCharacterTests
1818

1919
public static IEnumerable<object[]> StringWithSpecialCharacters
2020
{
21-
get
22-
{
23-
return
24-
from inputExpected in new[] {
25-
new[]{ "Test\bTest", "\"Test\\bTest\"" },
26-
new[]{ "Test\fTest", "\"Test\\fTest\""},
27-
new[]{ "Test\nTest", "\"Test\\nTest\""},
28-
new[]{ "Test\rTest", "\"Test\\rTest\""},
29-
new[]{ "Test\tTest", "\"Test\\tTest\""},
30-
new[]{ "Test\\Test", "\"Test\\\\Test\""},
31-
new[]{ "Test\"Test", "\"Test\\\"Test\""},
32-
new[]{ "StringsWith\"Quotes\"", "\"StringsWith\\\"Quotes\\\"\""},
33-
new[]{ "0x1234", "\"0x1234\""},
34-
}
35-
from shouldBeTerse in shouldProduceTerseOutputValues
36-
select new object[] { inputExpected[0], inputExpected[1], shouldBeTerse };
37-
}
21+
get =>
22+
from inputExpected in new[] {
23+
new[]{ "Test\bTest", "\"Test\\bTest\"" },
24+
new[]{ "Test\fTest", "\"Test\\fTest\""},
25+
new[]{ "Test\nTest", "\"Test\\nTest\""},
26+
new[]{ "Test\rTest", "\"Test\\rTest\""},
27+
new[]{ "Test\tTest", "\"Test\\tTest\""},
28+
new[]{ "Test\\Test", "\"Test\\\\Test\""},
29+
new[]{ "Test\"Test", "\"Test\\\"Test\""},
30+
new[]{ "StringsWith\"Quotes\"", "\"StringsWith\\\"Quotes\\\"\""},
31+
new[]{ "0x1234", "\"0x1234\""},
32+
}
33+
from shouldBeTerse in shouldProduceTerseOutputValues
34+
select new object[] { inputExpected[0], inputExpected[1], shouldBeTerse };
3835
}
3936

4037
[Theory]

0 commit comments

Comments
 (0)