Merge lp:~mandel/wadlsharp/fix_names into lp:~manishsinha/wadlsharp/trunk
- fix_names
- Merge into trunk
Status: | Rejected | ||||
---|---|---|---|---|---|
Rejected by: | Manish Sinha (मनीष सिन्हा) | ||||
Proposed branch: | lp:~mandel/wadlsharp/fix_names | ||||
Merge into: | lp:~manishsinha/wadlsharp/trunk | ||||
Prerequisite: | lp:~mandel/wadlsharp/add_command_line | ||||
Diff against target: |
636 lines (+289/-47) 10 files modified
LpNet.WadlSharp.Common/Generator/LpClass.cs (+45/-12) LpNet.WadlSharp.Common/Generator/LpMethod.cs (+47/-13) LpNet.WadlSharp.Common/Generator/LpNamespace.cs (+32/-2) LpNet.WadlSharp.Common/Generator/LpProperty.cs (+28/-2) LpNet.WadlSharp.Common/Generator/LpReturn.cs (+33/-6) LpNet.WadlSharp.Common/Utils.cs (+42/-4) LpNet.WadlSharp.Common/WadlConverter.cs (+32/-1) WadlConsole/Program.cs (+16/-5) WadlConsole/Resources.Designer.cs (+10/-1) WadlConsole/Resources.resx (+4/-1) |
||||
To merge this branch: | bzr merge lp:~mandel/wadlsharp/fix_names | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Manish Sinha (मनीष सिन्हा) | Disapprove | ||
Review via email: mp+35843@code.launchpad.net |
Commit message
Description of the change
Allows users to provide a command line parameter that will allow to fix the casing of the code by using PAscalCase notation. Other notations can be added to the code.
Manish Sinha (मनीष सिन्हा) (manishsinha) wrote : | # |
Manish Sinha (मनीष सिन्हा) (manishsinha) wrote : | # |
Manual, can you try to merge this branch with trunk which is at r30 ATM. If it works, then please merge it yourself. Reviewing this merge request will take just too much of my time.
Manuel de la Peña (mandel) wrote : | # |
Ok, no worries, I'll take care of it.
Manish Sinha (मनीष सिन्हा) (manishsinha) wrote : | # |
Wait. This branch has been asked to merge in the wrong branch. It should be requested to merge in lp:wadlsharp and not lp:~manishsinha/wadlsharp/trunk
The correct merge request is at
https:/
Manual, please try to merge it in lp:wadlsharp yourself because of the reason I told in the above comment. I am Disapproving this merge request as it asked to merge in the wrong branch.
Manuel de la Peña (mandel) wrote : | # |
Cool, agree! it should not be merged to your personal branch but the teams one. I'll make sure everything is done in the correct branch.
Unmerged revisions
- 30. By Manuel de la Peña
-
Fixed issue with not using the identify generator for the results.
- 29. By Manuel de la Peña
-
Modified the code to allow the users to fix the casing of the generated code to follow naming conventions.
- 28. By Manuel de la Peña
-
Added implementation of console application that will allow user to automate the code generation.
- 27. By Manuel de la Peña
-
Ignore resharper user config.
- 26. By Manuel de la Peña
-
Added lib dependencies so that the contributors have no ref errors.
Preview Diff
1 | === modified file 'LpNet.WadlSharp.Common/Generator/LpClass.cs' |
2 | --- LpNet.WadlSharp.Common/Generator/LpClass.cs 2010-05-02 07:16:04 +0000 |
3 | +++ LpNet.WadlSharp.Common/Generator/LpClass.cs 2010-09-17 16:11:21 +0000 |
4 | @@ -26,6 +26,8 @@ |
5 | ********************************************************************/ |
6 | |
7 | |
8 | +using System; |
9 | + |
10 | namespace LpNet.WadlSharp.Common.Generator |
11 | { |
12 | using System.CodeDom; |
13 | @@ -36,6 +38,36 @@ |
14 | |
15 | public class LpClass : IClass |
16 | { |
17 | + #region Variables |
18 | + |
19 | + private readonly Func<string, string> _createIdentifier; |
20 | + |
21 | + #endregion |
22 | + |
23 | + #region Constructors |
24 | + |
25 | + /// <summary> |
26 | + /// Creates a new instance of the class that will be use the |
27 | + /// basic identifier generator. |
28 | + /// </summary> |
29 | + public LpClass() |
30 | + : this(WadlSharpUtils.CreateIdentifier) |
31 | + { |
32 | + |
33 | + } |
34 | + |
35 | + /// <summary> |
36 | + /// Creates a new instance of the class with the given identifier generator. |
37 | + /// </summary> |
38 | + /// <param name="createIdentifier">The generator that will create |
39 | + /// the identifiers used in the generated class.</param> |
40 | + public LpClass(Func<string, string> createIdentifier) |
41 | + { |
42 | + _createIdentifier = createIdentifier; |
43 | + } |
44 | + |
45 | + #endregion |
46 | + |
47 | #region IClass Members |
48 | |
49 | /// <summary> |
50 | @@ -47,12 +79,13 @@ |
51 | /// <returns>Instance of CodeTypeDeclaration</returns> |
52 | public CodeTypeDeclaration Create(representation_type repType, HashSet<string> nameSpaces, CodeNamespace ns) |
53 | { |
54 | - CodeTypeDeclaration cdDec= new CodeTypeDeclaration(); |
55 | - |
56 | - cdDec.Name = WadlSharpUtils.CreateIdentifier(repType.id); |
57 | - cdDec.IsClass = true; |
58 | - cdDec.Attributes = MemberAttributes.Public | MemberAttributes.Static; |
59 | - cdDec.IsPartial = true; |
60 | + CodeTypeDeclaration cdDec= new CodeTypeDeclaration |
61 | + { |
62 | + Name = _createIdentifier(repType.id), |
63 | + IsClass = true, |
64 | + Attributes = MemberAttributes.Public | MemberAttributes.Static, |
65 | + IsPartial = true |
66 | + }; |
67 | |
68 | #region Namespaces Import |
69 | |
70 | @@ -85,12 +118,12 @@ |
71 | if (param.option != null) |
72 | { |
73 | paramName = string.Format("{0}_{1}", cdDec.Name, |
74 | - WadlSharpUtils.CreateIdentifier(param.name)); |
75 | + _createIdentifier(param.name)); |
76 | |
77 | CodeTypeMember existingEnum = LpMethod.CheckEnumExists(ns, param, paramName); |
78 | if (existingEnum == null) |
79 | { |
80 | - string enumName = WadlSharpUtils.CreateIdentifier(param.name); |
81 | + string enumName = _createIdentifier(param.name); |
82 | |
83 | IEnum paramEnum = new LpEnum(); |
84 | CodeTypeDeclaration memberEnum = paramEnum.Create(paramName, param.option, nameSpaces); |
85 | @@ -104,7 +137,7 @@ |
86 | |
87 | CodeMemberField field; |
88 | |
89 | - IProperty property = new LpProperty(); |
90 | + IProperty property = new LpProperty(_createIdentifier); |
91 | CodeMemberProperty prop = property.Create(param, out field, nameSpaces, ns, paramName); |
92 | |
93 | propertiesList.Add(prop); |
94 | @@ -139,7 +172,7 @@ |
95 | |
96 | #region The Class Definition and Properties |
97 | |
98 | - typeDeclaration.Name = WadlSharpUtils.CreateIdentifier(resourceType.id); |
99 | + typeDeclaration.Name = _createIdentifier(resourceType.id); |
100 | typeDeclaration.IsClass = true; |
101 | typeDeclaration.Attributes = MemberAttributes.Public | MemberAttributes.Static; |
102 | typeDeclaration.IsPartial = true; |
103 | @@ -177,7 +210,7 @@ |
104 | |
105 | foreach (method method in resourceType.method) |
106 | { |
107 | - IMethod lpmethod = new LpMethod(); |
108 | + IMethod lpmethod = new LpMethod(_createIdentifier); |
109 | CodeMemberMethod memberMethod; |
110 | |
111 | if (method.request != null && method.request.representation != null) |
112 | @@ -206,7 +239,7 @@ |
113 | { |
114 | foreach (param param in resourceType.param) |
115 | { |
116 | - IProperty paramInst = new LpProperty(); |
117 | + IProperty paramInst = new LpProperty(_createIdentifier); |
118 | CodeMemberField field; |
119 | |
120 | CodeMemberProperty prop = paramInst.Create(param, out field, nameSpaces, ns, string.Empty); |
121 | |
122 | === modified file 'LpNet.WadlSharp.Common/Generator/LpMethod.cs' |
123 | --- LpNet.WadlSharp.Common/Generator/LpMethod.cs 2010-05-02 07:16:04 +0000 |
124 | +++ LpNet.WadlSharp.Common/Generator/LpMethod.cs 2010-09-17 16:11:21 +0000 |
125 | @@ -24,26 +24,58 @@ |
126 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
127 | * OTHER DEALINGS IN THE SOFTWARE. |
128 | ********************************************************************/ |
129 | - |
130 | +using System; |
131 | +using System.CodeDom; |
132 | +using System.Collections.Generic; |
133 | +using LpNet.WadlSharp.Common.Enum; |
134 | +using LpNet.WadlSharp.Common.Interface.Generator; |
135 | +using LpNet.WadlSharp.Common.Resources; |
136 | |
137 | namespace LpNet.WadlSharp.Common.Generator |
138 | { |
139 | - using System.CodeDom; |
140 | - using System.Collections.Generic; |
141 | - using Interface.Generator; |
142 | - using Resources; |
143 | - using Enum; |
144 | + |
145 | |
146 | public class LpMethod : IMethod |
147 | { |
148 | + #region Vars |
149 | + |
150 | + private readonly Func<string, string> _createIdentifier; |
151 | + |
152 | + #endregion |
153 | + |
154 | + #region Constructors |
155 | + |
156 | + /// <summary> |
157 | + /// Creates a new instance of the class with the basic identifier generator. |
158 | + /// </summary> |
159 | + public LpMethod() |
160 | + : this(WadlSharpUtils.CreateIdentifier) |
161 | + { |
162 | + |
163 | + } |
164 | + |
165 | + /// <summary> |
166 | + /// Creates a new instance of the class that will use the passed |
167 | + /// identifier generator. |
168 | + /// </summary> |
169 | + /// <param name="createIdentifier">The identifier generator used to create the names of the methods.</param> |
170 | + public LpMethod(Func<string, string> createIdentifier) |
171 | + { |
172 | + _createIdentifier = createIdentifier; |
173 | + } |
174 | + |
175 | + #endregion |
176 | + |
177 | #region Public Methods Exposed by Interface |
178 | |
179 | public CodeMemberMethod Create(method methodInstance, HashSet<string> nameSpaces, CodeNamespace ns, CodeTypeDeclaration typeDeclaration) |
180 | { |
181 | // Create am instance of CodeMemberMethod and set it's name |
182 | - CodeMemberMethod memberMethod = new CodeMemberMethod(); |
183 | - memberMethod.Name = WadlSharpUtils.CreateIdentifier(methodInstance.id); |
184 | - memberMethod.Attributes = MemberAttributes.Public | MemberAttributes.Final; |
185 | + CodeMemberMethod memberMethod = new CodeMemberMethod |
186 | + { |
187 | + Name = _createIdentifier(methodInstance.id), |
188 | + Attributes = MemberAttributes.Public | MemberAttributes.Final |
189 | + }; |
190 | |
191 | typeDeclarationField = typeDeclaration; |
192 | |
193 | @@ -110,9 +142,11 @@ |
194 | if (paramSet != null) |
195 | { |
196 | // Create am instance of CodeMemberMethod and set it's name |
197 | - CodeMemberMethod memberMethod = new CodeMemberMethod(); |
198 | - memberMethod.Name = WadlSharpUtils.CreateIdentifier(methodInstance.id); |
199 | - memberMethod.Attributes = MemberAttributes.Public | MemberAttributes.Final; |
200 | + CodeMemberMethod memberMethod = new CodeMemberMethod |
201 | + { |
202 | + Name = _createIdentifier(methodInstance.id), |
203 | + Attributes = MemberAttributes.Public | MemberAttributes.Final |
204 | + }; |
205 | |
206 | typeDeclarationField = typeDeclaration; |
207 | |
208 | @@ -384,7 +418,7 @@ |
209 | |
210 | if (s.href != null) |
211 | { |
212 | - IReturn ret = new LpReturn(); |
213 | + IReturn ret = new LpReturn(_createIdentifier); |
214 | |
215 | memberMethod.ReturnType.BaseType = ret.Create(s, nameSpaces, ns); |
216 | } |
217 | |
218 | === modified file 'LpNet.WadlSharp.Common/Generator/LpNamespace.cs' |
219 | --- LpNet.WadlSharp.Common/Generator/LpNamespace.cs 2010-05-02 07:16:04 +0000 |
220 | +++ LpNet.WadlSharp.Common/Generator/LpNamespace.cs 2010-09-17 16:11:21 +0000 |
221 | @@ -25,6 +25,7 @@ |
222 | * OTHER DEALINGS IN THE SOFTWARE. |
223 | ********************************************************************/ |
224 | |
225 | +using System; |
226 | using LpNet.WadlSharp.Common.Custom; |
227 | |
228 | namespace LpNet.WadlSharp.Common.Generator |
229 | @@ -36,6 +37,35 @@ |
230 | |
231 | public class LpNamespace : INamespace |
232 | { |
233 | + #region Vars |
234 | + |
235 | + private readonly Func<string, string> _createIdentifier; |
236 | + |
237 | + #endregion |
238 | + |
239 | + #region Constructors |
240 | + |
241 | + /// <summary> |
242 | + /// Creates a new instance of the class with the basic identifier generator. |
243 | + /// </summary> |
244 | + public LpNamespace() |
245 | + : this(WadlSharpUtils.CreateIdentifier) |
246 | + { |
247 | + |
248 | + } |
249 | + |
250 | + /// <summary> |
251 | + /// Creates a new instance of the class that will use the passed |
252 | + /// identifier generator. |
253 | + /// </summary> |
254 | + /// <param name="createIdentifier">The identifier generator used to create the names of the methods.</param> |
255 | + public LpNamespace(Func<string, string> createIdentifier) |
256 | + { |
257 | + _createIdentifier = createIdentifier; |
258 | + } |
259 | + |
260 | + #endregion |
261 | + |
262 | #region INamespace Members |
263 | |
264 | public CodeNamespace Create(application app, string namespaceName) |
265 | @@ -52,7 +82,7 @@ |
266 | { |
267 | representation_type repType = item as representation_type; |
268 | |
269 | - IClass customType = new LpClass(); |
270 | + IClass customType = new LpClass(_createIdentifier); |
271 | CodeTypeDeclaration typeDec = customType.Create(repType, namespaces, ns); |
272 | |
273 | ns.Types.Add(typeDec); |
274 | @@ -61,7 +91,7 @@ |
275 | { |
276 | resource_type resType = item as resource_type; |
277 | |
278 | - IClass customType = new LpClass(); |
279 | + IClass customType = new LpClass(_createIdentifier); |
280 | CodeTypeDeclaration typeDec = customType.Create(resType, namespaces, ns); |
281 | |
282 | ns.Types.Add(typeDec); |
283 | |
284 | === modified file 'LpNet.WadlSharp.Common/Generator/LpProperty.cs' |
285 | --- LpNet.WadlSharp.Common/Generator/LpProperty.cs 2010-05-01 21:19:11 +0000 |
286 | +++ LpNet.WadlSharp.Common/Generator/LpProperty.cs 2010-09-17 16:11:21 +0000 |
287 | @@ -38,6 +38,31 @@ |
288 | |
289 | public class LpProperty : IProperty |
290 | { |
291 | + #region Vars |
292 | + |
293 | + private readonly Func<string, string> _createIdentifier; |
294 | + |
295 | + #endregion |
296 | + |
297 | + /// <summary> |
298 | + /// Creates a new instance of the class with the basic identifier generator. |
299 | + /// </summary> |
300 | + public LpProperty() |
301 | + : this(WadlSharpUtils.CreateIdentifier) |
302 | + { |
303 | + |
304 | + } |
305 | + |
306 | + /// <summary> |
307 | + /// Creates a new instance of the class that will use the passed |
308 | + /// identifier generator. |
309 | + /// </summary> |
310 | + /// <param name="createIdentifier">The identifier generator used to create the names of the methods.</param> |
311 | + public LpProperty(Func<string, string> createIdentifier) |
312 | + { |
313 | + _createIdentifier = createIdentifier; |
314 | + } |
315 | + |
316 | #region IProperty Method |
317 | |
318 | public CodeMemberProperty Create(param propertyInstance, out CodeMemberField memberField, HashSet<string> nameSpaces, CodeNamespace ns, string propertyType) |
319 | @@ -67,7 +92,7 @@ |
320 | |
321 | #endregion |
322 | |
323 | - property.Name = WadlSharpUtils.CreateIdentifier(propertyInstance.name); |
324 | + property.Name = _createIdentifier(propertyInstance.name); |
325 | property.Attributes = MemberAttributes.Public | MemberAttributes.Final; |
326 | property.Type = new CodeTypeReference(dataType); |
327 | |
328 | @@ -80,7 +105,8 @@ |
329 | propertyInstance.link.resource_type))))); |
330 | } |
331 | |
332 | - string fieldName = string.Format("_{0}", property.Name); |
333 | + // always use camelcase for porperties |
334 | + string fieldName = string.Format("_{0}", WadlSharpUtils.CreateCamelCaseIdentifier(propertyInstance.name)); |
335 | property.GetStatements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), fieldName))); |
336 | property.SetStatements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), fieldName), new CodePropertySetValueReferenceExpression())); |
337 | |
338 | |
339 | === modified file 'LpNet.WadlSharp.Common/Generator/LpReturn.cs' |
340 | --- LpNet.WadlSharp.Common/Generator/LpReturn.cs 2010-04-23 13:16:28 +0000 |
341 | +++ LpNet.WadlSharp.Common/Generator/LpReturn.cs 2010-09-17 16:11:21 +0000 |
342 | @@ -26,16 +26,43 @@ |
343 | ********************************************************************/ |
344 | |
345 | |
346 | +using System; |
347 | +using System.Collections.Generic; |
348 | +using System.Data; |
349 | +using LpNet.WadlSharp.Common.Interface.Generator; |
350 | +using LpNet.WadlSharp.Common.Resources; |
351 | +using System.CodeDom; |
352 | + |
353 | namespace LpNet.WadlSharp.Common.Generator |
354 | { |
355 | - using System.Collections.Generic; |
356 | - using System.Data; |
357 | - using Interface.Generator; |
358 | - using Resources; |
359 | - using System.CodeDom; |
360 | + |
361 | |
362 | public class LpReturn : IReturn |
363 | { |
364 | + #region Vars |
365 | + |
366 | + private readonly Func<string, string> _createIdentifier; |
367 | + |
368 | + #endregion |
369 | + |
370 | + /// <summary> |
371 | + /// Creates a new instance of the class with the basic identifier generator. |
372 | + /// </summary> |
373 | + public LpReturn() |
374 | + : this(WadlSharpUtils.CreateIdentifier) |
375 | + { |
376 | + |
377 | + } |
378 | + |
379 | + /// <summary> |
380 | + /// Creates a new instance of the class that will use the passed |
381 | + /// identifier generator. |
382 | + /// </summary> |
383 | + /// <param name="createIdentifier">The identifier generator used to create the names of the methods.</param> |
384 | + public LpReturn(Func<string, string> createIdentifier) |
385 | + { |
386 | + _createIdentifier = createIdentifier; |
387 | + } |
388 | #region IReturn Members |
389 | |
390 | /// <summary> |
391 | @@ -50,7 +77,7 @@ |
392 | if (hashPos != -1) |
393 | { |
394 | string href = repType.href.Substring(hashPos + 1); |
395 | - href = WadlSharpUtils.CreateIdentifier(href); |
396 | + href = _createIdentifier(href); |
397 | |
398 | return href; |
399 | } |
400 | |
401 | === modified file 'LpNet.WadlSharp.Common/Utils.cs' |
402 | --- LpNet.WadlSharp.Common/Utils.cs 2010-05-02 07:16:04 +0000 |
403 | +++ LpNet.WadlSharp.Common/Utils.cs 2010-09-17 16:11:21 +0000 |
404 | @@ -26,12 +26,12 @@ |
405 | ********************************************************************/ |
406 | |
407 | |
408 | - |
409 | +using System.Text; |
410 | +using System.Text.RegularExpressions; |
411 | +using LpNet.WadlSharp.Common.Enum; |
412 | |
413 | namespace LpNet.WadlSharp.Common |
414 | { |
415 | - using System.Text.RegularExpressions; |
416 | - using Enum; |
417 | |
418 | public class WadlSharpUtils |
419 | { |
420 | @@ -49,6 +49,44 @@ |
421 | return filteredString; |
422 | } |
423 | |
424 | + public static string CreateCamelCaseIdentifier(string methodCandidate) |
425 | + { |
426 | + var splittedPhrase = methodCandidate.Split(' ', '-', '.', '_'); |
427 | + var sb = new StringBuilder(); |
428 | + |
429 | + sb.Append(splittedPhrase[0].ToLower()); |
430 | + |
431 | + for (var index = 1; index < splittedPhrase.Length; index++) |
432 | + { |
433 | + var s = splittedPhrase[index]; |
434 | + var splittedPhraseChars = s.ToCharArray(); |
435 | + if (splittedPhraseChars.Length > 0) |
436 | + { |
437 | + splittedPhraseChars[0] = ((new string(splittedPhraseChars[0], 1)).ToUpper().ToCharArray())[0]; |
438 | + } |
439 | + sb.Append(new string(splittedPhraseChars)); |
440 | + } |
441 | + |
442 | + return sb.ToString(); |
443 | + } |
444 | + |
445 | + public static string CreatePascalCaseIdentifier(string methodCandidate) |
446 | + { |
447 | + var splittedCancidate = methodCandidate.Split(' ', '-', '.', '_'); |
448 | + var sb = new StringBuilder(); |
449 | + foreach (var currentNamePart in splittedCancidate) |
450 | + { |
451 | + var splittedPhraseChars = currentNamePart.ToCharArray(); |
452 | + if (splittedPhraseChars.Length > 0) |
453 | + { |
454 | + splittedPhraseChars[0] = ((new string(splittedPhraseChars[0], 1)).ToUpper().ToCharArray())[0]; |
455 | + } |
456 | + sb.Append(new string(splittedPhraseChars)); |
457 | + } |
458 | + |
459 | + return sb.ToString(); |
460 | + } |
461 | + |
462 | public static string FilterComments(string commentString) |
463 | { |
464 | string filteredText = commentString.Replace("\n", ""); |
465 | @@ -83,7 +121,7 @@ |
466 | |
467 | public static HttpMethodType ParseHttpMethod(string methodName) |
468 | { |
469 | - HttpMethodType method = (HttpMethodType)System.Enum.Parse(typeof (HttpMethodType), methodName); |
470 | + HttpMethodType method = (HttpMethodType)System.Enum.Parse(typeof(HttpMethodType), methodName); |
471 | |
472 | return method; |
473 | } |
474 | |
475 | === modified file 'LpNet.WadlSharp.Common/WadlConverter.cs' |
476 | --- LpNet.WadlSharp.Common/WadlConverter.cs 2010-09-17 11:19:00 +0000 |
477 | +++ LpNet.WadlSharp.Common/WadlConverter.cs 2010-09-17 16:11:21 +0000 |
478 | @@ -26,6 +26,8 @@ |
479 | ********************************************************************/ |
480 | |
481 | |
482 | +using System; |
483 | + |
484 | namespace LpNet.WadlSharp.Common |
485 | { |
486 | using Interface; |
487 | @@ -40,6 +42,35 @@ |
488 | |
489 | public class WadlConverter :IConverter |
490 | { |
491 | + #region Vars |
492 | + |
493 | + private readonly Func<string, string> _createIdentifier; |
494 | + |
495 | + #endregion |
496 | + |
497 | + #region Constructors |
498 | + |
499 | + /// <summary> |
500 | + /// Creates a new instance of the class with the basic identifier generator. |
501 | + /// </summary> |
502 | + public WadlConverter() |
503 | + : this(WadlSharpUtils.CreateIdentifier) |
504 | + { |
505 | + |
506 | + } |
507 | + |
508 | + /// <summary> |
509 | + /// Creates a new instance of the class that will use the passed |
510 | + /// identifier generator. |
511 | + /// </summary> |
512 | + /// <param name="createIdentifier">The identifier generator used to create the names of the methods.</param> |
513 | + public WadlConverter(Func<string, string> createIdentifier) |
514 | + { |
515 | + _createIdentifier = createIdentifier; |
516 | + } |
517 | + |
518 | + #endregion |
519 | + |
520 | #region IConverter Members |
521 | |
522 | public void Convert(string inputFileName, string outputFileName, string rootNamespace) |
523 | @@ -60,7 +91,7 @@ |
524 | |
525 | #region Create the Code File's DOM |
526 | |
527 | - INamespace nsp = new LpNamespace(); |
528 | + INamespace nsp = new LpNamespace(_createIdentifier); |
529 | CodeNamespace nameSpace = nsp.Create(app, rootNamespace); |
530 | |
531 | #endregion |
532 | |
533 | === modified file 'WadlConsole/Program.cs' |
534 | --- WadlConsole/Program.cs 2010-09-17 16:11:21 +0000 |
535 | +++ WadlConsole/Program.cs 2010-09-17 16:11:21 +0000 |
536 | @@ -77,9 +77,18 @@ |
537 | /// <param name="outputFileName">The filename of the .cs file. If the file does not exist, |
538 | /// it would be created. If it does exist, it would be truncated and then overwritten.</param> |
539 | /// <param name="rootNamespace">The name of the namespace which you would like the generated code to have.</param> |
540 | - private static void GenerateCode(string inputFileName, string outputFileName, string rootNamespace) |
541 | + /// <param name="fixCase">A flag that states if the case of the generated code should be fixed.</param> |
542 | + private static void GenerateCode(string inputFileName, string outputFileName, string rootNamespace, bool fixCase) |
543 | { |
544 | - var converter = new WadlConverter(); |
545 | + WadlConverter converter; |
546 | + if(fixCase) |
547 | + { |
548 | + converter = new WadlConverter(WadlSharpUtils.CreatePascalCaseIdentifier); |
549 | + } |
550 | + else |
551 | + { |
552 | + converter = new WadlConverter(); |
553 | + } |
554 | converter.Convert(inputFileName, outputFileName, rootNamespace); |
555 | } |
556 | |
557 | @@ -91,14 +100,16 @@ |
558 | var outputFile = ""; |
559 | var rootNamespace = ""; |
560 | var input = ""; |
561 | - var help = false; |
562 | + var help = false; |
563 | + var fixCase = false; |
564 | |
565 | // create the option set that will provide the diff options |
566 | // of the command line |
567 | var options = new OptionSet |
568 | { |
569 | { "i|input=", Resources.InputDescription, v => input = v }, |
570 | - { "u|url", Resources.UrlDescription, v=> isFile = false }, |
571 | + { "u|url", Resources.UrlDescription, v => isFile = false }, |
572 | + { "c|fixCase", Resources.FixCaseDescription, v => fixCase = v != null }, |
573 | { "o|output=", Resources.OutputDescription, v=> outputFile = v }, |
574 | { "n|namespace=", Resources.NamespaceDescription, v=> rootNamespace = v }, |
575 | { "h|?|help", Resources.HelpDescription, v => help = v != null }, |
576 | @@ -143,7 +154,7 @@ |
577 | } |
578 | |
579 | // eveyhthin is ok, therefore we generate the code |
580 | - GenerateCode(input, outputFile, rootNamespace); |
581 | + GenerateCode(input, outputFile, rootNamespace, fixCase); |
582 | Console.WriteLine(Resources.Completed); |
583 | } |
584 | } |
585 | |
586 | === modified file 'WadlConsole/Resources.Designer.cs' |
587 | --- WadlConsole/Resources.Designer.cs 2010-09-17 16:11:21 +0000 |
588 | +++ WadlConsole/Resources.Designer.cs 2010-09-17 16:11:21 +0000 |
589 | @@ -70,6 +70,15 @@ |
590 | } |
591 | |
592 | /// <summary> |
593 | + /// Looks up a localized string similar to A boolean flag stating if the case of the generated code should be fixed.. |
594 | + /// </summary> |
595 | + internal static string FixCaseDescription { |
596 | + get { |
597 | + return ResourceManager.GetString("FixCaseDescription", resourceCulture); |
598 | + } |
599 | + } |
600 | + |
601 | + /// <summary> |
602 | /// Looks up a localized string similar to Usage: wadl-sharp [OPTIONS] |
603 | /// |
604 | ///Generates the C# code required to communicate with a wadl service. |
605 | @@ -109,7 +118,7 @@ |
606 | } |
607 | |
608 | /// <summary> |
609 | - /// Looks up a localized string similar to The fiilename of the .cs file to be generated. If the file does not exist, it would be created. If it does exist, it would be truncated and then overwritten.. |
610 | + /// Looks up a localized string similar to The filename of the .cs file to be generated. If the file does not exist, it would be created. If it does exist, it would be truncated and then overwritten.. |
611 | /// </summary> |
612 | internal static string OutputDescription { |
613 | get { |
614 | |
615 | === modified file 'WadlConsole/Resources.resx' |
616 | --- WadlConsole/Resources.resx 2010-09-17 16:11:21 +0000 |
617 | +++ WadlConsole/Resources.resx 2010-09-17 16:11:21 +0000 |
618 | @@ -120,6 +120,9 @@ |
619 | <data name="Completed" xml:space="preserve"> |
620 | <value>Generation completed.</value> |
621 | </data> |
622 | + <data name="FixCaseDescription" xml:space="preserve"> |
623 | + <value>A boolean flag stating if the case of the generated code should be fixed.</value> |
624 | + </data> |
625 | <data name="Help" xml:space="preserve"> |
626 | <value>Usage: wadl-sharp [OPTIONS] |
627 | |
628 | @@ -136,7 +139,7 @@ |
629 | <value>The name of the namespace which you would like the generated code to have.</value> |
630 | </data> |
631 | <data name="OutputDescription" xml:space="preserve"> |
632 | - <value>The fiilename of the .cs file to be generated. If the file does not exist, it would be created. If it does exist, it would be truncated and then overwritten.</value> |
633 | + <value>The filename of the .cs file to be generated. If the file does not exist, it would be created. If it does exist, it would be truncated and then overwritten.</value> |
634 | </data> |
635 | <data name="TryHelp" xml:space="preserve"> |
636 | <value>Try `wadl-sharp --help' for more information.</value> |
Since this is implemented after implementing WadlConsole and WadlConsole itself is broken, so merging this will make introduce one feature and one defect.
The Fixing of names is really great except that WadlConsole project needs to be fixed first.