Skip to content

Commit ab768b2

Browse files
authored
Run CodeFormatter on SvcUtil (#2495)
* Run CodeFormatter on SvcUtil * Addressed CR Feedback.
1 parent f17f2bb commit ab768b2

File tree

24 files changed

+583
-630
lines changed

24 files changed

+583
-630
lines changed

src/Common/src/System/SR.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// Copyright (c) Microsoft. All rights reserved.
2-
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
34

45
using System.Resources;
56
using System.Runtime.CompilerServices;

src/System.Private.ServiceModel/tests/Scenarios/Contract/XmlSerializer/XmlSerializerFormatTest.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
public static partial class XmlSerializerFormatTests
1414
{
1515
#if SVCUTILTESTS
16-
private static readonly string SerializationModeSetterName = "set_Mode";
16+
private static readonly string s_serializationModeSetterName = "set_Mode";
1717

1818
static XmlSerializerFormatTests()
1919
{
20-
MethodInfo method = typeof(XmlSerializer).GetMethod(SerializationModeSetterName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
21-
Assert.True(method != null, $"No method named {SerializationModeSetterName}");
20+
MethodInfo method = typeof(XmlSerializer).GetMethod(s_serializationModeSetterName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
21+
Assert.True(method != null, $"No method named {s_serializationModeSetterName}");
2222
method.Invoke(null, new object[] { 3 });
2323
}
2424
#endif
@@ -171,7 +171,7 @@ private static void RunVariation(string serviceAddress, bool isMultiNs = false)
171171
if (isMultiNs)
172172
{
173173
Guid guid2 = Guid.NewGuid();
174-
serviceProxy2.AddString(guid2, testStr);
174+
serviceProxy2.AddString(guid2, testStr);
175175
Assert.Equal(testStr, serviceProxy2.GetAndRemoveString(guid2));
176176
}
177177
}
@@ -187,6 +187,6 @@ private static void RunVariation(string serviceAddress, bool isMultiNs = false)
187187
{
188188
ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy2);
189189
}
190-
}
191-
}
190+
}
191+
}
192192
}

