Skip to content

Commit 53c2102

Browse files
committed
convert to target type inference
1 parent 5f2b6c7 commit 53c2102

5 files changed

Lines changed: 22 additions & 26 deletions

File tree

src/ServiceStack.Interfaces/Logging/TestLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public enum Levels {
3131
WARN,
3232
};
3333

34-
static private List<KeyValuePair<Levels, string>> _logs = new List<KeyValuePair<Levels, string>>();
34+
static private List<KeyValuePair<Levels, string>> _logs = new();
3535

3636

3737
static public IList<KeyValuePair<Levels, string>> GetLogs() { return _logs; }

src/ServiceStack.Interfaces/RouteAttribute.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,23 +166,23 @@ public ReflectAttribute ToReflectAttribute()
166166
{
167167
return new ReflectAttribute {
168168
ConstructorArgs = new List<KeyValuePair<PropertyInfo, object>> {
169-
new KeyValuePair<PropertyInfo, object>(GetType().GetProperty(nameof(Path)), Path),
170-
new KeyValuePair<PropertyInfo, object>(GetType().GetProperty(nameof(Verbs)), Verbs),
169+
new(GetType().GetProperty(nameof(Path)), Path),
170+
new(GetType().GetProperty(nameof(Verbs)), Verbs),
171171
}
172172
};
173173
}
174174

175175
return new ReflectAttribute {
176176
ConstructorArgs = new List<KeyValuePair<PropertyInfo, object>> {
177-
new KeyValuePair<PropertyInfo, object>(GetType().GetProperty(nameof(Path)), Path),
177+
new(GetType().GetProperty(nameof(Path)), Path),
178178
}
179179
};
180180
}
181181

182182
//Otherwise return Property Args
183183
var to = new ReflectAttribute {
184184
PropertyArgs = new List<KeyValuePair<PropertyInfo, object>> {
185-
new KeyValuePair<PropertyInfo, object>(GetType().GetProperty(nameof(Path)), Path),
185+
new(GetType().GetProperty(nameof(Path)), Path),
186186
}
187187
};
188188
if (Verbs != null)

src/ServiceStack.Razor/Managers/RazorGen/RazorViewPageTransformer.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ public RazorViewPageTransformer(Type pageBaseType)
1313
this.codeTransformers.Add(new SetBaseType(pageBaseType));
1414
}
1515

16-
private static readonly HashSet<string> namespaces = new HashSet<string>()
16+
private static readonly HashSet<string> namespaces = new()
1717
{
1818
"System",
1919
};
2020

21-
private readonly List<RazorCodeTransformerBase> codeTransformers = new List<RazorCodeTransformerBase>
22-
{
21+
private readonly List<RazorCodeTransformerBase> codeTransformers = new() {
2322
new AddGeneratedClassAttribute(),
2423
new AddPageVirtualPathAttribute(),
2524
new SetImports( namespaces, replaceExisting: false ),
@@ -28,10 +27,7 @@ public RazorViewPageTransformer(Type pageBaseType)
2827
new WebConfigTransformer()
2928
};
3029

31-
protected override IEnumerable<RazorCodeTransformerBase> CodeTransformers
32-
{
33-
get { return this.codeTransformers; }
34-
}
30+
protected override IEnumerable<RazorCodeTransformerBase> CodeTransformers => this.codeTransformers;
3531

3632
public override void Initialize(RazorPageHost razorHost, IDictionary<string, string> directives)
3733
{

tests/ServiceStack.WebHost.Endpoints.Tests/ScriptTests/QueryTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ public void Take_does_limit_KVP_Objects()
1313
var context = new ScriptContext {
1414
Args = {
1515
["items"] = new List<KeyValuePair<string, object>> {
16-
new KeyValuePair<string, object>("A", 1),
17-
new KeyValuePair<string, object>("B", 2),
18-
new KeyValuePair<string, object>("C", 3),
16+
new("A", 1),
17+
new("B", 2),
18+
new("C", 3),
1919
}
2020
}
2121
}.Init();
@@ -38,9 +38,9 @@ public void Take_does_limit_KVP_longs()
3838
var context = new ScriptContext {
3939
Args = {
4040
["items"] = new List<KeyValuePair<string, long>> {
41-
new KeyValuePair<string, long>("A", 1),
42-
new KeyValuePair<string, long>("B", 2),
43-
new KeyValuePair<string, long>("C", 3),
41+
new("A", 1),
42+
new("B", 2),
43+
new("C", 3),
4444
}
4545
}
4646
}.Init();

tests/ServiceStack.WebHost.Endpoints.Tests/ScriptTests/ScriptCodeTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,10 @@ public void Can_execute_existing_Script_Blocks_in_Code_Statements_in_Code_Syntax
664664

665665
result = context.EvaluateCode(code);
666666
Assert.That(result, Is.EquivalentTo(new List<KeyValuePair<string, string>> {
667-
new KeyValuePair<string, string>("Apples","2"),
668-
new KeyValuePair<string, string>("Oranges","3"),
669-
new KeyValuePair<string, string>("Grape Fruit","2"),
670-
new KeyValuePair<string, string>("Rock Melon","3"),
667+
new("Apples","2"),
668+
new("Oranges","3"),
669+
new("Grape Fruit","2"),
670+
new("Rock Melon","3"),
671671
}));
672672
Assert.That(context.EvaluateCode(code.Trim()), Is.EquivalentTo((List<KeyValuePair<string, string>>)result));
673673

@@ -681,10 +681,10 @@ public void Can_execute_existing_Script_Blocks_in_Code_Statements_in_Code_Syntax
681681
list |> return";
682682
result = context.EvaluateCode(code);
683683
Assert.That(result, Is.EquivalentTo(new List<List<string>> {
684-
new List<string> { "Apples", "2", "2" },
685-
new List<string> { "Oranges", "3", "3" },
686-
new List<string> { "Grape Fruit", "2", "2" },
687-
new List<string> { "Rock Melon", "3", "3" },
684+
new() { "Apples", "2", "2" },
685+
new() { "Oranges", "3", "3" },
686+
new() { "Grape Fruit", "2", "2" },
687+
new() { "Rock Melon", "3", "3" },
688688
}));
689689
Assert.That(context.EvaluateCode(code.Trim()), Is.EquivalentTo((List<List<string>>)result));
690690

0 commit comments

Comments
 (0)