Skip to content

Commit 4fdac03

Browse files
Merge pull request #5 from SimpleStateMachine/dev
Dev
2 parents 3e8b0ef + b82d06b commit 4fdac03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+517
-112
lines changed

src/SimpleStateMachine.StructuralSearch.Sandbox/Program.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
using System;
22
using System.Linq;
3+
using System.Text.Json;
34
using System.Text.RegularExpressions;
45
using Pidgin;
6+
using SimpleStateMachine.StructuralSearch.Configurations;
57
using SimpleStateMachine.StructuralSearch.Extensions;
68
using SimpleStateMachine.StructuralSearch.Rules;
9+
using YamlDotNet.Serialization;
10+
using YamlDotNet.Serialization.NamingConventions;
711
using static Pidgin.Parser;
812
using String = System.String;
913

src/SimpleStateMachine.StructuralSearch.Sandbox/SimpleStateMachine.StructuralSearch.Sandbox.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
<ItemGroup>
1212
<PackageReference Include="Pidgin" Version="3.0.0" />
13+
<PackageReference Include="YamlDotNet" Version="11.2.1" />
1314
</ItemGroup>
1415

1516
<ItemGroup>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Configurations:
2+
- FindTemplate: |-
3+
if($var$ $sign$ null)
4+
{
5+
$var$ = $value$;
6+
}
7+
FindRules:
8+
- $sign$ In ("Is", "==")
9+
ReplaceTemplate: |-
10+
$var$ ??= $value$;
11+
ReplaceRules:
12+
13+
14+
15+
- FindTemplate: |-
16+
if($condition$)
17+
return $value1$;
18+
else
19+
return $value2$;
20+
FindRules:
21+
ReplaceTemplate: |-
22+
return $condition$? $value1$ : $value2$;
23+
ReplaceRules:
24+
25+
26+
27+
- FindTemplate: |-
28+
if($value1$ $sign$ null)
29+
{
30+
$var$ = $value1$;
31+
}
32+
else
33+
{
34+
$var$ = $value2$;
35+
}
36+
FindRules:
37+
- $sign$ In ("Is", "==")
38+
ReplaceTemplate: |-
39+
$var$ = $value1$ ?? $value2$;
40+
ReplaceRules:
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Configurations:
2+
- FindTemplate: |-
3+
if($var$ $sign$ null)
4+
{
5+
$var$ = $value$;
6+
}
7+
FindRules:
8+
- $sign$ In ("Is", "==")
9+
ReplaceTemplate: |-
10+
$var$ ??= $value$;
11+
12+
13+
14+
- FindTemplate: |-
15+
if($condition$)
16+
return $value1$;
17+
else
18+
return $value2$;
19+
ReplaceTemplate: |-
20+
return $condition$? $value1$ : $value2$;
21+
22+
23+
24+
- FindTemplate: |-
25+
if($value1$ $sign$ null)
26+
{
27+
$var$ = $value1$;
28+
}
29+
else
30+
{
31+
$var$ = $value2$;
32+
}
33+
FindRules:
34+
- $sign$ In ("Is", "==")
35+
ReplaceTemplate: |-
36+
$var$ = $value1$ ?? $value2$;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Collections.Generic;
2+
using System.IO;
3+
using System.Text.Json;
4+
using Pidgin;
5+
using SimpleStateMachine.StructuralSearch.Configurations;
6+
using Xunit;
7+
using YamlDotNet.Serialization;
8+
using YamlDotNet.Serialization.NamingConventions;
9+
10+
namespace SimpleStateMachine.StructuralSearch.Tests
11+
{
12+
public class ConfigurationFileTests
13+
{
14+
[Theory]
15+
[InlineData("ConfigurationFile/ShortConfig.yml")]
16+
[InlineData("ConfigurationFile/FullConfig.yml")]
17+
public void ConfigurationFileParsingShouldBeSuccess(string filePath)
18+
{
19+
var yml = File.ReadAllText(filePath);
20+
var deserializer = new DeserializerBuilder()
21+
.WithNamingConvention(PascalCaseNamingConvention.Instance)
22+
.Build();
23+
24+
var cfg = deserializer.Deserialize<ConfigurationsFile>(yml);
25+
}
26+
27+
// private ConfigurationsFile Mock()
28+
// {
29+
// var configurationFile = new ConfigurationsFile();
30+
//
31+
// }
32+
}
33+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$sign$ In ("Is", "==")

src/SimpleStateMachine.StructuralSearch.Tests/FindTemplate/IfElseTemplate.txt renamed to src/SimpleStateMachine.StructuralSearch.Tests/FindTemplate/IfElseFindTemplate.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if($var1$ $sign$ $value1$)
1+
if($var1$ $sign$ $some1$)
22
{
33
$var$ = $value1$;
44
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
if($condition$)
2+
return $value1$;
3+
else
4+
return $value2$;

0 commit comments

Comments
 (0)