src/svcutilcore/src/Microsoft/Tools/ServiceModel/SvcUtil/CommandLineParser.cs

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
//-----------------------------------------------------------------------------
2-
// Copyright (c) Microsoft Corporation. All rights reserved.
3-
//-----------------------------------------------------------------------------
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
45
namespace Microsoft.Tools.ServiceModel.SvcUtil
56
{
67
using System;
@@ -18,29 +19,29 @@ internal enum SwitchType
1819

1920
internal class CommandSwitch
2021
{
21-
readonly string name;
22-
readonly string abbreviation;
23-
readonly SwitchType switchType;
22+
private readonly string _name;
23+
private readonly string _abbreviation;
24+
private readonly SwitchType _switchType;
2425

2526
internal CommandSwitch(string name, string abbreviation, SwitchType switchType)
2627
{
2728
//ensure that either name doesn't start with '/' or '-'
2829
//also convert to lower-case
2930
if ((name[0] == '/') || (name[0] == '-'))
30-
this.name = (name.Substring(1)).ToLower(CultureInfo.InvariantCulture);
31+
_name = (name.Substring(1)).ToLower(CultureInfo.InvariantCulture);
3132
else
32-
this.name = name.ToLower(CultureInfo.InvariantCulture);
33+
_name = name.ToLower(CultureInfo.InvariantCulture);
3334
if ((abbreviation[0] == '/') || (abbreviation[0] == '-'))
34-
this.abbreviation = (abbreviation.Substring(1)).ToLower(CultureInfo.InvariantCulture);
35+
_abbreviation = (abbreviation.Substring(1)).ToLower(CultureInfo.InvariantCulture);
3536
else
36-
this.abbreviation = abbreviation.ToLower(CultureInfo.InvariantCulture);
37+
_abbreviation = abbreviation.ToLower(CultureInfo.InvariantCulture);
3738

38-
this.switchType = switchType;
39+
_switchType = switchType;
3940
}
4041

4142
internal string Name
4243
{
43-
get { return name; }
44+
get { return _name; }
4445
}
4546

4647
#if NotUsed
@@ -52,7 +53,7 @@ internal string Abbreviation
5253

5354
internal SwitchType SwitchType
5455
{
55-
get { return switchType; }
56+
get { return _switchType; }
5657
}
5758

5859
internal bool Equals(string other)
@@ -67,10 +68,10 @@ internal bool Equals(string other)
6768
temp = other.ToLower(CultureInfo.InvariantCulture);
6869

6970
//if equal to name, then return the OK
70-
if (name.Equals(temp))
71+
if (_name.Equals(temp))
7172
return true;
7273
//now check abbreviation
73-
return abbreviation.Equals(temp);
74+
return _abbreviation.Equals(temp);
7475
}
7576

7677
internal static CommandSwitch FindSwitch(string name, CommandSwitch[] switches)
@@ -85,11 +86,11 @@ internal static CommandSwitch FindSwitch(string name, CommandSwitch[] switches)
8586

8687
internal class ArgumentDictionary
8788
{
88-
Dictionary<string, IList<string>> contents;
89+
private Dictionary<string, IList<string>> _contents;
8990

9091
internal ArgumentDictionary(int capacity)
9192
{
92-
contents = new Dictionary<string, IList<string>>(capacity);
93+
_contents = new Dictionary<string, IList<string>>(capacity);
9394
}
9495

9596
internal void Add(string key, string value)
@@ -109,7 +110,7 @@ internal void Add(string key, string value)
109110
internal string GetArgument(string key)
110111
{
111112
IList<string> values;
112-
if (contents.TryGetValue(key.ToLower(CultureInfo.InvariantCulture), out values))
113+
if (_contents.TryGetValue(key.ToLower(CultureInfo.InvariantCulture), out values))
113114
{
114115
#if SM_TOOL
115116
Tool.Assert((values.Count == 1), "contains more than one argument please call GetArguments");
@@ -126,32 +127,29 @@ internal string GetArgument(string key)
126127
internal IList<string> GetArguments(string key)
127128
{
128129
IList<string> result;
129-
if (!contents.TryGetValue(key.ToLower(CultureInfo.InvariantCulture), out result))
130+
if (!_contents.TryGetValue(key.ToLower(CultureInfo.InvariantCulture), out result))
130131
result = new List<string>();
131132
return result;
132133
}
133134

134135
internal bool ContainsArgument(string key)
135136
{
136-
return contents.ContainsKey(key.ToLower(CultureInfo.InvariantCulture));
137+
return _contents.ContainsKey(key.ToLower(CultureInfo.InvariantCulture));
137138
}
138139

139140
internal void Add(string key, IList<string> values)
140141
{
141-
contents.Add(key.ToLower(CultureInfo.InvariantCulture), values);
142+
_contents.Add(key.ToLower(CultureInfo.InvariantCulture), values);
142143
}
143144

144145
internal int Count
145146
{
146-
get { return contents.Count; }
147+
get { return _contents.Count; }
147148
}
148-
149149
}
150150

151151
internal static class CommandParser
152152
{
153-
154-
155153
internal static ArgumentDictionary ParseCommand(string[] cmd, CommandSwitch[] switches)
156154
{
157155
ArgumentDictionary arguments; //switches/values from cmd line
@@ -242,7 +240,5 @@ internal static ArgumentDictionary ParseCommand(string[] cmd, CommandSwitch[] sw
242240

243241
return arguments;
244242
}
245-
246243
}
247-
248244
}

src/svcutilcore/src/Microsoft/Tools/ServiceModel/SvcUtil/ExportModule.cs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
//-----------------------------------------------------------------------------
2-
// Copyright (c) Microsoft Corporation. All rights reserved.
3-
//-----------------------------------------------------------------------------
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
45
namespace Microsoft.Tools.ServiceModel.SvcUtil
56
{
67
using System;
@@ -15,43 +16,43 @@ namespace Microsoft.Tools.ServiceModel.SvcUtil
1516
using System.Collections.ObjectModel;
1617
using DcNS = System.Runtime.Serialization;
1718

18-
class ExportModule
19+
internal class ExportModule
1920
{
20-
readonly DcNS.XsdDataContractExporter dcExporter;
21-
readonly bool dcOnlyMode;
22-
readonly string serviceName;
23-
readonly IsTypeExcludedDelegate isTypeExcluded;
24-
readonly TypeResolver typeResolver;
25-
21+
private readonly DcNS.XsdDataContractExporter _dcExporter;
22+
private readonly bool _dcOnlyMode;
23+
private readonly string _serviceName;
24+
private readonly IsTypeExcludedDelegate _isTypeExcluded;
25+
private readonly TypeResolver _typeResolver;
26+
2627
internal delegate bool IsTypeExcludedDelegate(Type t);
2728
internal delegate void TypeLoadErrorEventHandler(Type type, string errorMessage);
2829
internal delegate void ServiceResolutionErrorEventHandler(string configName, string errorMessage);
2930
internal delegate void ConfigLoadErrorEventHandler(string fileName, string errorMessage);
3031

3132
internal class ContractLoader
3233
{
33-
readonly List<Type> types = new List<Type>();
34-
readonly IsTypeExcludedDelegate isTypeExcluded;
35-
TypeLoadErrorEventHandler contractLoadErrorCallback;
34+
private readonly List<Type> _types = new List<Type>();
35+
private readonly IsTypeExcludedDelegate _isTypeExcluded;
36+
private TypeLoadErrorEventHandler _contractLoadErrorCallback;
3637

3738
internal ContractLoader(IEnumerable<Assembly> assemblies, IsTypeExcludedDelegate isTypeExcluded)
3839
{
39-
this.isTypeExcluded = isTypeExcluded;
40+
_isTypeExcluded = isTypeExcluded;
4041
foreach (Assembly assembly in assemblies)
41-
types.AddRange(InputModule.LoadTypes(assembly));
42+
_types.AddRange(InputModule.LoadTypes(assembly));
4243
}
4344

4445
internal TypeLoadErrorEventHandler ContractLoadErrorCallback
4546
{
46-
get { return contractLoadErrorCallback; }
47-
set { contractLoadErrorCallback = value; }
47+
get { return _contractLoadErrorCallback; }
48+
set { _contractLoadErrorCallback = value; }
4849
}
4950

5051
internal IEnumerable<ContractDescription> GetContracts()
5152
{
52-
foreach (Type type in this.types)
53+
foreach (Type type in _types)
5354
{
54-
if (!isTypeExcluded(type) && IsContractType(type))
55+
if (!_isTypeExcluded(type) && IsContractType(type))
5556
{
5657
ContractDescription contract = LoadContract(type);
5758
if (contract != null)
@@ -60,7 +61,7 @@ internal IEnumerable<ContractDescription> GetContracts()
6061
}
6162
}
6263

63-
ContractDescription LoadContract(Type type)
64+
private ContractDescription LoadContract(Type type)
6465
{
6566
try
6667
{
@@ -73,14 +74,14 @@ ContractDescription LoadContract(Type type)
7374
if (Tool.IsFatal(e))
7475
throw;
7576

76-
if (this.contractLoadErrorCallback != null)
77-
this.contractLoadErrorCallback(type, e.Message);
77+
if (_contractLoadErrorCallback != null)
78+
_contractLoadErrorCallback(type, e.Message);
7879

7980
return null;
8081
}
8182
}
8283

83-
static bool IsContractType(Type type)
84+
private static bool IsContractType(Type type)
8485
{
8586
return (type.IsInterface || type.IsClass) && (type.IsDefined(typeof(ServiceContractAttribute), false));
8687
}

0 commit comments

Comments
 (0)