private static void Debug_SequentialEnumIsDefinedCheck(Enum value, int minVal, int maxVal) { Type t = value.GetType(); if (enumValueInfo is null) { enumValueInfo = new Hashtable(); } SequentialEnumInfo?sequentialEnumInfo = null; if (enumValueInfo.ContainsKey(t)) { sequentialEnumInfo = enumValueInfo[t] as SequentialEnumInfo; } if (sequentialEnumInfo is null) { sequentialEnumInfo = new SequentialEnumInfo(t); if (enumValueInfo.Count > MAXCACHE) { // see comment next to MAXCACHE declaration. Debug.Fail("cache is too bloated, clearing out, we need to revisit this."); enumValueInfo.Clear(); } enumValueInfo[t] = sequentialEnumInfo; } if (minVal != sequentialEnumInfo.MinValue) { // put string allocation in the IF block so the common case doesnt build up the string. System.Diagnostics.Debug.Fail("Minimum passed in is not the actual minimum for the enum. Consider changing the parameters or using a different function."); } if (maxVal != sequentialEnumInfo.MaxValue) { // put string allocation in the IF block so the common case doesnt build up the string. Debug.Fail("Maximum passed in is not the actual maximum for the enum. Consider changing the parameters or using a different function."); } }
private static void Debug_SequentialEnumIsDefinedCheck(Enum value, int minVal, int maxVal) { Type enumType = value.GetType(); if (t_enumValueInfo == null) { t_enumValueInfo = new Hashtable(); } SequentialEnumInfo sequentialEnumInfo = null; if (t_enumValueInfo.ContainsKey(enumType)) { sequentialEnumInfo = t_enumValueInfo[enumType] as SequentialEnumInfo; } if (sequentialEnumInfo == null) { sequentialEnumInfo = new SequentialEnumInfo(enumType); Debug.Assert(t_enumValueInfo.Count <= MaxCache); t_enumValueInfo[enumType] = sequentialEnumInfo; } Debug.Assert(minVal == sequentialEnumInfo.MinValue, "Minimum passed in is not the actual minimum for the enum. Consider changing the parameters or using a different function."); Debug.Assert(maxVal == sequentialEnumInfo.MaxValue, "Maximum passed in is not the actual maximum for the enum. Consider changing the parameters or using a different function."); }
private static void Debug_SequentialEnumIsDefinedCheck(System.Enum value, int minVal, int maxVal) { Type t = value.GetType(); if (enumValueInfo == null) { enumValueInfo = new Hashtable(); } SequentialEnumInfo sequentialEnumInfo = null; if (enumValueInfo.ContainsKey(t)) { sequentialEnumInfo = enumValueInfo[t] as SequentialEnumInfo; } if (sequentialEnumInfo == null) { sequentialEnumInfo = new SequentialEnumInfo(t); if (enumValueInfo.Count > MAXCACHE) { // see comment next to MAXCACHE declaration. Debug.Fail("cache is too bloated, clearing out, we need to revisit this."); enumValueInfo.Clear(); } enumValueInfo[t] = sequentialEnumInfo; } if (minVal != sequentialEnumInfo.MinValue) { // put string allocation in the IF block so the common case doesnt build up the string. System.Diagnostics.Debug.Fail("Minimum passed in is not the actual minimum for the enum. Consider changing the parameters or using a different function."); } if (maxVal != sequentialEnumInfo.MaxValue) { // put string allocation in the IF block so the common case doesnt build up the string. Debug.Fail("Maximum passed in is not the actual maximum for the enum. Consider changing the parameters or using a different function."); } }