Skip to content

Commit 5240c8f

Browse files
committed
Merge branch 'feature/geryxyz/csharp'
2 parents 9827757 + 9c57163 commit 5240c8f

File tree

5 files changed

+394
-0
lines changed

5 files changed

+394
-0
lines changed

.editorconfig

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
[*]
2+
end_of_line = crlf
3+
4+
[*.xml]
5+
indent_style = space
6+
7+
[*.cs]
8+
charset = utf-8
9+
indent_style = space
10+
indent_size = 4
11+
trim_trailing_whitespace = false
12+
insert_final_newline = true
13+
csharp_style_conditional_delegate_call = true:warning
14+
csharp_style_expression_bodied_accessors = when_on_single_line:warning
15+
csharp_style_expression_bodied_constructors = when_on_single_line:suggestion
16+
csharp_style_expression_bodied_indexers = when_on_single_line:warning
17+
csharp_style_expression_bodied_methods = when_on_single_line:suggestion
18+
csharp_style_expression_bodied_operators = when_on_single_line:suggestion
19+
csharp_style_expression_bodied_properties = when_on_single_line:warning
20+
csharp_style_inlined_variable_declaration = true:warning
21+
csharp_style_pattern_matching_over_as_with_null_check = true:warning
22+
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
23+
csharp_style_throw_expression = true:suggestion
24+
csharp_style_var_elsewhere = false:error
25+
csharp_style_var_for_built_in_types = false:error
26+
csharp_style_var_when_type_is_apparent = true:suggestion
27+
csharp_new_line_before_catch = true
28+
csharp_new_line_before_else = true
29+
csharp_new_line_before_finally = true
30+
csharp_new_line_before_members_in_anonymous_types = true
31+
csharp_new_line_before_members_in_object_initializers = true
32+
csharp_new_line_before_open_brace = all
33+
csharp_new_line_between_query_expression_clauses = true
34+
csharp_indent_case_contents = true
35+
csharp_indent_labels = one_less_than_current
36+
csharp_indent_switch_labels = false
37+
csharp_preserve_single_line_blocks = true
38+
csharp_preserve_single_line_statements = true
39+
csharp_space_after_cast = false
40+
csharp_space_after_keywords_in_control_flow_statements = false
41+
csharp_space_between_method_call_parameter_list_parentheses = true
42+
csharp_space_between_method_declaration_parameter_list_parentheses = true
43+
csharp_space_between_parentheses = expressions
44+
csharp_prefer_braces = true
45+
csharp_prefer_simple_default_expression = true
46+
dotnet_sort_system_directives_first = true
47+
dotnet_style_coalesce_expression = true:error
48+
dotnet_style_collection_initializer = true:warning
49+
dotnet_style_explicit_tuple_names = true:error
50+
dotnet_style_null_propagation = true:error
51+
dotnet_style_object_initializer = true:warning
52+
dotnet_style_predefined_type_for_locals_parameters_members = true:error
53+
dotnet_style_predefined_type_for_member_access = true:error
54+
dotnet_style_qualification_for_event = false:suggestion
55+
dotnet_style_qualification_for_field = false:suggestion
56+
dotnet_style_qualification_for_method = false:suggestion
57+
dotnet_style_qualification_for_property = false:suggestion
58+
dotnet_naming_rule.public_member_PascalCase.symbols = public_symbols
59+
dotnet_naming_symbols.public_symbols.applicable_kinds = property,method,field,event
60+
dotnet_naming_symbols.public_symbols.applicable_accessibilities = public
61+
dotnet_naming_style.PascalCase.capitalization = pascal_case
62+
dotnet_naming_rule.public_member_PascalCase.style = PascalCase

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@
3030
*.vrb
3131
*.xdy
3232
*.tdo
33+
*.pdf

convention.tex

