summaryrefslogtreecommitdiff
path: root/src/bindings
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-12-30 21:42:24 +0000
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2019-12-30 22:17:32 -0300
commite632c1334a123a2793776b0b60c04ebf00fcd7b8 (patch)
tree3d070a2e441c5e6dd0e79278d50622b3a3fe5585 /src/bindings
parent2af38d11ed58d95f050dc08cc038d6b4aa30ac91 (diff)
csharp: Add StyleCop support to dotnet build
This patch adds support to run the StyleCop rules. To enable, -Ddotnet=true is needed, You can pass -Ddotnet-stylecop=CAXXXX,CAXXYY where X and Y are digits for CAs or SAs. You can also ask that the CAs and SAs cause errors instead of warnings. Differential Revision: https://phab.enlightenment.org/D10969
Diffstat (limited to 'src/bindings')
-rw-r--r--src/bindings/mono/ca.ruleset.in334
-rw-r--r--src/bindings/mono/efl_sharp.csproj.in14
-rw-r--r--src/bindings/mono/meson.build71
3 files changed, 410 insertions, 9 deletions
diff --git a/src/bindings/mono/ca.ruleset.in b/src/bindings/mono/ca.ruleset.in
new file mode 100644
index 0000000000..0f5be8816c
--- /dev/null
+++ b/src/bindings/mono/ca.ruleset.in
@@ -0,0 +1,334 @@
1<?xml version="1.0" encoding="utf-8"?>
2<RuleSet Name="CustomRulset" Description="Custom Rulset" ToolsVersion="14.0">
3 <Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
4 <!-- Do not declare static members on Generic Types -->
5 @CA1000@
6 <!-- Consider making Raise an event -->
7 @CA1030@
8 <!-- Catch generic exception -->
9 @CA1031@
10 <!-- Add extra exception constructors -->
11 @CA1032@
12 <!-- Do not nest NativeTypes -->
13 @CA1034@
14 <!-- IComparable must implement other comparison operators -->
15 @CA1036@
16 <!-- Avoid empty interface -->
17 @CA1040@
18 <!-- Use Integral Or String Argument For Indexers -->
19 @CA1043@
20 <!-- Consider making property with getter -->
21 @CA1044@
22 <!-- Visible instance fields -->
23 @CA1051@
24 <!-- Static holder can be static -->
25 @CA1052@
26 <!-- Using parameters before checking for null -->
27 @CA1062@
28 <!-- Remove IDisposable as Object already has it -->
29 @CA1063@
30 <!-- Exceptions must be public -->
31 @CA1064@
32 <!-- Do not raise exception in unexpected locations -->
33 @CA1065@
34 <!-- String localization -->
35 @CA1303@
36 <!-- Specify IFormatProvider -->
37 @CA1305@
38 <!-- Specify Stringcomparison -->
39 @CA1307@
40 <!-- PInvoke should not be visible -->
41 @CA1401@
42 <!-- Use nameof -->
43 @CA1507@
44 <!-- Parameter underscore -->
45 @CA1707@
46 <!-- Attribute classes must have the Attribute Suffix -->
47 @CA1710@
48 <!-- Replace generic parameter with T -->
49 @CA1715@
50 <!-- Parameter End conflicts with VB -->
51 @CA1716@
52 <!-- Enum field must be plural -->
53 @CA1717@
54 <!-- Variable has type name -->
55 @CA1720@
56 <!-- Property with same name as getter -->
57 @CA1721@
58 <!-- Type name must not match namespace -->
59 @CA1724@
60 <!-- Unused parameter. Lots of warnings regarding Dispose(disposing) -->
61 @CA1801@
62 <!-- Do not ignore function result -->
63 @CA1806@
64 <!-- Remove static constructors -->
65 @CA1810@
66 <!-- Realized classes are never instantiated -->
67 @CA1812@
68 <!-- Override equal and operator equal on Value Types-->
69 @CA1815@
70 <!-- Dispose must call SuppressFinalizers -->
71 @CA1816@
72 <!-- Member can be static -->
73 @CA1822@
74 <!-- Consider zero length array allocation -->
75 @CA1825@
76 <!-- Count() is used where Any() could be used instead to improve performance -->
77 @CA1827@
78 <!-- Use Count instead of Count() -->
79 @CA1829@
80 <!-- Call dispose before going out of scope -->
81 @CA2000@
82 <!-- Call ConfigureWait-->
83 @CA2007@
84 <!-- PInvoke should specify string marshalling -->
85 @CA2101@
86 <!-- Rethrow loses stack info -->
87 @CA2200@
88 <!-- Declare static fields when they are declared and remove static constructor -->
89 @CA2207@
90 <!-- Instantiate exception params correctly -->
91 @CA2208@
92 <!-- Dot not call overrideable methods in constructors -->
93 @CA2214@
94 <!-- Replace implicit operator -->
95 @CA2225@
96 <!-- Change 'XXXXX' to be read-only by removing the property setter -->
97 @CA2227@
98
99
100
101 </Rules>
102 <Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
103 <!-- Ignore docs -->
104 @SA0001@
105
106 <!-- 10** Spacing rules -->
107 @SA1000@
108 @SA1001@
109 @SA1002@
110 @SA1003@
111 <!-- Documentation must start with single space -->
112 @SA1004@
113 @SA1005@
114 @SA1006@
115 @SA1007@
116 @SA1008@
117 @SA1009@
118 @SA1010@
119 @SA1011@
120 @SA1012@
121 @SA1013@
122 @SA1014@
123 @SA1015@
124 @SA1016@
125 @SA1017@
126 @SA1018@
127 @SA1019@
128 @SA1020@
129 @SA1021@
130 @SA1022@
131 @SA1023@
132 @SA1024@
133 @SA1025@
134 @SA1026@
135 @SA1027@
136 @SA1028@
137
138 <!-- Readability -->
139 @SA1100@
140 @SA1101@
141 @SA1102@
142 @SA1103@
143 @SA1104@
144 @SA1105@
145 @SA1106@
146 @SA1107@
147 @SA1108@
148 @SA1109@
149 @SA1110@
150 @SA1111@
151 @SA1112@
152 @SA1113@
153 @SA1114@
154 @SA1115@
155 @SA1116@
156 @SA1117@
157 @SA1118@
158 @SA1119@
159 @SA1120@
160 @SA1121@
161 @SA1122@
162 @SA1123@
163 @SA1124@
164 @SA1125@
165 @SA1126@
166 @SA1127@
167 @SA1128@
168 @SA1129@
169 @SA1130@
170 @SA1131@
171 @SA1132@
172 @SA1133@
173 @SA1134@
174 @SA1135@
175 @SA1136@
176 @SA1137@
177 @SA1138@
178 @SA1139@
179
180 <!-- 12** Ordering -->
181 <!-- FIXME Check if this somehow affects docfx output -->
182 @SA1200@
183 @SA1201@
184 @SA1202@
185 @SA1203@
186 @SA1204@
187 @SA1205@
188 @SA1206@
189 @SA1207@
190 @SA1208@
191 @SA1209@
192 @SA1210@
193 @SA1211@
194 @SA1212@
195 @SA1213@
196 @SA1214@
197 @SA1215@
198 @SA1216@
199 @SA1217@
200
201 <!-- 13** Naming Rules -->
202 <!-- Element start with upper case -->
203 @SA1300@
204 @SA1301@
205 <!-- Interface start with I -->
206 @SA1302@
207 <!-- Upper/lower score rules -->
208 @SA1303@
209 @SA1304@
210 @SA1305@
211 @SA1306@
212 @SA1307@
213 <!-- Variable field prefixes -->
214 @SA1308@
215 @SA1309@
216 @SA1310@
217 @SA1311@
218 @SA1312@
219 @SA1313@
220 @SA1314@
221
222 <!-- 14** Maintainability -->
223 <!-- Access modifier -->
224 @SA1400@
225 <!-- Field must be private -->
226 @SA1401@
227 <!-- File Must contain single class or namespace -->
228 @SA1402@
229 @SA1403@
230 <!-- CodeAnalysis suppress does not have justification -->
231 @SA1404@
232 <!-- Debug.Assert/Fail must provide a message -->
233 @SA1405@
234 @SA1406@
235 <!-- Arithmetic/Conditional expression must declare precedence -->
236 @SA1407@
237 @SA1408@
238 <!-- Remove unecessary code -->
239 @SA1409@
240 <!-- Delegate/Attribute parentheses -->
241 @SA1410@
242 @SA1411@
243 <!-- Utf8 file -->
244 @SA1412@
245 <!-- Trailing commas multiline initializer -->
246 @SA1413@
247
248 <!-- 15** Layout Rules -->
249 @SA1500@
250 @SA1501@
251 @SA1502@
252 @SA1503@
253 @SA1504@
254 @SA1505@
255 @SA1506@
256 @SA1507@
257 @SA1508@
258 @SA1509@
259 @SA1510@
260 @SA1511@
261 @SA1512@
262 @SA1513@
263 @SA1514@
264 @SA1515@
265 @SA1516@
266 @SA1517@
267 @SA1518@
268 @SA1519@
269 @SA1520@
270
271 <!-- 16** Documentation rules -->
272 <!-- Things must be documented -->
273 @SA1600@
274 @SA1601@
275 @SA1602@
276 <!-- Valid xml in docs -->
277 @SA1603@
278 @SA1604@
279 @SA1605@
280 @SA1606@
281 @SA1607@
282 @SA1608@
283 @SA1609@
284 @SA1610@
285 @SA1611@
286 @SA1612@
287 @SA1613@
288 @SA1614@
289 @SA1615@
290 @SA1616@
291 @SA1617@
292 @SA1618@
293 @SA1619@
294 @SA1620@
295 @SA1621@
296 @SA1622@
297 @SA1623@
298 @SA1624@
299 @SA1625@
300 @SA1626@
301 @SA1627@
302 @SA1628@
303 @SA1629@
304 @SA1630@
305 @SA1631@
306 @SA1632@
307 <!-- File headers -->
308 @SA1633@
309 @SA1634@
310 @SA1635@
311 @SA1636@
312 @SA1637@
313 @SA1638@
314 @SA1639@
315 @SA1640@
316 @SA1641@
317 <!-- Constructor/Destructor -->
318 @SA1642@
319 @SA1643@
320 <!-- File header -->
321 @SA1644@
322 <!-- Miscellaneous doc -->
323 @SA1645@
324 @SA1646@
325 @SA1647@
326 @SA1648@
327 <!-- Filename must match file type -->
328 @SA1649@
329 <!-- Spelling -->
330 @SA1650@
331 <!-- Placeholder -->
332 @SA1651@
333 </Rules>
334</RuleSet>
diff --git a/src/bindings/mono/efl_sharp.csproj.in b/src/bindings/mono/efl_sharp.csproj.in
index ce6a9e463c..e03be33950 100644
--- a/src/bindings/mono/efl_sharp.csproj.in
+++ b/src/bindings/mono/efl_sharp.csproj.in
@@ -12,11 +12,6 @@
12 <PackageLicenseExpression>Apache-2.0</PackageLicenseExpression> 12 <PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
13 </PropertyGroup> 13 </PropertyGroup>
14 14
15 <PropertyGroup>
16 <DocumentationFile>$(AssemblyName).xml</DocumentationFile>
17 <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
18 </PropertyGroup>
19
20 <!-- <PropertyGroup Condition="'$(BuildType)'=='Beta'"> --> 15 <!-- <PropertyGroup Condition="'$(BuildType)'=='Beta'"> -->
21 <!-- <DefineConstants>EFL_BETA</DefineConstants> --> 16 <!-- <DefineConstants>EFL_BETA</DefineConstants> -->
22 <!-- </PropertyGroup> --> 17 <!-- </PropertyGroup> -->
@@ -41,4 +36,13 @@
41 <Compile Include="./*.cs" /> 36 <Compile Include="./*.cs" />
42 </ItemGroup> 37 </ItemGroup>
43 38
39 <!-- Code style configuration -->
40 <ItemGroup>
41 <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.6" />
42 <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
43 </ItemGroup>
44 <PropertyGroup>
45 <CodeAnalysisRuleSet>@CA_RULESET@</CodeAnalysisRuleSet>
46 </PropertyGroup>
47
44</Project> 48</Project>
diff --git a/src/bindings/mono/meson.build b/src/bindings/mono/meson.build
index f98aa5eeae..ed2f58d508 100644
--- a/src/bindings/mono/meson.build
+++ b/src/bindings/mono/meson.build
@@ -124,8 +124,9 @@ efl_mono_conf_data.set('ELDBUS', eldbus_lib.full_path())
124efl_mono_conf_data.set('ELEMENTARY', elementary_lib.full_path()) 124efl_mono_conf_data.set('ELEMENTARY', elementary_lib.full_path())
125 125
126efl_mono_dll_config = configure_file(input : 'efl_mono.dll.config.in', 126efl_mono_dll_config = configure_file(input : 'efl_mono.dll.config.in',
127 output : 'efl_mono.dll.config', 127 output : 'efl_mono.dll.config',
128 configuration : efl_mono_conf_data) 128 configuration : efl_mono_conf_data)
129
129 130
130extra_cs_args = runtime_assemblies 131extra_cs_args = runtime_assemblies
131 132
@@ -137,8 +138,69 @@ efl_mono_install_dir = join_paths(dir_lib, 'efl-mono-'+version_major)
137efl_mono_xml_doc = join_paths(meson.current_build_dir(), 'efl_mono.xml') 138efl_mono_xml_doc = join_paths(meson.current_build_dir(), 'efl_mono.xml')
138 139
139if (get_option('dotnet')) 140if (get_option('dotnet'))
141 styles = ['CA1000', 'CA1030', 'CA1031', 'CA1032', 'CA1034', 'CA1036', 'CA1040',
142 'CA1043', 'CA1044', 'CA1051', 'CA1052', 'CA1062', 'CA1063', 'CA1064',
143 'CA1065', 'CA1303', 'CA1305', 'CA1307', 'CA1401', 'CA1507', 'CA1707',
144 'CA1710', 'CA1715', 'CA1716', 'CA1717', 'CA1720', 'CA1721', 'CA1724',
145 'CA1801', 'CA1806', 'CA1810', 'CA1812', 'CA1815', 'CA1816', 'CA1822',
146 'CA1825', 'CA1827', 'CA1829', 'CA2000', 'CA2007', 'CA2101', 'CA2200',
147 'CA2207', 'CA2208', 'CA2214', 'CA2225', 'CA2227', 'SA0001', 'SA1000',
148 'SA1001', 'SA1002', 'SA1003', 'SA1004', 'SA1005',
149 'SA1006', 'SA1007', 'SA1008', 'SA1009', 'SA1010', 'SA1011', 'SA1012',
150 'SA1013', 'SA1014', 'SA1015', 'SA1016', 'SA1017', 'SA1018', 'SA1019',
151 'SA1020', 'SA1021', 'SA1022', 'SA1023', 'SA1024', 'SA1025', 'SA1026',
152 'SA1027', 'SA1028', 'SA1100', 'SA1101', 'SA1102', 'SA1103', 'SA1104',
153 'SA1105', 'SA1106', 'SA1107', 'SA1108', 'SA1109', 'SA1110', 'SA1111',
154 'SA1112', 'SA1113', 'SA1114', 'SA1115', 'SA1116', 'SA1117', 'SA1118',
155 'SA1119', 'SA1120', 'SA1121', 'SA1122', 'SA1123', 'SA1124', 'SA1125',
156 'SA1126', 'SA1127', 'SA1128', 'SA1129', 'SA1130', 'SA1131', 'SA1132',
157 'SA1133', 'SA1134', 'SA1135', 'SA1136', 'SA1137', 'SA1138', 'SA1139',
158 'SA1200', 'SA1201', 'SA1202', 'SA1203', 'SA1204', 'SA1205', 'SA1206',
159 'SA1207', 'SA1208', 'SA1209', 'SA1210', 'SA1211', 'SA1212', 'SA1213',
160 'SA1214', 'SA1215', 'SA1216', 'SA1217', 'SA1300', 'SA1301', 'SA1302',
161 'SA1303', 'SA1304', 'SA1305', 'SA1306', 'SA1307', 'SA1308', 'SA1309',
162 'SA1310', 'SA1311', 'SA1312', 'SA1313', 'SA1314', 'SA1400', 'SA1401',
163 'SA1402', 'SA1403', 'SA1404', 'SA1405', 'SA1406', 'SA1407', 'SA1408',
164 'SA1409', 'SA1410', 'SA1411', 'SA1412', 'SA1413', 'SA1500', 'SA1501',
165 'SA1502', 'SA1503', 'SA1504', 'SA1505', 'SA1506', 'SA1507', 'SA1508',
166 'SA1509', 'SA1510', 'SA1511', 'SA1512', 'SA1513', 'SA1514', 'SA1515',
167 'SA1516', 'SA1517', 'SA1518', 'SA1519', 'SA1520', 'SA1600', 'SA1601',
168 'SA1602', 'SA1603', 'SA1604', 'SA1605', 'SA1606', 'SA1607', 'SA1608',
169 'SA1609', 'SA1610', 'SA1611', 'SA1612', 'SA1613', 'SA1614', 'SA1615',
170 'SA1616', 'SA1617', 'SA1618', 'SA1619', 'SA1620', 'SA1621', 'SA1622',
171 'SA1623', 'SA1624', 'SA1625', 'SA1626', 'SA1627', 'SA1628', 'SA1629',
172 'SA1630', 'SA1631', 'SA1632', 'SA1633', 'SA1634', 'SA1635', 'SA1636',
173 'SA1637', 'SA1638', 'SA1639', 'SA1640', 'SA1641', 'SA1642', 'SA1643',
174 'SA1644', 'SA1645', 'SA1646', 'SA1647', 'SA1648', 'SA1649', 'SA1650',
175 'SA1651']
176
177 efl_stylecop_data = configuration_data()
178 watched_styles = []
179 severity_styles = get_option('dotnet-stylecop-severity')
180 if get_option('dotnet-stylecop') == '*'
181 watched_styles = styles
182 elif get_option('dotnet-stylecop') != ''
183 s = get_option('dotnet-stylecop').to_upper().split(',')
184 foreach cc : s
185 if cc.startswith('CA') or cc.startswith('SA')
186 watched_styles += cc
187 endif
188 endforeach
189 endif
190
191 foreach s : styles
192 if s in watched_styles
193 efl_stylecop_data.set('@0@'.format(s), '<Rule Id="@0@" Action="@1@"/>'.format(s, severity_styles))
194 else
195 efl_stylecop_data.set('@0@'.format(s), '<Rule Id="@0@" Action="None"/>'.format(s))
196 endif
197 endforeach
198
199 ca_ruleset = configure_file(input : 'ca.ruleset.in',
200 output : 'ca.ruleset',
201 configuration : efl_stylecop_data)
202
140 dotnet = find_program('dotnet') 203 dotnet = find_program('dotnet')
141 warning('Dotnet support is still experimental.')
142 204
143 lib_csproj_conf_data = configuration_data() 205 lib_csproj_conf_data = configuration_data()
144 206
@@ -160,6 +222,7 @@ if (get_option('dotnet'))
160 222
161 lib_csproj_conf_data.set('NETSTANDARD_VERSION', dotnet_standard_version) 223 lib_csproj_conf_data.set('NETSTANDARD_VERSION', dotnet_standard_version)
162 lib_csproj_conf_data.set('BINDING_SRC', meson.current_source_dir()) 224 lib_csproj_conf_data.set('BINDING_SRC', meson.current_source_dir())
225 lib_csproj_conf_data.set('CA_RULESET', join_paths(meson.build_root(), '@0@'.format(ca_ruleset)))
163 lib_csproj_conf_data.set('EFL_VERSION', meson.project_version()) 226 lib_csproj_conf_data.set('EFL_VERSION', meson.project_version())
164 227
165 if get_option('mono-beta') 228 if get_option('mono-beta')
@@ -173,7 +236,7 @@ if (get_option('dotnet'))
173 configuration: lib_csproj_conf_data) 236 configuration: lib_csproj_conf_data)
174 237
175 efl_mono = custom_target('efl_mono', 238 efl_mono = custom_target('efl_mono',
176 input: mono_generator_target + mono_files + [efl_src] + [lib_csproj], 239 input: mono_generator_target + mono_files + [efl_src] + [lib_csproj] + [ca_ruleset],
177 output: 'efl_sharp.dll', 240 output: 'efl_sharp.dll',
178 build_by_default: true, 241 build_by_default: true,
179 command: [dotnet, 242 command: [dotnet,