-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·78 lines (61 loc) · 1.74 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
YEAR=$1
DAY=Day$2
SOLUTION_FILENAME=AdventOfCode$YEAR.sln
if [ $# -lt 2 ]; then
echo "Usage: $0 year day"
exit 1
fi
# Build directory structure
mkdir -p $YEAR
cd $YEAR
mkdir -p $DAY
cd $DAY
# Create solution and projects
dotnet new classlib -o $DAY.Logic
dotnet new xunit -o $DAY.UnitTests
cd $DAY.UnitTests
dotnet add reference ../$DAY.Logic/$DAY.Logic.csproj
# Add using to test file
sed -i "1s/^/using $DAY.Logic;\nusing static $DAY.UnitTests.Constants;\n\n/" UnitTest1.cs
cd ..
dotnet new sln
dotnet sln $DAY.sln add **/*.csproj
# Create editorconfig
cat <<EOT > .editorconfig
[*]
end_of_line = lf
trim_trailing_whitespace = true
indent_size = 4
[*.{cs,vb}]
dotnet_naming_rule.private_members_with_underscore.symbols = private_fields
dotnet_naming_rule.private_members_with_underscore.style = prefix_underscore
dotnet_naming_rule.private_members_with_underscore.severity = suggestion
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
dotnet_naming_style.prefix_underscore.capitalization = camel_case
dotnet_naming_style.prefix_underscore.required_prefix = _
EOT
cd ..
if [ ! -f $SOLUTION_FILENAME ]; then
dotnet new sln
mv $YEAR.sln $SOLUTION_FILENAME
fi
dotnet sln $SOLUTION_FILENAME add $DAY/**/*.csproj
cd $DAY
# Create Constants.cs
cat <<EOT > $DAY.UnitTests/Constants.cs
namespace $DAY.UnitTests;
public static class Constants
{
public const string SAMPLE_INPUT = @"";
public const string PUZZLE_INPUT = @"";
}
EOT
# Convert all files to LF
dos2unix $DAY.UnitTests/$DAY.UnitTests.csproj
dos2unix $DAY.UnitTests/UnitTest1.cs
dos2unix $DAY.Logic/$DAY.Logic.csproj
dos2unix $DAY.Logic/Class1.cs
# Open Visual Studio Code
code -r .
exit 0