Skip to content

Commit 3d6305e

Browse files
committed
Column.cs: Coding style - resolve most R# warnings.
1 parent f4ef8b5 commit 3d6305e

File tree

2 files changed

+82
-82
lines changed

2 files changed

+82
-82
lines changed

src/NHibernate/Mapping/Column.cs

Lines changed: 80 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ public class Column : ISelectable, ICloneable
1717
public const int DefaultPrecision = 19;
1818
public const int DefaultScale = 2;
1919

20-
private int? length;
21-
private int? precision;
22-
private int? scale;
20+
private int? _length;
21+
private int? _precision;
22+
private int? _scale;
2323
private IValue _value;
24-
private int typeIndex = 0;
25-
private string name;
26-
private bool nullable = true;
27-
private bool unique = false;
28-
private string sqlType;
29-
private SqlType sqlTypeCode;
30-
private bool quoted = false;
31-
internal int uniqueInteger;
32-
private string checkConstraint;
33-
private string comment;
34-
private string defaultValue;
24+
private int _typeIndex;
25+
private string _name;
26+
private bool _nullable = true;
27+
private bool _unique;
28+
private string _sqlType;
29+
private SqlType _sqlTypeCode;
30+
private bool _quoted;
31+
internal int UniqueInteger;
32+
private string _checkConstraint;
33+
private string _comment;
34+
private string _defaultValue;
3535

3636
/// <summary>
3737
/// Initializes a new instance of <see cref="Column"/>.
@@ -55,8 +55,8 @@ public Column(string columnName)
5555
/// <value>The length of the datatype in the database.</value>
5656
public int Length
5757
{
58-
get { return length.GetValueOrDefault(DefaultLength); }
59-
set { length = value; }
58+
get { return _length.GetValueOrDefault(DefaultLength); }
59+
set { _length = value; }
6060
}
6161

6262
/// <summary>
@@ -79,24 +79,24 @@ public int Length
7979
/// </remarks>
8080
public string Name
8181
{
82-
get { return name; }
82+
get { return _name; }
8383
set
8484
{
8585
if (value[0] == '`')
8686
{
87-
quoted = true;
88-
name = value.Substring(1, value.Length - 2);
87+
_quoted = true;
88+
_name = value.Substring(1, value.Length - 2);
8989
}
9090
else
9191
{
92-
name = value;
92+
_name = value;
9393
}
9494
}
9595
}
9696

9797
public string CanonicalName
9898
{
99-
get { return quoted ? name : name.ToLowerInvariant(); }
99+
get { return _quoted ? _name : _name.ToLowerInvariant(); }
100100
}
101101

102102
/// <summary>
@@ -112,7 +112,7 @@ public string CanonicalName
112112
/// </returns>
113113
public string GetQuotedName(Dialect.Dialect d)
114114
{
115-
return IsQuoted ? d.QuoteForColumnName(name) : name;
115+
return IsQuoted ? d.QuoteForColumnName(_name) : _name;
116116
}
117117

