Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3057


Ignore:
Timestamp:
03/16/10 10:21:41 (15 years ago)
Author:
epitzer
Message:

Fix warnings (#915)

Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Tests/HeuristicLab.Persistence-3.3.Tests.csproj

    r2951 r3057  
    3030    <ErrorReport>prompt</ErrorReport>
    3131    <WarningLevel>4</WarningLevel>
     32    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    3233  </PropertyGroup>
    3334  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
  • trunk/sources/HeuristicLab.Persistence/3.3/Tests/StorableAttributeTests.cs

    r3025 r3057  
    1212
    1313    [Storable(Name = "TestProperty", DefaultValue = 12)]
    14     public object o;
     14    public object o = null;
    1515
    1616    [Storable]
    1717    public int x = 2;
    1818
    19     public int y;
    20 
     19    public int y = 0;
    2120  }
    2221
  • trunk/sources/HeuristicLab.Persistence/3.3/Tests/UseCases.cs

    r3029 r3057  
    4141    [Storable]
    4242    private ulong _ulong = 123456;
     43    public override bool Equals(object obj) {
     44      NumberTest nt = obj as NumberTest;
     45      if (nt == null)
     46        throw new NotSupportedException();
     47      return
     48        nt._bool == _bool &&
     49        nt._byte == _byte &&
     50        nt._sbyte == _sbyte &&
     51        nt._short == _short &&
     52        nt._ushort == _ushort &&
     53        nt._int == _int &&
     54        nt._uint == _uint &&
     55        nt._long == _long &&
     56        nt._ulong == _ulong;
     57    }
     58    public override int GetHashCode() {
     59      return
     60        _bool.GetHashCode() ^
     61        _byte.GetHashCode() ^
     62        _sbyte.GetHashCode() ^
     63        _short.GetHashCode() ^
     64        _short.GetHashCode() ^
     65        _int.GetHashCode() ^
     66        _uint.GetHashCode() ^
     67        _long.GetHashCode() ^
     68        _ulong.GetHashCode();
     69    }
    4370  }
    4471
     
    86113    [Storable]
    87114    private object o = new object();
     115    public override bool Equals(object obj) {
     116      PrimitivesTest pt = obj as PrimitivesTest;
     117      if (pt == null)
     118        throw new NotSupportedException();
     119      return base.Equals(obj) &&
     120        c == pt.c &&
     121        _long_array == pt._long_array &&
     122        list == pt.list &&
     123        o == pt.o;
     124    }
     125    public override int GetHashCode() {
     126      return base.GetHashCode() ^
     127        c.GetHashCode() ^
     128        _long_array.GetHashCode() ^
     129        list.GetHashCode() ^
     130        o.GetHashCode();
     131    }
    88132  }
    89133
     
    96140    [Storable]
    97141    public TestEnum myEnum = TestEnum.va3;
     142    public override bool Equals(object obj) {
     143      RootBase rb = obj as RootBase;
     144      if (rb == null)
     145        throw new NotSupportedException();
     146      return baseString == rb.baseString &&
     147        myEnum == rb.myEnum;
     148    }
     149    public override int GetHashCode() {
     150      return baseString.GetHashCode() ^
     151        myEnum.GetHashCode();
     152    }
    98153  }
    99154
     
    175230
    176231  public class NonSerializable {
    177     int x;
     232    int x = 0;
     233    public override bool Equals(object obj) {
     234      NonSerializable ns = obj as NonSerializable;
     235      if (ns == null)
     236        throw new NotSupportedException();
     237      return ns.x == x;
     238    }
     239    public override int GetHashCode() {
     240      return x.GetHashCode();
     241    }
    178242  }
    179243
     
    377441      [Storable]
    378442      private string value = "value";
     443      public override bool Equals(object obj) {
     444        NestedType nt = obj as NestedType;
     445        if (nt == null)
     446          throw new NotSupportedException();
     447        return nt.value == value;
     448      }
     449      public override int GetHashCode() {
     450        return value.GetHashCode();
     451      }
    379452    }
    380453
     
    387460        DebugStringGenerator.Serialize(t),
    388461        DebugStringGenerator.Serialize(o));
     462      Assert.IsTrue(t.Equals(o));
    389463    }
    390464
     
    465539        DebugStringGenerator.Serialize(sdt),
    466540        DebugStringGenerator.Serialize(o));
     541      Assert.IsTrue(sdt.Equals(o));
    467542    }
    468543
  • trunk/sources/HeuristicLab.Tracing/3.2/Logger.cs

    r2790 r3057  
    2929namespace HeuristicLab.Tracing {
    3030
     31  /// <summary>
     32  /// HeuristicLab Tracing entry point. Default logger. Reads configured tracing
     33  /// file and provides automatic logging with reflection of the calling type.
     34  /// </summary>
    3135  public class Logger {
    3236
     37    /// <summary>
     38    /// true if Configure has been called already.
     39    /// </summary>
    3340    protected static bool IsConfigured = false;
    3441
     42    /// <summary>
     43    /// Configures this instance: Reads the log file specified in the settings.
     44    /// </summary>
    3545    protected static void Configure() {
    3646      if (IsConfigured) return;
     
    4555    }
    4656
     57    /// <summary>
     58    /// Gets the default logger for the calling class n levels up in the
     59    /// call hierarchy.
     60    /// </summary>
     61    /// <param name="nParents">The number of parent calls.</param>
     62    /// <returns>An <see cref="ILog"/> instance.</returns>
    4763    public static ILog GetDefaultLogger(int nParents) {
    4864      Configure();
     
    5167    }
    5268
     69    /// <summary>
     70    /// Gets the default logger: The logger for the class of the
     71    /// calling method.
     72    /// </summary>
     73    /// <returns>An <see cref="ILog"/> instance.</returns>
    5374    public static ILog GetDefaultLogger() {
    5475      Configure();
     
    5778    }
    5879
     80    /// <summary>
     81    /// Issues a debug message to the default logger.
     82    /// </summary>
     83    /// <param name="message">The message.</param>
    5984    public static void Debug(object message) {
    6085      GetDefaultLogger(1).Debug(message);
    6186    }
    6287
     88    /// <summary>
     89    /// Issues an informational message to the default logger.
     90    /// </summary>
     91    /// <param name="message">The message.</param>
    6392    public static void Info(object message) {
    6493      GetDefaultLogger(1).Info(message);
    6594    }
    6695
     96    /// <summary>
     97    /// Issues a warning message to the default logger.
     98    /// </summary>
     99    /// <param name="message">The message.</param>
    67100    public static void Warn(object message) {
    68101      GetDefaultLogger(1).Warn(message);
    69102    }
    70103
     104    /// <summary>
     105    /// Issues an error message to the default logger.
     106    /// </summary>
     107    /// <param name="message">The message.</param>
    71108    public static void Error(object message) {
    72109      GetDefaultLogger(1).Error(message);
    73110    }
    74111
     112    /// <summary>
     113    /// Issues a fatal error message to the default logger.
     114    /// </summary>
     115    /// <param name="message">The message.</param>
    75116    public static void Fatal(object message) {
    76117      GetDefaultLogger(1).Fatal(message);
    77118    }
    78119
     120    /// <summary>
     121    /// Issues a debug message to the logger of the specified type.
     122    /// </summary>
     123    /// <param name="type">The type.</param>
     124    /// <param name="message">The message.</param>
    79125    public static void Debug(Type type, object message) {
    80126      Configure();
     
    82128    }
    83129
     130    /// <summary>
     131    /// Issues an iformational message to the logger of the specified
     132    /// type.
     133    /// </summary>
     134    /// <param name="type">The type.</param>
     135    /// <param name="message">The message.</param>
    84136    public static void Info(Type type, object message) {
    85137      Configure();
     
    87139    }
    88140
     141    /// <summary>
     142    /// Issues a warning message to the logger of
     143    /// the specified type.
     144    /// </summary>
     145    /// <param name="type">The type.</param>
     146    /// <param name="message">The message.</param>
    89147    public static void Warn(Type type, object message) {
    90148      Configure();
     
    92150    }
    93151
     152    /// <summary>
     153    /// Issues an error message to the logger of the specified
     154    /// type.
     155    /// </summary>
     156    /// <param name="type">The type.</param>
     157    /// <param name="message">The message.</param>
    94158    public static void Error(Type type, object message) {
    95159      Configure();
     
    97161    }
    98162
     163    /// <summary>
     164    /// Issues a fatal error message to the logger of
     165    /// the specified type.
     166    /// </summary>
     167    /// <param name="type">The type.</param>
     168    /// <param name="message">The message.</param>
    99169    public static void Fatal(Type type, object message) {
    100170      Configure();
     
    102172    }
    103173
     174    /// <summary>
     175    /// Issues a debug message to the default
     176    /// logger including an exception.
     177    /// </summary>
     178    /// <param name="message">The message.</param>
     179    /// <param name="exception">The exception.</param>
    104180    public static void Debug(object message, Exception exception) {
    105181      GetDefaultLogger(1).Debug(message, exception);
    106182    }
    107183
     184    /// <summary>
     185    /// Issues an informational message to the default
     186    /// logger including an exception.
     187    /// </summary>
     188    /// <param name="message">The message.</param>
     189    /// <param name="exception">The exception.</param>
     190
    108191    public static void Info(object message, Exception exception) {
    109192      GetDefaultLogger(1).Info(message, exception);
    110193    }
    111194
     195    /// <summary>
     196    /// Issues a warning message to the default
     197    /// logger including an exception.
     198    /// </summary>
     199    /// <param name="message">The message.</param>
     200    /// <param name="exception">The exception.</param>
    112201    public static void Warn(object message, Exception exception) {
    113202      GetDefaultLogger(1).Warn(message, exception);
    114203    }
    115204
     205    /// <summary>
     206    /// Issues an error message to the default
     207    /// logger including an exception.
     208    /// </summary>
     209    /// <param name="message">The message.</param>
     210    /// <param name="exception">The exception.</param>
    116211    public static void Error(object message, Exception exception) {
    117212      GetDefaultLogger(1).Error(message, exception);
    118213    }
    119214
     215    /// <summary>
     216    /// Issues a fatal error message to the default
     217    /// logger including an exception.
     218    /// </summary>
     219    /// <param name="message">The message.</param>
     220    /// <param name="exception">The exception.</param>
    120221    public static void Fatal(object message, Exception exception) {
    121222      GetDefaultLogger(1).Fatal(message, exception);
    122223    }
    123224
     225    /// <summary>
     226    /// Issues a debug message to the logger of the specified
     227    /// type including an exception.
     228    /// </summary>
     229    /// <param name="type">The type.</param>
     230    /// <param name="message">The message.</param>
     231    /// <param name="exception">The exception.</param>
    124232    public static void Debug(Type type, object message, Exception exception) {
    125233      Configure();
     
    127235    }
    128236
     237    /// <summary>
     238    /// Issues an informational message to the logger of the specified
     239    /// type including an exception.
     240    /// </summary>
     241    /// <param name="type">The type.</param>
     242    /// <param name="message">The message.</param>
     243    /// <param name="exception">The exception.</param>
    129244    public static void Info(Type type, object message, Exception exception) {
    130245      Configure();
     
    132247    }
    133248
     249    /// <summary>
     250    /// Issues a warning message to the logger of the specified
     251    /// type including an exception.
     252    /// </summary>
     253    /// <param name="type">The type.</param>
     254    /// <param name="message">The message.</param>
     255    /// <param name="exception">The exception.</param>
    134256    public static void Warn(Type type, object message, Exception exception) {
    135257      Configure();
     
    137259    }
    138260
     261    /// <summary>
     262    /// Issues an error message to the logger of the specified
     263    /// type including an exception.
     264    /// </summary>
     265    /// <param name="type">The type.</param>
     266    /// <param name="message">The message.</param>
     267    /// <param name="exception">The exception.</param>
    139268    public static void Error(Type type, object message, Exception exception) {
    140269      Configure();
     
    142271    }
    143272
     273    /// <summary>
     274    /// Issues a fatal error message to the logger of the specified
     275    /// type including an exception.
     276    /// </summary>
     277    /// <param name="type">The type.</param>
     278    /// <param name="message">The message.</param>
     279    /// <param name="exception">The exception.</param>
    144280    public static void Fatal(Type type, object message, Exception exception) {
    145281      Configure();
    146282      LogManager.GetLogger(type).Fatal(message, exception);
    147283    }
    148 
    149284  }
    150285}
Note: See TracChangeset for help on using the changeset viewer.