Skip to content

Commit 98a7e6e

Browse files
authored
Fix naming conventions and line ending issues (#43)
1 parent 149ae49 commit 98a7e6e

File tree

21 files changed

+578
-560
lines changed

21 files changed

+578
-560
lines changed

.editorconfig

+15-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ tab_width = 4
1313

1414
# New line preferences
1515
end_of_line = crlf
16-
insert_final_newline = false
16+
insert_final_newline = true
17+
18+
# Other
19+
trim_trailing_whitespace = true
20+
charset = utf-8
1721

1822
#### .NET Coding Conventions ####
1923

@@ -167,7 +171,7 @@ dotnet_naming_rule.types_should_be_pascal_case.severity = warning
167171
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
168172
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
169173

170-
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = silent
174+
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = warning
171175
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
172176
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
173177

@@ -196,3 +200,12 @@ dotnet_naming_style.begins_with_i.required_prefix = I
196200
dotnet_naming_style.begins_with_i.required_suffix =
197201
dotnet_naming_style.begins_with_i.word_separator =
198202
dotnet_naming_style.begins_with_i.capitalization = pascal_case
203+
204+
# internal and private fields should be _camelCase
205+
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = warning
206+
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
207+
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
208+
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
209+
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
210+
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
211+
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case

.gitattributes

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Don't do any line ending normalization, ever
2+
* -text
3+
4+
# Improve diffing
5+
*.cs diff=csharp
6+
*.cpp diff=cpp
7+
*.hpp diff=cpp
8+
*.c diff=cpp
9+
*.h diff=cpp
10+
11+
# Prevent git from interpreting dot as Microsoft Word documents while diffing.
12+
*.dot !diff
13+
*.DOT !diff

.github/workflows/main.yml

+64-58
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,64 @@
1-
# This is a basic workflow to help you get started with Actions
2-
3-
name: CI
4-
5-
# Controls when the action will run. Triggers the workflow on push or pull request
6-
# events but only for the master branch
7-
on:
8-
push:
9-
branches: [ master ]
10-
pull_request:
11-
branches: [ master ]
12-
13-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
14-
# https://timheuer.com/blog/building-net-framework-apps-using-github-actions/
15-
jobs:
16-
# This workflow contains a single job called "build"
17-
build:
18-
19-
runs-on: windows-latest
20-
21-
# Steps represent a sequence of tasks that will be executed as part of the job
22-
steps:
23-
- uses: actions/checkout@v1
24-
name: Checkout Code
25-
26-
- name: Add msbuild to PATH
27-
uses: microsoft/[email protected]
28-
29-
- name: Setup NuGet.exe for use with actions
30-
uses: NuGet/[email protected]
31-
32-
- name: Restore NuGet Packages
33-
run: nuget restore Rubjerg.Graphviz.sln
34-
35-
- name: Build App
36-
run: msbuild Rubjerg.Graphviz.sln /p:Configuration=Release
37-
38-
- name: Check if README is up-to-date
39-
run: git diff --exit-code -- README.md
40-
41-
- name: Run Unittests With Coverage Calculation
42-
run: packages\opencover\4.7.922\tools\OpenCover.Console.exe -returntargetcode -skipautoprops -register '-target:packages\nunit.consolerunner\3.12.0\tools\nunit3-console.exe' -targetargs:'Rubjerg.Graphviz.Test\bin\x64\Release\net48\Rubjerg.Graphviz.Test.dll --where \"cat!=Slow and cat!=Flaky\" ' '-filter:+[Rubjerg*]* -[Rubjerg.Graphviz.Test*]*'
43-
44-
- name: Upload Coverage data
45-
run: |
46-
echo "C:\msys64\usr\bin" >> $GITHUB_PATH
47-
Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh
48-
bash codecov.sh -f "results.xml"
49-
50-
- name: Run Nuget Tests
51-
run: packages\nunit.consolerunner\3.12.0\tools\nunit3-console.exe Rubjerg.Graphviz.NugetTest\bin\x64\Release\net48\Rubjerg.Graphviz.NugetTest.dll
52-
53-
- name: Run Transitive Tests
54-
run: packages\nunit.consolerunner\3.12.0\tools\nunit3-console.exe Rubjerg.Graphviz.TransitiveTest\bin\x64\Release\net48\Rubjerg.Graphviz.TransitiveTest.dll
55-
56-
- name: Run Transitive Nuget Tests
57-
run: packages\nunit.consolerunner\3.12.0\tools\nunit3-console.exe Rubjerg.Graphviz.TransitiveNugetTest\bin\x64\Release\net48\Rubjerg.Graphviz.TransitiveNugetTest.dll
58-
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: CI
4+
5+
# Controls when the action will run. Triggers the workflow on push or pull request
6+
# events but only for the master branch
7+
on:
8+
push:
9+
branches: [ master ]
10+
pull_request:
11+
branches: [ master ]
12+
13+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
14+
# https://timheuer.com/blog/building-net-framework-apps-using-github-actions/
15+
jobs:
16+
# This workflow contains a single job called "build"
17+
build:
18+
19+
runs-on: windows-latest
20+
21+
# Steps represent a sequence of tasks that will be executed as part of the job
22+
steps:
23+
- uses: actions/checkout@v1
24+
name: Checkout Code
25+
26+
- name: Check if line endings are CRLF
27+
run: |
28+
bash -c "git grep -rlIP . | xargs unix2dos"
29+
echo test
30+
git diff --exit-code
31+
32+
- name: Add msbuild to PATH
33+
uses: microsoft/[email protected]
34+
35+
- name: Setup NuGet.exe for use with actions
36+
uses: NuGet/[email protected]
37+
38+
- name: Restore NuGet Packages
39+
run: nuget restore Rubjerg.Graphviz.sln
40+
41+
- name: Build App
42+
run: msbuild Rubjerg.Graphviz.sln /p:Configuration=Release
43+
44+
- name: Check if README is up-to-date
45+
run: git diff --exit-code -- README.md
46+
47+
- name: Run Unittests With Coverage Calculation
48+
run: packages\opencover\4.7.922\tools\OpenCover.Console.exe -returntargetcode -skipautoprops -register '-target:packages\nunit.consolerunner\3.12.0\tools\nunit3-console.exe' -targetargs:'Rubjerg.Graphviz.Test\bin\x64\Release\net48\Rubjerg.Graphviz.Test.dll --where \"cat!=Slow and cat!=Flaky\" ' '-filter:+[Rubjerg*]* -[Rubjerg.Graphviz.Test*]*'
49+
50+
- name: Upload Coverage data
51+
run: |
52+
echo "C:\msys64\usr\bin" >> $GITHUB_PATH
53+
Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh
54+
bash codecov.sh -f "results.xml"
55+
56+
- name: Run Nuget Tests
57+
run: packages\nunit.consolerunner\3.12.0\tools\nunit3-console.exe Rubjerg.Graphviz.NugetTest\bin\x64\Release\net48\Rubjerg.Graphviz.NugetTest.dll
58+
59+
- name: Run Transitive Tests
60+
run: packages\nunit.consolerunner\3.12.0\tools\nunit3-console.exe Rubjerg.Graphviz.TransitiveTest\bin\x64\Release\net48\Rubjerg.Graphviz.TransitiveTest.dll
61+
62+
- name: Run Transitive Nuget Tests
63+
run: packages\nunit.consolerunner\3.12.0\tools\nunit3-console.exe Rubjerg.Graphviz.TransitiveNugetTest\bin\x64\Release\net48\Rubjerg.Graphviz.TransitiveNugetTest.dll
64+

.gitignore

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
.vs
2-
packages/
3-
TestResult.xml
4-
results.xml
5-
*.nupkg
6-
NativeFiles/
1+
.vs
2+
packages/
3+
TestResult.xml
4+
results.xml
5+
*.nupkg
6+
NativeFiles/

GraphvizWrapper/.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
bin
2-
*.vcxproj.user
1+
bin
2+
*.vcxproj.user

GraphvizWrapper/Main.cpp

+22-22
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ using namespace std;
1313
extern "C" {
1414

1515
// Some wrappers around existing cgraph functions to handle string marshaling
16-
__declspec(dllexport) const char* imagmemwrite(Agraph_t * g);
17-
__declspec(dllexport) Agraph_t* imagmemread(const char* s);
18-
__declspec(dllexport) const char* imagget(void* obj, char* name);
19-
__declspec(dllexport) const char* imagnameof(void* obj);
20-
__declspec(dllexport) Agraph_t* imagopen(char* name, int graphtype);
21-
__declspec(dllexport) const char *imsym_key(Agsym_t *sym);
16+
__declspec(dllexport) const char* rj_agmemwrite(Agraph_t * g);
17+
__declspec(dllexport) Agraph_t* rj_agmemread(const char* s);
18+
__declspec(dllexport) const char* rj_agget(void* obj, char* name);
19+
__declspec(dllexport) const char* rj_agnameof(void* obj);
20+
__declspec(dllexport) Agraph_t* rj_agopen(char* name, int graphtype);
21+
__declspec(dllexport) const char *rj_sym_key(Agsym_t *sym);
2222

2323
__declspec(dllexport) double node_x(Agnode_t* node);
2424
__declspec(dllexport) double node_y(Agnode_t* node);
@@ -44,7 +44,7 @@ extern "C" {
4444
// Test and debug functions
4545
__declspec(dllexport) bool echobool(bool arg);
4646
__declspec(dllexport) int echoint(int arg);
47-
__declspec(dllexport) void imdebug();
47+
__declspec(dllexport) void rj_debug();
4848
}
4949

5050

@@ -57,30 +57,30 @@ char* marshalCString(const char* s)
5757
return ptr;
5858
}
5959

60-
static int imafread(void* stream, char* buffer, int bufsize)
60+
static int rj_afread(void* stream, char* buffer, int bufsize)
6161
{
6262
istringstream* is = (istringstream*) stream;
6363
is->read(buffer, bufsize);
6464
int result = (int) is->gcount();
6565
return result;
6666
}
6767

68-
static int imputstr(void* stream, const char *s)
68+
static int rj_putstr(void* stream, const char *s)
6969
{
7070
ostringstream* os = (ostringstream*) stream;
7171
(*os) << s;
7272
return 0;
7373
}
7474

75-
static int imflush(void* stream)
75+
static int rj_flush(void* stream)
7676
{
7777
ostringstream* os = (ostringstream*) stream;
7878
os->flush();
7979
return 0;
8080
}
8181

8282

83-
static Agiodisc_t memIoDisc = {imafread, imputstr, imflush};
83+
static Agiodisc_t memIoDisc = {rj_afread, rj_putstr, rj_flush};
8484
static Agdisc_t memDisc = {0, 0, &memIoDisc};
8585

8686
textlabel_t* node_label(Agnode_t* node) { return ND_label(node); }
@@ -102,9 +102,9 @@ double node_y(Agnode_t* node) { return ND_coord(node).y; } // in points
102102
double node_width(Agnode_t* node) { return ND_width(node); } // in inches
103103
double node_height(Agnode_t* node) { return ND_height(node); } // in inches
104104

105-
const char *imsym_key(Agsym_t *sym) { return marshalCString(sym->name); }
105+
const char *rj_sym_key(Agsym_t *sym) { return marshalCString(sym->name); }
106106

107-
Agraph_t* imagopen(char* name, int graphtype)
107+
Agraph_t* rj_agopen(char* name, int graphtype)
108108
{
109109
if (graphtype == 0)
110110
return agopen(name, Agdirected, &memDisc);
@@ -117,16 +117,16 @@ Agraph_t* imagopen(char* name, int graphtype)
117117
return 0;
118118
}
119119

120-
Agraph_t* imagmemread(const char* s)
120+
Agraph_t* rj_agmemread(const char* s)
121121
{
122122
stringstream stream;
123123
stream << s;
124124
Agraph_t* g = agread(&stream, &memDisc);
125125
return g;
126126
}
127127

128-
// Note: for this function to work, the graph has to be created with the memDisc, e.g. using imagopen
129-
void imagwrite(Agraph_t * g, const char* filename)
128+
// Note: for this function to work, the graph has to be created with the memDisc, e.g. using rj_agopen
129+
void rj_agwrite(Agraph_t * g, const char* filename)
130130
{
131131
ostringstream os;
132132
agwrite(g, &os);
@@ -135,21 +135,21 @@ void imagwrite(Agraph_t * g, const char* filename)
135135
out.close();
136136
}
137137

138-
// Note: for this function to work, the graph has to be created with the memDisc, e.g. using imagopen
139-
const char* imagmemwrite(Agraph_t * g)
138+
// Note: for this function to work, the graph has to be created with the memDisc, e.g. using rj_agopen
139+
const char* rj_agmemwrite(Agraph_t * g)
140140
{
141141
ostringstream os;
142142
agwrite(g, &os);
143143
return marshalCString(os.str().c_str());
144144
}
145145

146-
const char* imagget(void* obj, char* name)
146+
const char* rj_agget(void* obj, char* name)
147147
{
148148
char* result = agget(obj, name);
149149
return marshalCString(result);
150150
}
151151

152-
const char* imagnameof(void* obj)
152+
const char* rj_agnameof(void* obj)
153153
{
154154
char* result = agnameof(obj);
155155
return marshalCString(result);
@@ -188,11 +188,11 @@ int echoint(int arg)
188188
return arg;
189189
}
190190

191-
void imdebug()
191+
void rj_debug()
192192
{
193193
}
194194

195195
int main()
196196
{
197-
imdebug();
197+
rj_debug();
198198
}

0 commit comments

Comments
 (0)