Lines changed: 284 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,284 @@
1+
\documentclass[11pt,a4paper]{book}
2+
\usepackage[utf8]{inputenc}
3+
\usepackage[english]{babel}
4+
\usepackage{paralist}
5+
6+
\usepackage{doavoidnot}
7+
8+
\author{Gergő Balogh}
9+
\title{Code Convention}
10+
\begin{document}
11+
\maketitle
12+
13+
\chapter{C\#}
14+
15+
\section{Capitalization styles}
16+
\paragraph{Pascal case} The first letter in the identifier and the first letter of each subsequent concatenated word are capitalized. \verb|PascalCase|
17+
\paragraph{Camel case} The first letter of an identifier is lowercase and the first letter of each subsequent concatenated word is capitalized. \verb|camelCase|
18+
\paragraph{Uppercase} All letters in the identifier are capitalized. \verb|UPPERCASE|
19+
20+
\section{Naming}
21+
22+
\domark Use pascal case if the visibility of entity is public.
23+
\begin{verbatim}
24+
public
25+
void Something()
26+
\end{verbatim}
27+
28+
\domark Use camel case if the visibility of method, attribute, property or event is non-public.
29+
\begin{verbatim}
30+
private
31+
void something()
32+
33+
internal
34+
void something()
35+
\end{verbatim}
36+
37+
\domark Use camel case and start the identifier with an underscore (\_) if the visibility of variable is local.
38+
\begin{verbatim}
39+
internal
40+
void something()
41+
{
42+
int _count;
43+
}
44+
\end{verbatim}
45+
46+
\whymark You can use code completion to quickly list all local variables, just type the underscore sing (\_).
47+
48+
\domark Use camel case and start the name of parameters of lambda expressions with an underscore (\_).
49+
\begin{verbatim}
50+
var foo = ( _a, _b ) => _a + _b;
51+
\end{verbatim}
52+
53+
\domark Use the variable name \_ (a single underscore) to denote variables in lambda expressions, which is irrelevant in the current context.
54+
\begin{verbatim}
55+
(_, _b) => _b + 1
56+
\end{verbatim}
57+
58+
\domark Use pascal case in the name of namespaces, classes, interfaces, structures, enumerations and members of enumerations.
59+
60+
\domark Start name of interfaces with a capital I.
61+
62+
\domark Start name of generic type parameters with a capital T.
63+
\begin{verbatim}
64+
class ExampleClass< TValue >
65+
66+
interface IExampleInterface
67+
68+
enum ExampleEnum
69+
70+
struct ExampleStruct
71+
\end{verbatim}
72+
73+
\domark Use camel case in the name of parameters of methods.
74+
\begin{verbatim}
75+
void Somthing( int somethingToRead )
76+
\end{verbatim}
77+
78+
\notmark Do not use Hungarian notion.
79+
\begin{verbatim}
80+
int i_foo;
81+
float f_foo;
82+
\end{verbatim}
83+
84+
\whymark It usually results cryptic abbreviation and types are noted and shown by Visual Studio or any other IDE.
85+
86+
\avoidmark Avoid using single letter variable names.
87+
\begin{verbatim}
88+
//avoid
89+
int a;
90+
int b;
91+
92+
//do
93+
int componentA;
94+
int componentB;
95+
\end{verbatim}
96+
97+
\notmark Do not mark member with m\_ prefix.
98+
\begin{verbatim}
99+
int m_length //wrong
100+
101+
int length //right
102+
\end{verbatim}
103+
104+
\notmark Do not use white-spaces to construct columns in the source code.
105+
\begin{verbatim}
106+
//do
107+
int length = 10;
108+
string name = "Thangorodrim;
109+
110+
//wrong
111+
int length = 10;
112+
string name = "Thangorodrim;
113+
\end{verbatim}
114+
115+
\whymark It suggest structures which do not exist.
116+
117+
\avoidmark Avoid uncommon abbreviation. Use abbreviation, when you have no other choice.
118+
\begin{verbatim}
119+
string Idkwit = "true"; //I Don't Know What Is This
120+
\end{verbatim}
121+
122+
\domark Use the same case as in their first letter of abbreviation less then three character long.
123+
\begin{verbatim}
124+
private
125+
void uiReader()
126+
127+
private
128+
void readerUI()
129+
130+
public
131+
void UIReader()
132+
\end{verbatim}
133+
134+
\domark Use camel case in abbreviation more then two letters long.
135+
\begin{verbatim}
136+
private
137+
void umlReader()
138+
139+
public
140+
void UmlReader()
141+
\end{verbatim}
142+
143+
\avoidmark Avoid the using the following words.
144+
\begin{compactitem}
145+
\item data
146+
\item information
147+
\item some
148+
\item do
149+
\item make
150+
\end{compactitem}
151+
152+
\whymark Because they are too general to provide useful information.
153+
154+
\notmark Do not use plural form in the name of namespaces, classes, interfaces, structures, enumerations and members of enumerations.
155+
\begin{verbatim}
156+
//wrong
157+
items
158+
men
159+
160+
//right
161+
itemCollection
162+
manCollection
163+
\end{verbatim}
164+
165+
\whymark It is easy to misread the plural and singular forms. Can not find irregular forms by searching singulars.
166+
167+
\section{Layout}
168+
169+
\avoidmark Avoid lines longer then 80 characters. Prefer shorter lines as much as possible.
170+
171+
\subsection{Horizontal spacing}
172+
173+
\notmark Do not put spaces inside empty parentheses.
174+
175+
\domark Use spaces at the inner side of all parentheses, except curly braces.
176+
\begin{verbatim}
177+
( Something< int >( _foo[ bla ] ) ) * 10
178+
\end{verbatim}
179+
180+
\domark Use spaces around operators, except parentheses, point (.), increment (\verb|++|) and decrement (\verb|--|) operators.
181+
\begin{verbatim}
182+
int foo = ( ( x == 0 ) ? ( z + 3 ) : bar.some[ 42 ] )
183+
foo++;
184+
\end{verbatim}
185+
186+
\domark Use spaces instead of tabs at the beginning of the line.
187+
188+
\domark Use four spaces per each indentation level. 4 spaces = 1 tab
189+
190+
\notmark Do not mix tabs and spaces at the beginning of the line.
191+
192+
\domark Only increment the indentation level one-by-one.
193+
194+
\subsection{Line-breaks}
195+
196+
\domark Put curly braces in their own empty lines.
197+
\begin{verbatim}
198+
void foo()
199+
{
200+
if( true )
201+
{
202+
bla++;
203+
}
204+
}
205+
\end{verbatim}
206+
207+
\domark Put member modifiers in a separate line.
208+
\begin{verbatim}
209+
public static
210+
void Something()
211+
212+
private
213+
int count;
214+
\end{verbatim}
215+
216+
\domark Write getter and setter with one or no modifier in the same line with the name of auto property.
217+
\begin{verbatim}
218+
public
219+
int Count{ get; private set; }
220+
\end{verbatim}
221+
222+
\domark If necessary break line after equal sign (=).
223+
\begin{verbatim}
224+
int _count =
225+
x + 567567563 / 2121231 + foobar;
226+
\end{verbatim}
227+
228+
\domark If necessary break line before operators, except parentheses and assignment (=).
229+
\begin{verbatim}
230+
string _text =
231+
"this is a long string need to be"
232+
+ "broken into seperate lines";
233+
234+
"to write something"
235+
.Let().TaggedAsInformation()
236+
.Write();
237+
\end{verbatim}
238+
239+
\domark Put the closing parentheses in the same line with the last parameter, except curly braces.
240+
\begin{verbatim}
241+
int grantPermissions(
242+
string user,
243+
string password,
244+
int id,
245+
PersmissionSet permission )
246+
\end{verbatim}
247+
248+
\domark If necessary prefer to start method calls in a new line.
249+
250+
\domark Put all or none of the parameters into separate lines.
251+
\begin{verbatim}
252+
int count =
253+
AvarageOf(
254+
foo,
255+
bar,
256+
asd );
257+
\end{verbatim}
258+
259+
\subsection{Vertical spaces}
260+
261+
\domark Separate members in classes with an empty lines.
262+
\begin{verbatim}
263+
private
264+
int foo
265+
266+
public
267+
void Something()
268+
\end{verbatim}
269+
270+
\section{Commenting}
271+
272+
\domark Prefer documenting comments (///) over general one (//).
273+
274+
\notmark Do not use block comments (/* */).
275+
276+
\appendix
277+
278+
\chapter{C\#}
279+
280+
\section{EditorConfig for Visual Studio}
281+
282+
For further details and \emph{some} automatic style and convention settings please use the \texttt{.editorcongif} file next to this document. It only contains Visual Studio and C\#{} specific settings. This file do not cover every details present in this documents and provided \emph{as is}.
283+
284+
\end{document}

test.tex

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
\documentclass{book}
2+
\usepackage[utf8]{inputenc}
3+
\usepackage[english]{babel}
4+
5+
\usepackage{doavoidnot}
6+
7+
\begin{document}
8+
\domark Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eu sapien augue. Suspendisse potenti. Aliquam ultrices quam tortor, at cursus lorem suscipit sit amet. Donec vulputate eleifend ultrices. Mauris vel magna sit amet enim sollicitudin tincidunt. Praesent congue dictum nibh et fringilla. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nam faucibus erat at hendrerit accumsan. Sed facilisis laoreet dolor sed tempor. Duis tellus lectus, ultrices et viverra feugiat, faucibus quis elit. Morbi lacinia et justo eu ornare.
9+
10+
\avoidmark Ut porttitor, elit quis commodo porta, augue purus aliquet nisi, ac lacinia odio justo sed neque. Vestibulum sed elit vel lectus pellentesque euismod et ut diam. Pellentesque eu tellus arcu. Sed tincidunt ligula eu elit sagittis sagittis.
11+
12+
\whymark Phasellus consequat eros nec molestie bibendum. Pellentesque dignissim laoreet felis, vel dictum nulla ultrices eu. Sed volutpat lorem
13+
14+
\notmark nec tempor placerat. Nulla in purus id orci egestas condimentum sed non elit. Vestibulum leo enim, rutrum quis est id, porta convallis tortor. Curabitur sit amet purus ut ipsum commodo suscipit sit amet et purus. Fusce ac mi massa. Nullam commodo condimentum urna sit amet hendrerit. Fusce tempor semper turpis et mattis. Curabitur congue molestie nibh.
15+
\end{document}

0 commit comments

Comments
 (0)