118118
/**
@@ -123,32 +123,32 @@ public string GetQuotedName(Dialect.Dialect d)
123123

124124
public string GetAlias(Dialect.Dialect dialect)
125125
{
126-
string alias = name;
127-
string _unique = uniqueInteger.ToString() + '_';
128-
int lastLetter = StringHelper.LastIndexOfLetter(name);
126+
string alias = _name;
127+
string suffix = UniqueInteger.ToString() + '_';
128+
int lastLetter = StringHelper.LastIndexOfLetter(_name);
129129
if (lastLetter == -1)
130130
{
131131
alias = "column";
132132
}
133-
else if (lastLetter < name.Length - 1)
133+
else if (lastLetter < _name.Length - 1)
134134
{
135-
alias = name.Substring(0, lastLetter + 1);
135+
alias = _name.Substring(0, lastLetter + 1);
136136
}
137137
if (alias.Length > dialect.MaxAliasLength)
138138
{
139-
alias = alias.Substring(0, dialect.MaxAliasLength - _unique.Length);
139+
alias = alias.Substring(0, dialect.MaxAliasLength - suffix.Length);
140140
}
141-
bool useRawName = name.Equals(alias) &&
142-
!quoted &&
143-
!StringHelper.EqualsCaseInsensitive(name, "rowid");
141+
bool useRawName = _name.Equals(alias) &&
142+
!_quoted &&
143+
!StringHelper.EqualsCaseInsensitive(_name, "rowid");
144144

145145
if (useRawName)
146146
{
147147
return alias;
148148
}
149149
else
150150
{
151-
return alias + _unique;
151+
return alias + suffix;
152152
}
153153
}
154154

@@ -164,8 +164,8 @@ public string GetAlias(Dialect.Dialect dialect, Table table)
164164
/// <value><see langword="true" /> if the column can have a null value in it.</value>
165165
public bool IsNullable
166166
{
167-
get { return nullable; }
168-
set { nullable = value; }
167+
get { return _nullable; }
168+
set { _nullable = value; }
169169
}
170170

171171
/// <summary>
@@ -176,8 +176,8 @@ public bool IsNullable
176176
/// </value>
177177
public int TypeIndex
178178
{
179-
get { return typeIndex; }
180-
set { typeIndex = value; }
179+
get { return _typeIndex; }
180+
set { _typeIndex = value; }
181181
}
182182

183183
/// <summary>
@@ -186,8 +186,8 @@ public int TypeIndex
186186
/// <value><see langword="true" /> if the column contains unique values.</value>
187187
public bool IsUnique
188188
{
189-
get { return unique; }
190-
set { unique = value; }
189+
get { return _unique; }
190+
set { _unique = value; }
191191
}
192192

193193
/// <summary>
@@ -205,7 +205,7 @@ public bool IsUnique
205205
/// </remarks>
206206
public string GetSqlType(Dialect.Dialect dialect, IMapping mapping)
207207
{
208-
return sqlType ?? GetDialectTypeName(dialect, mapping);
208+
return _sqlType ?? GetDialectTypeName(dialect, mapping);
209209
}
210210

211211
private string GetDialectTypeName(Dialect.Dialect dialect, IMapping mapping)
@@ -250,18 +250,18 @@ public bool Equals(Column column)
250250
if (null == column)
251251
return false;
252252

253-
if (this == column)
253+
if (ReferenceEquals(this, column))
254254
return true;
255255

256-
return IsQuoted ? name.Equals(column.name) : name.ToLowerInvariant().Equals(column.name.ToLowerInvariant());
256+
return IsQuoted ? _name.Equals(column._name) : _name.ToLowerInvariant().Equals(column._name.ToLowerInvariant());
257257
}
258258

259259
/// <summary>
260260
/// Returns the hash code for this instance.
261261
/// </summary>
262262
public override int GetHashCode()
263263
{
264-
return IsQuoted ? name.GetHashCode() : name.ToLowerInvariant().GetHashCode();
264+
return IsQuoted ? _name.GetHashCode() : _name.ToLowerInvariant().GetHashCode();
265265
}
266266

267267
#endregion
@@ -277,8 +277,8 @@ public override int GetHashCode()
277277
/// </remarks>
278278
public string SqlType
279279
{
280-
get { return sqlType; }
281-
set { sqlType = value; }
280+
get { return _sqlType; }
281+
set { _sqlType = value; }
282282
}
283283

284284
/// <summary>
@@ -287,34 +287,34 @@ public string SqlType
287287
/// <value><see langword="true" /> if the column is quoted.</value>
288288
public bool IsQuoted
289289
{
290-
get { return quoted; }
291-
set { quoted = value; }
290+
get { return _quoted; }
291+
set { _quoted = value; }
292292
}
293293

294294
/// <summary>
295295
/// Gets or sets whether the column is unique.
296296
/// </summary>
297297
public bool Unique
298298
{
299-
get { return unique; }
300-
set { unique = value; }
299+
get { return _unique; }
300+
set { _unique = value; }
301301
}
302302

303303
/// <summary>
304304
/// Gets or sets a check constraint on the column
305305
/// </summary>
306306
public string CheckConstraint
307307
{
308-
get { return checkConstraint; }
309-
set { checkConstraint = value; }
308+
get { return _checkConstraint; }
309+
set { _checkConstraint = value; }
310310
}
311311

312312
/// <summary>
313313
/// Do we have a check constraint?
314314
/// </summary>
315315
public bool HasCheckConstraint
316316
{
317-
get { return !string.IsNullOrEmpty(checkConstraint); }
317+
get { return !string.IsNullOrEmpty(_checkConstraint); }
318318
}
319319

320320
public string Text
@@ -334,14 +334,14 @@ public bool IsFormula
334334

335335
public int Precision
336336
{
337-
get { return precision.GetValueOrDefault(DefaultPrecision); }
338-
set { precision = value; }
337+
get { return _precision.GetValueOrDefault(DefaultPrecision); }
338+
set { _precision = value; }
339339
}
340340

341341
public int Scale
342342
{
343-
get { return scale.GetValueOrDefault(DefaultScale); }
344-
set { scale = value; }
343+
get { return _scale.GetValueOrDefault(DefaultScale); }
344+
set { _scale = value; }
345345
}
346346

347347
public IValue Value
@@ -361,20 +361,20 @@ public IValue Value
361361
/// </remarks>
362362
public SqlType SqlTypeCode
363363
{
364-
get { return sqlTypeCode; }
365-
set { sqlTypeCode = value; }
364+
get { return _sqlTypeCode; }
365+
set { _sqlTypeCode = value; }
366366
}
367367

368368
public string Comment
369369
{
370-
get { return comment; }
371-
set { comment = value; }
370+
get { return _comment; }
371+
set { _comment = value; }
372372
}
373373

374374
public string DefaultValue
375375
{
376-
get { return defaultValue; }
377-
set { defaultValue = value; }
376+
get { return _defaultValue; }
377+
set { _defaultValue = value; }
378378
}
379379

380380
public string GetTemplate(Dialect.Dialect dialect, SQLFunctionRegistry functionRegistry)
@@ -384,7 +384,7 @@ public string GetTemplate(Dialect.Dialect dialect, SQLFunctionRegistry functionR
384384

385385
public override string ToString()
386386
{
387-
return string.Format("{0}({1})", GetType().FullName, name);
387+
return string.Format("{0}({1})", GetType().FullName, _name);
388388
}
389389

390390
public SqlType GetSqlTypeCode(IMapping mapping)
@@ -393,7 +393,7 @@ public SqlType GetSqlTypeCode(IMapping mapping)
393393
try
394394
{
395395
SqlType sqltc = type.SqlTypes(mapping)[TypeIndex];
396-
if (SqlTypeCode != null && SqlTypeCode != sqltc)
396+
if (SqlTypeCode != null && !ReferenceEquals(SqlTypeCode, sqltc))
397397
{
398398
throw new MappingException(string.Format("SQLType code's does not match. mapped as {0} but is {1}", sqltc, SqlTypeCode));
399399
}
@@ -402,14 +402,14 @@ public SqlType GetSqlTypeCode(IMapping mapping)
402402
catch (Exception e)
403403
{
404404
throw new MappingException(string.Format("Could not determine type for column {0} of type {1}: {2}",
405-
name, type.GetType().FullName, e.GetType().FullName), e);
405+
_name, type.GetType().FullName, e.GetType().FullName), e);
406406
}
407407
}
408408

409409
/// <summary>returns quoted name as it would be in the mapping file. </summary>
410410
public string GetQuotedName()
411411
{
412-
return quoted ? '`' + name + '`' : name;
412+
return _quoted ? '`' + _name + '`' : _name;
413413
}
414414

415415
public bool IsCaracteristicsDefined()
@@ -419,39 +419,39 @@ public bool IsCaracteristicsDefined()
419419

420420
public bool IsPrecisionDefined()
421421
{
422-
return precision.HasValue || scale.HasValue;
422+
return _precision.HasValue || _scale.HasValue;
423423
}
424424

425425
public bool IsLengthDefined()
426426
{
427-
return length.HasValue;
427+
return _length.HasValue;
428428
}
429429

430430
#region ICloneable Members
431431
/// <summary> Shallow copy, the value is not copied</summary>
432432
public object Clone()
433433
{
434434
Column copy = new Column();
435-
if (length.HasValue)
435+
if (_length.HasValue)
436436
copy.Length = Length;
437-
if (precision.HasValue)
437+
if (_precision.HasValue)
438438
copy.Precision = Precision;
439-
if (scale.HasValue)
439+
if (_scale.HasValue)
440440
copy.Scale = Scale;
441441
copy.Value = _value;
442-
copy.TypeIndex = typeIndex;
442+
copy.TypeIndex = _typeIndex;
443443
copy.Name = GetQuotedName();
444-
copy.IsNullable = nullable;
445-
copy.Unique = unique;
446-
copy.SqlType = sqlType;
447-
copy.SqlTypeCode = sqlTypeCode;
448-
copy.uniqueInteger = uniqueInteger; //usually useless
449-
copy.CheckConstraint = checkConstraint;
450-
copy.Comment = comment;
451-
copy.DefaultValue = defaultValue;
444+
copy.IsNullable = _nullable;
445+
copy.Unique = _unique;
446+
copy.SqlType = _sqlType;
447+
copy.SqlTypeCode = _sqlTypeCode;
448+
copy.UniqueInteger = UniqueInteger; //usually useless
449+
copy.CheckConstraint = _checkConstraint;
450+
copy.Comment = _comment;
451+
copy.DefaultValue = _defaultValue;
452452
return copy;
453453
}
454454

455455
#endregion
456456
}
457-
}
457+
}

src/NHibernate/Mapping/Table.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,11 @@ public void AddColumn(Column column)
581581
if (old == null)
582582
{
583583
columns[column.CanonicalName] = column;
584-
column.uniqueInteger = columns.Count;
584+
column.UniqueInteger = columns.Count;
585585
}
586586
else
587587
{
588-
column.uniqueInteger = old.uniqueInteger;
588+
column.UniqueInteger = old.UniqueInteger;
589589
}
590590
}
591591

0 commit comments

Comments
 (0)