1285 references to Contracts
Microsoft.ML.Core (1283)
CommandLine\ArgumentAttribute.cs (1)
58Contracts.Check(value == null || !(this is DefaultArgumentAttribute));
CommandLine\CharCursor.cs (5)
25Contracts.CheckValueOrNull(text); 34Contracts.CheckValueOrNull(text); 35Contracts.CheckParam(0 <= min && min <= Utils.Size(text), nameof(min)); 36Contracts.CheckParam(min <= lim && lim <= Utils.Size(text), nameof(lim)); 63Contracts.Assert(0 <= dich && dich <= _ichLim - _ichCur);
CommandLine\CmdLexer.cs (24)
80Contracts.Assert(bldr.Length > ichDst); 120Contracts.Assert(_curs.ChCur == '{'); 133Contracts.Assert(count > 0); 168Contracts.Assert(_curs.ChCur == '{'); 182Contracts.Assert(count >= 0); 215Contracts.Assert(_curs.ChCur == '\\'); 216Contracts.Assert(_escapes); 249Contracts.Assert(_curs.ChCur == '"'); 321Contracts.AssertValueOrNull(str); 329Contracts.AssertValue(sb); 330Contracts.Assert(0 <= ich && ich <= sb.Length); 346Contracts.Assert(curs.IchCur > 0 || lex.Error); 381Contracts.Assert(f == (force || curs.ChCur == '{')); 390Contracts.Assert(v.StartsWith("{") && v.EndsWith("}")); 396Contracts.Assert(!lex.Error); 397Contracts.Assert(curs.Eof); 398Contracts.Assert(str == res.ToString()); 415Contracts.Assert(ich == sb.Length); 420Contracts.Assert(ich == sb.Length); 431Contracts.AssertNonEmpty(str); 444Contracts.Assert(curs.IchCur > 0 || lex.Error); 467Contracts.AssertNonEmpty(str); 517Contracts.Assert(ichMin >= 0 && _str[ichMin] == '\\'); 518Contracts.Assert(ichMin == 0 || _str[ichMin - 1] != '\\');
CommandLine\CmdParser.cs (63)
238Contracts.CheckValue(env, nameof(env)); 281Contracts.CheckValue(destination, nameof(destination)); 292Contracts.CheckValue(env, nameof(env)); 430Contracts.AssertValueOrNull(reporter); 455Contracts.Assert(1 < firstNonUpper && firstNonUpper <= name.Length); 464Contracts.CheckValue(type, nameof(type)); 465Contracts.CheckParam(type.IsClass, nameof(type)); 476Contracts.Check(!field.IsStatic && !field.IsInitOnly && !field.IsLiteral); 479throw Contracts.Except($"Duplicate default argument '{def.LongName}' vs '{field.Name}'"); 497Contracts.Assert(!isDefault || nicks == null); 500throw Contracts.Except($"Duplicate name '{name}' in argument type '{type.Name}'"); 506throw Contracts.Except($"Duplicate name '{nick}' in argument type '{type.Name}'"); 530Contracts.Assert(def.ShortNames == null); 532Contracts.Assert(map.ContainsKey(name) && map[name] == def); 569Contracts.Assert(!string.IsNullOrEmpty(str)); 622Contracts.AssertValue(arg); 623Contracts.Assert(arg != info.ArgDef); 624Contracts.Assert(0 <= arg.Index && arg.Index < info.Args.Length); 1038Contracts.Assert(ich < curs.IchCur || curs.Eof); 1091Contracts.Assert(ich < curs.IchCur || curs.Eof); 1166throw Contracts.Except("Invalid Component string: mismatched braces, or empty component name."); 1179Contracts.AssertValueOrNull(first); 1191Contracts.AssertValue(info); 1192Contracts.AssertValue(args); 1206Contracts.Assert(Args.Where(a => a.Index == argument.Index).Count() == 1); 1208Contracts.AssertValue(arg); 1248Contracts.AssertValue(arg); 1254Contracts.CheckValue(type, nameof(type)); 1255Contracts.CheckValueOrNull(defaults); 1266Contracts.AssertValue(type); 1270Contracts.Assert(isGeneric); 1272Contracts.Assert(Utils.Size(genArgs) == 1); 1342Contracts.Assert(argDef == null || argDef.Index == -1); 1343Contracts.AssertValue(args); 1344Contracts.AssertValue(map); 1345Contracts.Assert(map.Count >= args.Length); 1346Contracts.Assert(args.Select((arg, index) => arg.Index == index).All(b => b)); 1365Contracts.AssertValue(type); 1374Contracts.AssertValue(type); 1383Contracts.AssertValue(sb); 1422Contracts.Assert(index >= -1); 1423Contracts.Assert(!string.IsNullOrWhiteSpace(name)); 1424Contracts.Check(nicks == null || nicks.All(nick => !string.IsNullOrWhiteSpace(nick))); 1425Contracts.AssertValueOrNull(defaults); 1426Contracts.AssertValue(attr); 1427Contracts.AssertValue(field); 1441Contracts.Assert(!IsDefault || Utils.Size(ShortNames) == 0); 1485throw Contracts.Except("Invalid argument type: '{0}'", ItemValueType.Name); 1488Contracts.Check(!IsCollection || AllowMultiple, "Collection arguments must allow multiple"); 1489Contracts.Check(!Unique || IsCollection, "Unique only applicable to collection arguments"); 1494Contracts.AssertValue(type); 1498Contracts.AssertValue(type.GenericTypeArguments); 1545Contracts.Check(_signatureType != null, "ComponentFactory Arguments need a SignatureType set."); 1682Contracts.Assert(string.IsNullOrEmpty(tag) || tag.StartsWith("[") && tag.EndsWith("]")); 1709Contracts.Assert(newValue is string || newValue == null); 1710Contracts.Assert((string)newValue != ""); 1892Contracts.Assert(type.IsEnum); 1929Contracts.Assert(success); 1966Contracts.Assert(value == null || value is Array); 2037Contracts.Assert(IsKeyValuePair(type)); 2065Contracts.Assert(value == null || value is Array); 2242Contracts.Assert(false); 2292throw Contracts.ExceptNotImpl("ComponentFactoryFactory can only create IComponentFactory<> types with 4 or less type args.");
ComponentModel\AssemblyLoadingUtils.cs (7)
23Contracts.AssertValue(env); 33Contracts.CheckNonEmpty(path, nameof(path)); 36throw Contracts.ExceptParam(nameof(path), "File does not exist at path: {0}", path); 68throw Contracts.ExceptIO(e, "Creating temp directory for extra assembly zip extraction failed: '{0}'", path); 77throw Contracts.ExceptIO(e, "Extracting extra assembly zip failed: '{0}'", path); 87Contracts.CheckValue(env, nameof(env)); 95Contracts.CheckValue(env, nameof(env));
ComponentModel\ComponentCatalog.cs (69)
202Contracts.AssertValue(attr); 203Contracts.AssertValue(attr.InstanceType); 204Contracts.AssertValue(attr.LoaderType); 205Contracts.AssertValueOrNull(attr.Summary); 206Contracts.AssertValueOrNull(attr.DocName); 207Contracts.AssertValueOrNull(attr.UserName); 208Contracts.AssertNonEmpty(attr.LoadNames); 209Contracts.Assert(getter == null || Utils.Size(attr.CtorTypes) == 0); 231Contracts.Assert(ArgType == null || CtorTypes.Length > 0 && CtorTypes[0] == ArgType); 236Contracts.Assert(Utils.Size(ctorArgs) == CtorTypes.Length + ((RequireEnvironment) ? 1 : 0)); 241Contracts.Assert(Utils.Size(ctorArgs) == 0); 252throw Contracts.Except(ex, "Error during class instantiation"); 256throw Contracts.Except("Can't instantiate class '{0}'", Type.Name); 267Contracts.CheckValue(env, nameof(env)); 289throw Contracts.Except("Loadable class '{0}' does not derive from '{1}'", LoadNames[0], typeof(TRes).FullName); 299throw Contracts.Except("Loadable class '{0}' does not derive from '{1}'", LoadNames[0], typeof(TRes).FullName); 315throw Contracts.Except("Loadable class '{0}' has ArgType '{1}', which has no suitable constructor", 343Contracts.AssertValue(method); 344Contracts.AssertValue(attribute); 357throw Contracts.Except("Method '{0}' has {1} parameters, but must have 2 or 3", method.Name, parameters.Length); 359throw Contracts.Except("Method '{0}', 1st parameter is {1}, but must be IHostEnvironment", method.Name, parameters[0].ParameterType); 363throw Contracts.Except("Method '{0}' returns {1}, but must return a class", method.Name, outputType); 407Contracts.AssertValue(interfaceType); 408Contracts.AssertNonEmpty(kind); 409Contracts.AssertValue(argumentType); 410Contracts.AssertValue(attribute); 421throw Contracts.Except("Invalid component kind: '{0}'", Kind); 425throw Contracts.Except("Component name '{0}' is not valid.", Name); 428throw Contracts.Except("Component '{0}' has an invalid alias '{1}'", Name, Aliases.First(x => !IsValidName(x))); 431throw Contracts.Except("Component '{0}' must inherit from IComponentFactory", argumentType); 496throw Contracts.Except($"Can't load type {instType}, because it has both create and constructor methods with the same visibility. Please indicate which one should be used by changing either the signature or the visibility of one of them."); 541throw Contracts.Except($"ComponentCatalog cannot map name '{name}' and SignatureType '{sigType}' to {info.Type.Name}, already mapped to {infoCur.Type.Name}."); 610throw Contracts.Except("Component signature '{0}' doesn't inherit from '{1}'", faceType, typeof(IComponentFactory)); 619throw Contracts.Except(ex, "Component type '{0}' doesn't have a default constructor", faceType); 701throw Contracts.Except( 704Contracts.Assert(getter == null && ctor == null && create == null); 733Contracts.CheckValue(typeBase, nameof(typeBase)); 734Contracts.CheckValueOrNull(typeSig); 761Contracts.CheckValue(sig, nameof(sig)); 762Contracts.CheckParam(sig.BaseType == typeof(MulticastDelegate), nameof(sig), "Must be a delegate type"); 816Contracts.CheckParam(signatureType.BaseType == typeof(MulticastDelegate), nameof(signatureType), "signatureType must be a delegate type"); 817Contracts.CheckValueOrNull(loadName); 834Contracts.CheckNonEmpty(name, nameof(name)); 841Contracts.CheckNonEmpty(kind, nameof(kind)); 842Contracts.CheckNonEmpty(alias, nameof(alias)); 852Contracts.CheckValue(argumentType, nameof(argumentType)); 861Contracts.CheckValue(interfaceType, nameof(interfaceType)); 862Contracts.CheckParam(interfaceType.IsInterface, nameof(interfaceType), "Must be interface"); 863Contracts.CheckValue(argumentType, nameof(argumentType)); 872Contracts.CheckValue(interfaceType, nameof(interfaceType)); 873Contracts.CheckParam(interfaceType.IsInterface, nameof(interfaceType), "Must be interface"); 874Contracts.CheckNonEmpty(alias, nameof(alias)); 886Contracts.CheckValue(interfaceType, nameof(interfaceType)); 887Contracts.CheckParam(interfaceType.IsInterface, nameof(interfaceType), "Must be interface"); 888Contracts.CheckNonEmpty(alias, nameof(alias)); 918Contracts.CheckNonEmpty(kind, nameof(kind)); 919Contracts.CheckParam(IsValidName(kind), nameof(kind), "Invalid component kind"); 929Contracts.CheckValue(interfaceType, nameof(interfaceType)); 936Contracts.CheckValue(signatureType, nameof(signatureType)); 966Contracts.AssertValueOrNull(name); 982throw Contracts.Except("Unknown loadable class: {0}", name).MarkSensitive(MessageSensitivity.None); 1000Contracts.CheckValue(env, nameof(env)); 1034throw Contracts.Except("Can't instantiate arguments object '{0}' for '{1}'", info.ArgType.Name, name); 1051Contracts.AssertValue(args); 1052Contracts.AssertNonEmpty(name); 1067Contracts.Assert(false); 1068throw Contracts.Except(e, "Unexpected exception thrown while parsing: " + e.Message); 1072throw Contracts.Except(errorMsg); 1092throw Contracts.Except($"An extension for '{key.AttributeType.Name}' with contract '{key.ContractName}' has already been registered in the ComponentCatalog.");
ComponentModel\LoadableClassAttribute.cs (17)
163Contracts.CheckValueOrNull(summary); 164Contracts.CheckValue(instType, nameof(instType)); 165Contracts.CheckValue(loaderType, nameof(loaderType)); 166Contracts.CheckNonEmpty(sigTypes, nameof(sigTypes)); 172throw Contracts.ExceptEmpty(nameof(loadNames), "LoadableClass loadName parameter can't be empty"); 175Contracts.CheckValue(sigType, nameof(sigTypes)); 177Contracts.CheckParam(sigType.BaseType == typeof(System.MulticastDelegate), nameof(sigTypes), "LoadableClass signature type must be a delegate type"); 180Contracts.CheckParam(meth != null, nameof(sigTypes), "LoadableClass signature type must be a delegate type"); 181Contracts.CheckParam(meth.ReturnType == typeof(void), nameof(sigTypes), "LoadableClass signature type must be a delegate type with void return"); 200throw Contracts.Except("Invalid signature parameter attributes"); 207Contracts.CheckValue(sigType, nameof(sigTypes)); 209Contracts.Check(sigType.BaseType == typeof(System.MulticastDelegate), "LoadableClass signature type must be a delegate type"); 212Contracts.CheckParam(meth != null, nameof(sigTypes), "LoadableClass signature type must be a delegate type"); 213Contracts.CheckParam(meth.ReturnType == typeof(void), nameof(sigTypes), "LoadableClass signature type must be a delegate type with void return"); 215Contracts.CheckParam(parms.Length + itypeBase == types.Length, nameof(sigTypes), "LoadableClass signatures must have the same number of parameters"); 220throw Contracts.ExceptParam(nameof(sigTypes), "Invalid signature parameter attributes"); 221Contracts.CheckParam(types[itypeBase + itype] == parm.ParameterType, nameof(sigTypes),
Data\AnnotationUtils.cs (15)
118public static Exception ExceptGetAnnotation() => Contracts.Except("Invalid call to GetAnnotation"); 130Contracts.CheckValue(getter, nameof(getter)); 144Contracts.CheckParam(size > 0, nameof(size), "must be known size"); 156Contracts.CheckParam(rangeCount > 0, nameof(rangeCount), "must be known size"); 198Contracts.CheckValue(type, nameof(type)); 300Contracts.CheckValueOrNull(schema); 301Contracts.CheckParam(vectorSize >= 0, nameof(vectorSize)); 326Contracts.CheckParam(column.IsValid, nameof(column), "struct not initialized properly"); 341Contracts.CheckParam(col.IsValid, nameof(col), "struct not initialized properly"); 360Contracts.CheckValue(schema, nameof(schema)); 361Contracts.CheckValue(type, nameof(type)); 380Contracts.CheckValue(schema, nameof(schema)); 381Contracts.Check(colIndex >= 0, nameof(colIndex)); 464Contracts.AssertValue(annotations); 497Contracts.CheckValue(annotations, nameof(annotations));
Data\ColumnTypeExtensions.cs (2)
135Contracts.Assert(false); 165Contracts.Assert(false);
Data\DataKind.cs (3)
141Contracts.Check(0 <= index && index < KindCount); 158Contracts.Check(kind != InternalDataKind.UG); 295Contracts.CheckValueOrNull(type);
Data\IEstimator.cs (10)
64Contracts.CheckNonEmpty(name, nameof(name)); 65Contracts.CheckValueOrNull(annotations); 66Contracts.CheckParam(!(itemType is KeyDataViewType), nameof(itemType), "Item type cannot be a key"); 67Contracts.CheckParam(!(itemType is VectorDataViewType), nameof(itemType), "Item type cannot be a vector"); 68Contracts.CheckParam(!isKey || KeyDataViewType.IsValidDataType(itemType.RawType), nameof(itemType), "The item type must be valid for a key"); 89Contracts.Check(source.IsValid, nameof(source)); 131Contracts.CheckValue(columns, nameof(columns)); 133Contracts.CheckParam(columns.All(c => c.IsValid), nameof(columns), "Some items are not initialized properly."); 180Contracts.CheckValue(schema, nameof(schema)); 209Contracts.CheckValue(name, nameof(name));
Data\IFileHandle.cs (7)
69Contracts.CheckValue(ectx, nameof(ectx)); 99Contracts.Assert(_streams != null); 113Contracts.Assert(false, "Closing a SimpleFileHandle write stream failed!"); 128Contracts.Assert(false, "Closing a SimpleFileHandle read stream failed!"); 133Contracts.Assert(IsDisposed); 145Contracts.Assert(false, "Deleting a SimpleFileHandle physical file failed!"); 166Contracts.Assert(_streamWrite == null);
Data\IHostEnvironment.cs (8)
38Contracts.AssertValue(env); 39Contracts.CheckNonWhiteSpace(path, nameof(path)); 48Contracts.AssertValue(env); 49Contracts.CheckNonWhiteSpace(path, nameof(path)); 225Contracts.CheckNonEmpty(message, nameof(message)); 235Contracts.CheckNonEmpty(fmt, nameof(fmt)); 236Contracts.CheckNonEmpty(args, nameof(args)); 262/// that do not belong in more specific areas, for example, <see cref="Contracts"/> or
Data\IProgressChannel.cs (2)
104Contracts.CheckValueOrNull(unitNames); 105Contracts.CheckValueOrNull(metricNames);
Data\ModelHeader.cs (76)
109Contracts.Assert(Marshal.SizeOf(typeof(ModelHeader)) == Size); 110Contracts.CheckValue(writer, nameof(writer)); 122Contracts.CheckIO(writer.FpCur() == fpMin + ModelHeader.Size); 131Contracts.CheckValue(writer, nameof(writer)); 132Contracts.CheckParam(fpMin >= 0, nameof(fpMin)); 133Contracts.CheckValueOrNull(pool); 138Contracts.Check(header.FpStringTable == 0); 139Contracts.Check(header.CbStringTable == 0); 140Contracts.Check(header.FpStringChars == 0); 141Contracts.Check(header.CbStringChars == 0); 152Contracts.Assert(ns.Id == cv); 157Contracts.Assert(cv == pool.Count); 160Contracts.Assert(header.FpStringChars == header.FpStringTable + header.CbStringTable); 167Contracts.Assert(offset == header.CbStringChars); 199Contracts.CheckValue(writer, nameof(writer)); 200Contracts.CheckParam(fpMin >= 0, nameof(fpMin)); 210Contracts.Assert(res); 211Contracts.Check(res); 218Contracts.Assert(writer.FpCur() == fpMin + ModelHeader.Size); 228Contracts.Check(header.FpModel == ModelHeader.Size); 229Contracts.Check(header.CbModel == 0); 232Contracts.Check(fpCur - fpMin >= header.FpModel); 262Contracts.Check(sig.Length <= 24); 266Contracts.Check(ch <= 0xFF); 288Contracts.Check(sig.Length <= 24); 292Contracts.Check(ch <= 0xFF); 307Contracts.Check(Utils.Size(bytes) >= Size); 326Contracts.CheckDecode(headerBytes.Length == ModelHeader.Size); 342Contracts.CheckDecode(header.FpModel + header.CbModel == reader.FpCur() - fpMin); 351Contracts.CheckDecode(header.ModelSignature == ver.ModelSignature, "Unknown file type"); 352Contracts.CheckDecode(header.ModelVerReadable <= header.ModelVerWritten, "Corrupt file header"); 354throw Contracts.ExceptDecode("Cause: ML.NET {0} cannont read component '{1}' of the model, because the model is too new.\n" + 362throw Contracts.ExceptDecode("Cause: ML.NET {0} cannot read component '{1}' of the model, because the model is too old.\n" + 374Contracts.Check(Utils.Size(bytes) >= Size); 388Contracts.Check(size >= 0); 392Contracts.CheckDecode(header.Signature == SignatureValue, "Wrong file type"); 393Contracts.CheckDecode(header.VerReadable <= header.VerWritten, "Corrupt file header"); 394Contracts.CheckDecode(header.VerReadable <= VerWrittenCur, "File is too new"); 395Contracts.CheckDecode(header.VerWritten >= VerWeCanReadBack, "File is too old"); 398Contracts.CheckDecode(header.FpModel == Size); 399Contracts.CheckDecode(header.FpModel + header.CbModel >= header.FpModel); 404Contracts.CheckDecode(header.CbStringTable == 0); 405Contracts.CheckDecode(header.FpStringChars == 0); 406Contracts.CheckDecode(header.CbStringChars == 0); 409Contracts.CheckDecode(header.FpTail == header.FpModel + header.CbModel); 415Contracts.CheckDecode(header.FpStringTable == header.FpModel + header.CbModel); 416Contracts.CheckDecode(header.CbStringTable % sizeof(long) == 0); 417Contracts.CheckDecode(header.CbStringTable / sizeof(long) < int.MaxValue); 418Contracts.CheckDecode(header.FpStringTable + header.CbStringTable > header.FpStringTable); 419Contracts.CheckDecode(header.FpStringChars == header.FpStringTable + header.CbStringTable); 420Contracts.CheckDecode(header.CbStringChars % sizeof(char) == 0); 421Contracts.CheckDecode(header.FpStringChars + header.CbStringChars >= header.FpStringChars); 424Contracts.CheckDecode(header.FpTail == header.FpStringChars + header.CbStringChars); 432Contracts.CheckDecode(header.CbAssemblyName == 0); 439Contracts.CheckDecode(header.FpAssemblyName == header.FpModel + header.CbModel); 443Contracts.CheckDecode(header.FpAssemblyName == header.FpStringChars + header.CbStringChars); 445Contracts.CheckDecode(header.CbAssemblyName % sizeof(char) == 0); 446Contracts.CheckDecode(header.FpTail == header.FpAssemblyName + header.CbAssemblyName); 450Contracts.CheckDecode(header.FpLim == header.FpTail + sizeof(ulong)); 451Contracts.CheckDecode(size == 0 || size >= header.FpLim); 468Contracts.CheckValue(reader, nameof(reader)); 469Contracts.Check(fpMin >= 0); 503Contracts.Assert(reader.FpCur() == header.FpStringTable + fpMin); 506Contracts.Assert(cstr < int.MaxValue); 508Contracts.Assert(header.FpStringChars == reader.FpCur() - fpMin); 509Contracts.CheckDecode(offsets[cstr - 1] == header.CbStringChars); 516Contracts.CheckDecode(header.FpStringChars + offset == reader.FpCur() - fpMin); 520Contracts.CheckDecode(offsetPrev <= offset && offset <= header.CbStringChars); 521Contracts.CheckDecode(offset % sizeof(char) == 0); 523Contracts.CheckDecode(cch < int.MaxValue); 530Contracts.CheckDecode(offset == header.CbStringChars); 531Contracts.CheckDecode(header.FpStringChars + header.CbStringChars == reader.FpCur() - fpMin); 551Contracts.CheckDecode(header.FpTail == reader.FpCur() - fpMin); 554Contracts.CheckDecode(tail == TailSignatureValue, "Corrupt model file tail"); 643Contracts.Check(Utils.Size(modelSignature) == 8, "Model signature must be eight characters"); 648Contracts.Check(ch <= 0xFF);
Data\ModelLoadContext.cs (3)
78Contracts.CheckValue(rep, nameof(rep)); 104Contracts.AssertValueOrNull(ectx); 153Contracts.CheckDecode(0 <= id && id < Utils.Size(Strings));
Data\ModelLoading.cs (13)
85Contracts.CheckValue(env, nameof(env)); 119Contracts.CheckValue(env, nameof(env)); 158Contracts.CheckValue(env, nameof(env)); 169Contracts.Assert(fp == ent.Stream.Position); 180Contracts.CheckValue(env, nameof(env)); 193Contracts.CheckValue(env, nameof(env)); 204Contracts.CheckValue(env, nameof(env)); 206throw Contracts.ExceptDecode("Couldn't load model"); 216Contracts.CheckValue(env, nameof(env)); 220Contracts.Assert(fp == ctx.FpMin); 231Contracts.CheckValue(env, nameof(env)); 233throw Contracts.ExceptDecode("Couldn't load model"); 295Contracts.AssertNonEmpty(args1);
Data\ModelSaveContext.cs (2)
87Contracts.CheckValue(rep, nameof(rep)); 123Contracts.AssertValueOrNull(ectx);
Data\ModelSaving.cs (2)
63Contracts.CheckValue(writer, nameof(writer)); 64Contracts.CheckValue(fn, nameof(fn));
Data\ProgressReporter.cs (21)
52Contracts.CheckValueOrNull(ectx); 115Contracts.Assert(_subChannels.Count == 0); 133Contracts.Assert(entry.Header.MetricNames.Count == 0 && entry.Header.UnitNames.Count == 0); 161Contracts.Assert(res == channel); 233Contracts.Assert(entry.Header.MetricNames.Count == 0 && entry.Header.UnitNames.Count == 0); 241Contracts.AssertValue(root); 242Contracts.Assert(level >= 0); 352Contracts.Assert(index > 0); 353Contracts.AssertNonEmpty(name); 354Contracts.AssertValue(channel); 366Contracts.CheckValue(ectx, nameof(ectx)); 525Contracts.Check(0 <= index && index < Progress.Length); 536Contracts.Check(0 <= index && index < Progress.Length); 537Contracts.Assert(0 <= index && index < Progress.Length); 547Contracts.Check(0 <= index && index < Metrics.Length); 556Contracts.CheckValue(header, nameof(header)); 588Contracts.CheckParam(index >= 0, nameof(index)); 589Contracts.CheckNonEmpty(name, nameof(name)); 590Contracts.CheckValue(entry, nameof(entry)); 602Contracts.CheckParam(index >= 0, nameof(index)); 603Contracts.CheckNonEmpty(name, nameof(name));
Data\ReadOnlyMemoryUtils.cs (6)
23Contracts.CheckValueOrNull(s); 36Contracts.CheckValueOrNull(separators); 123Contracts.CheckValueOrNull(separators); 215Contracts.CheckValue(sb, nameof(sb)); 231Contracts.Assert(j == span.Length); 239Contracts.CheckValue(sb, nameof(sb));
Data\Repository.cs (3)
110Contracts.AssertValueOrNull(ectx); 293Contracts.CheckValueOrNull(ectx); 452Contracts.CheckValueOrNull(ectx);
Data\RoleMappedSchema.cs (38)
103Contracts.CheckNonEmpty(value, nameof(value)); 159Contracts.AssertValue(schema); 160Contracts.AssertValue(map); 166Contracts.Assert(Utils.Size(kvp.Value) > 0); 170Contracts.Assert(!schema[info.Index].IsHidden, "How did a hidden column sneak in?"); 203Contracts.AssertValue(map); 204Contracts.AssertNonEmpty(role.Value); 216Contracts.AssertValue(schema); 217Contracts.AssertValue(roles); 222Contracts.AssertNonEmpty(kvp.Key.Value); 229throw Contracts.ExceptParam(nameof(schema), $"{kvp.Value} column '{kvp.Key.Value}' not found"); 307throw Contracts.Except("Expected exactly one column with role '{0}', but found {1}.", role.Value, Utils.Size(infos)); 316Contracts.Assert(Utils.Size(kvp.Value) > 0); 334: this(Contracts.CheckRef(schema, nameof(schema)), Contracts.CheckRef(roles, nameof(roles)), opt) 349: this(Contracts.CheckRef(schema, nameof(schema)), 350MapFromNames(schema, Contracts.CheckRef(roles, nameof(roles)), opt)) 392: this(Contracts.CheckRef(schema, nameof(schema)), PredefinedRolesHelper(label, feature, group, weight, name, custom), opt) 394Contracts.CheckValueOrNull(label); 395Contracts.CheckValueOrNull(feature); 396Contracts.CheckValueOrNull(group); 397Contracts.CheckValueOrNull(weight); 398Contracts.CheckValueOrNull(name); 399Contracts.CheckValueOrNull(custom); 424Contracts.AssertValue(data); 425Contracts.AssertValue(schema); 426Contracts.Assert(schema.Schema == data.Schema); 442: this(Contracts.CheckRef(data, nameof(data)), new RoleMappedSchema(data.Schema, Contracts.CheckRef(roles, nameof(roles)), opt)) 457: this(Contracts.CheckRef(data, nameof(data)), new RoleMappedSchema(data.Schema, Contracts.CheckRef(roles, nameof(roles)), opt)) 478: this(Contracts.CheckRef(data, nameof(data)), 481Contracts.CheckValueOrNull(label); 482Contracts.CheckValueOrNull(feature); 483Contracts.CheckValueOrNull(group); 484Contracts.CheckValueOrNull(weight); 485Contracts.CheckValueOrNull(name); 486Contracts.CheckValueOrNull(custom);
Data\RootCursorBase.cs (1)
40Contracts.CheckValue(provider, nameof(provider));
Data\ServerChannel.cs (6)
44Contracts.AssertValue(provider); 61Contracts.CheckValue(provider, nameof(provider)); 175Contracts.CheckValue(env, nameof(env)); 239Contracts.AssertValue(sch); 266Contracts.CheckValue(provider, nameof(provider)); 267Contracts.CheckNonWhiteSpace(identifier, nameof(identifier));
Data\SynchronizedCursorBase.cs (1)
44Contracts.AssertValue(provider);
Data\WrappingRow.cs (1)
32Contracts.AssertValue(input);
EntryPoints\EntryPointUtils.cs (4)
37Contracts.AssertValue(range); 38Contracts.AssertValue(val); 93Contracts.CheckValue(env, nameof(env)); 108Contracts.CheckValueOrNull(ectx);
EntryPoints\ModuleArgs.cs (16)
165Contracts.Check(_inf == null, 167Contracts.Check(_max == null || ((IComparable)_max).CompareTo(value) != -1, 169Contracts.Check(_sup == null || ((IComparable)_sup).CompareTo(value) == 1, 184Contracts.Check(_sup == null, 186Contracts.Check(_min == null || ((IComparable)_min).CompareTo(value) != 1, 188Contracts.Check(_inf == null || ((IComparable)_inf).CompareTo(value) == -1, 203Contracts.Check(_min == null, 205Contracts.Check(_max == null || ((IComparable)_max).CompareTo(value) == 1, 207Contracts.Check(_sup == null || ((IComparable)_sup).CompareTo(value) == 1, 222Contracts.Check(_max == null, 224Contracts.Check(_min == null || ((IComparable)_min).CompareTo(value) == -1, 226Contracts.Check(_inf == null || ((IComparable)_inf).CompareTo(value) == -1, 234Contracts.CheckValue(val, nameof(val)); 237Contracts.Check(val is IComparable, "Type for range attribute must support IComparable"); 241Contracts.Check(_type == val.GetType(), "All Range attribute values must be of the same type"); 602Contracts.AssertValue(type);
Environment\ConsoleEnvironment.cs (33)
41Contracts.AssertValue(parent); 42Contracts.AssertValue(outWriter); 43Contracts.AssertValue(errWriter); 74Contracts.Assert(msg.Kind == ChannelMessageKind.Error); 126Contracts.Assert(commChannel.Verbose); 180Contracts.AssertValue(progressTracker); 230Contracts.Assert(ev.Kind == ProgressReporting.ProgressEvent.EventKind.Progress); 231Contracts.Assert(!ev.ProgressEntry.IsCheckpoint); 371Contracts.CheckValueOrNull(outWriter); 372Contracts.CheckValueOrNull(errWriter); 396Contracts.AssertValue(rand); 397Contracts.AssertValueOrNull(parentFullName); 398Contracts.AssertNonEmpty(shortName); 399Contracts.Assert(source == this || source is Host); 405Contracts.AssertValue(parent); 406Contracts.Assert(parent is ConsoleEnvironment); 407Contracts.AssertNonEmpty(name); 413Contracts.AssertValue(parent); 414Contracts.Assert(parent is ConsoleEnvironment); 415Contracts.AssertNonEmpty(name); 425Contracts.CheckValue(newOutWriter, nameof(newOutWriter)); 426Contracts.CheckValue(newErrWriter, nameof(newErrWriter)); 443Contracts.AssertValue(env); 444Contracts.AssertValue(newOutWriter); 445Contracts.AssertValue(newErrWriter); 449Contracts.AssertValue(_oldConsoleWriter); 457Contracts.Assert(_root._consoleWriter == _newConsoleWriter); 473Contracts.AssertValue(parent); 474Contracts.Assert(parent is Host); 475Contracts.AssertNonEmpty(name); 481Contracts.AssertValue(parent); 482Contracts.Assert(parent is Host); 483Contracts.AssertNonEmpty(name);
Environment\HostEnvironmentBase.cs (22)
46Contracts.AssertValueOrNull(parentFullName); 47Contracts.AssertValueOrNull(shortName); 72Contracts.Mark(ex); 137Contracts.CheckNonEmpty(name, nameof(name)); 171Contracts.AssertValue(parent); 172Contracts.AssertValue(dispatch); 203Contracts.Mark(ex); 392Contracts.CheckValue(source, nameof(source)); 393Contracts.CheckValueOrNull(rand); 416Contracts.CheckNonEmpty(name, nameof(name)); 440Contracts.CheckNonEmpty(name, nameof(name)); 446Contracts.AssertNonEmpty(name); 447Contracts.AssertValueOrNull(host); 454Contracts.AssertValueOrNull(listenerAction); 455Contracts.AssertValue(channel); 479Contracts.Assert(dispatcher is Dispatcher<TMessage>); 499Contracts.CheckValue(listenerFunc, nameof(listenerFunc)); 506Contracts.CheckValue(listenerFunc, nameof(listenerFunc)); 510Contracts.AssertValue(typedDispatcher); 516Contracts.AssertValueOrNull(ex); 520Contracts.Mark(ex); 564Contracts.Assert(ichMin <= ichLim);
Environment\TelemetryMessage.cs (1)
66Contracts.AssertValue(exception);
Prediction\TrainContext.cs (3)
55Contracts.CheckValue(trainingSet, nameof(trainingSet)); 56Contracts.CheckValueOrNull(validationSet); 57Contracts.CheckValueOrNull(initialPredictor);
Utilities\BigArray.cs (59)
73Contracts.CheckParam(0 <= index && index < _length, nameof(index), "Index out of range."); 80Contracts.CheckParam(0 <= index && index < _length, nameof(index), "Index out of range."); 93Contracts.Assert(BlockSize > 1 && (BlockSize & (BlockSize - 1)) == 0, "Block size is not a power of two."); 95Contracts.CheckParam(size >= 0, nameof(size), "Must be non-negative."); 102Contracts.CheckParam(size <= MaxSize, nameof(size), "Size of BigArray is too large."); 104Contracts.Assert(longBlockCount <= Utils.ArrayMaxSize); 107Contracts.Assert(blockCount > 0); 108Contracts.Assert(0 < lastBlockSize && lastBlockSize <= BlockSize); 124Contracts.CheckValue(manip, nameof(manip)); 125Contracts.CheckParam(0 <= index && index < _length, nameof(index), "Index out of range."); 137Contracts.CheckValue(manip, nameof(manip)); 138Contracts.CheckParam(min >= 0, nameof(min), "Specified minimum index must be non-negative."); 139Contracts.CheckParam(lim <= _length, nameof(lim), "Specified limit index must be no more than length of the array."); 157Contracts.Assert(index == lim); 165Contracts.CheckParam(min >= 0, nameof(min), "Specified minimum index must be non-negative."); 166Contracts.CheckParam(lim <= _length, nameof(lim), "Specified limit index must be no more than length of the array."); 192Contracts.Assert(index == lim); 211Contracts.CheckParam(newLength >= 0, nameof(newLength), "Specified new size must be non-negative."); 212Contracts.CheckParam(newLength <= MaxSize, nameof(newLength), "Specified new size is too large."); 226Contracts.Assert(0 < longBlockCount && longBlockCount <= Utils.ArrayMaxSize); 229Contracts.Assert(0 < newLastBlockLength && newLastBlockLength <= BlockSize); 243Contracts.Assert(curBlockCount > 0); 246Contracts.Assert(0 < curLastBlockLength && curLastBlockLength <= curLastBlockSize && curLastBlockSize <= BlockSize); 251Contracts.Assert(newBlockCount < curBlockCount || (newBlockCount == curBlockCount && newLastBlockLength < curLastBlockLength)); 259Contracts.Assert(curBlockCount == newBlockCount); 264Contracts.Assert(_length == curLastBlockLength); 265Contracts.Assert(newLength == newLastBlockLength); 266Contracts.Assert(_entries.Length == 1); 279Contracts.Assert(newBlockCount > curBlockCount); 296Contracts.Assert(Utils.Size(_entries) == 0); 303Contracts.Assert(maMax >= 0); 304Contracts.Assert(0 < miLim && miLim <= Utils.Size(_entries[maMax])); 331Contracts.Assert(maMin <= maMax); // Could be violated if length == 0, but we already took care of this. 337Contracts.Assert(miLim - miMin == src.Length); 343Contracts.Assert((BlockSize - miMin) + miLim == src.Length); 347Contracts.Assert(_entries[maMax] == null); 362Contracts.Assert(_entries[major] == null); 366Contracts.Assert(srcSoFar < src.Length); 369Contracts.Assert(src.Length - srcSoFar == miLim); 370Contracts.Assert(_entries[maMax] == null); 389Contracts.Assert(0 <= length && length <= dst.Length); 390Contracts.Assert(idx <= Length && length <= Length - idx); 401Contracts.Assert(maMin <= maMax); // Could happen if length == 0, but we already took care of this. 406Contracts.Assert(miLim - miMin == length); 407Contracts.Assert(miLim <= Utils.Size(_entries[maMax])); 412Contracts.Assert((BlockSize - miMin) + miLim == length); 413Contracts.Assert(BlockSize <= Utils.Size(_entries[maMin])); 415Contracts.Assert(miLim <= Utils.Size(_entries[maMax])); 423Contracts.Assert(BlockSize <= Utils.Size(_entries[maMin])); 429Contracts.Assert(BlockSize <= Utils.Size(_entries[major])); 432Contracts.Assert(dstSoFar < length); 435Contracts.Assert(length - dstSoFar == miLim); 436Contracts.Assert(miLim <= Utils.Size(_entries[maMax])); 444Contracts.Assert(min >= 0); 445Contracts.Assert((min >> BlockSizeBits) < int.MaxValue); 448Contracts.Assert((long)major * BlockSize + minor == min); 453Contracts.Assert(lim > 0); 454Contracts.Assert((lim >> BlockSizeBits) < int.MaxValue); 458Contracts.Assert((long)major * BlockSize + minor == lim + 1);
Utilities\BinFinder.cs (60)
30Contracts.Check(cbin >= 2); 31Contracts.Check(numZeroes >= 0); 51Contracts.Assert(numValues == values.Count + 1); 88Contracts.Assert(_path[0] == 0); 89Contracts.Assert(_path[CountBins] == CountValues); 99Contracts.Assert(bounds[i] > bounds[i - 1]); 108Contracts.Check(cbin >= 2); 109Contracts.Check(numZeroes >= 0); 129Contracts.Assert(numValues == values.Count + 1); 166Contracts.Assert(_path[0] == 0); 167Contracts.Assert(_path[CountBins] == CountValues); 177Contracts.Assert(bounds[i] > bounds[i - 1]); 185Contracts.Check(cbin >= 2); 186Contracts.Check(numValues > cbin); 187Contracts.Check(counts.Count >= numValues); 188Contracts.Check(path.Length >= cbin + 1); 203Contracts.Assert(path[0] == 0); 204Contracts.Assert(path[CountBins] == CountValues); 216Contracts.Assert(a < b); 232Contracts.Assert(a <= ave); 245Contracts.Assert(a < b); 261Contracts.Assert(a <= ave); 331Contracts.Assert(CountValues > CountBins); 332Contracts.Assert(counts.Count == CountValues); 333Contracts.Assert(path.Length >= CountBins + 1); 362Contracts.Assert(_segmentHeap.Count > 0); 373Contracts.Assert(_path[0] == 0); 374Contracts.Assert(_path[CountBins] == CountValues); 391Contracts.Assert(min < max - 1); 434Contracts.Assert(0 <= min && min < split && split < max && max <= CountValues); 442Contracts.Assert(a < b && b < c); 482Contracts.Assert(peg.Energy >= 0); 491Contracts.Assert(pegs[peg.Index] == peg); 492Contracts.Assert(_path[peg.Index] != peg.Split); 495Contracts.Assert(FindSplitPosition(out e, _path[peg.Index - 1], _path[peg.Index + 1], peg.Index) == peg.Split); 520Contracts.Assert(peg.Energy >= 0); 568Contracts.Assert(CountBins >= 2); 569Contracts.Assert(CountValues > CountBins); 570Contracts.Assert(counts.Count == CountValues); 571Contracts.Assert(path.Length >= CountBins + 1); 611Contracts.Assert(bestWorst < EnergyType.MaxValue); 618Contracts.Assert(ccol > 0); 628Contracts.Assert(ivBase == (row - 1) * width); 651Contracts.Assert(eBest > 0); 652Contracts.Assert(0 <= colBest && colBest <= col); 665Contracts.Assert(bestWorst < EnergyType.MaxValue); 673Contracts.Assert(ccol > 0); 677Contracts.Assert(height + width == CountValues); 691Contracts.Assert(eBest < EnergyType.MaxValue); 695Contracts.Assert(height == CountBins - 1); 704Contracts.Assert(ivBase == (row - 1) * width); 706Contracts.Assert(_pathInfo[ivBase + colBest] <= colBest); 709Contracts.Assert(_path[row] < _path[row + 1]); 711Contracts.Assert(ivBase == 0); 716Contracts.Assert(d > 0); 730Contracts.Assert(0 <= row && row < CountBins - 1); 731Contracts.Assert(0 <= col && col <= _cskip); 738Contracts.Assert(0 < cbin && cbin <= span); 744Contracts.Assert(0 <= rem && rem < cbin); 755Contracts.Assert(worst >= best);
Utilities\BitUtils.cs (3)
177Contracts.Assert(0 <= ibit && ibit < CbitUint, "UMaskBelow is designed to work for 0 <= ibit < 32"); 184Contracts.Assert(0 <= ibit && ibit < CbitUlong, "UMaskBelowEx is designed to work for 0 <= ibit < 64"); 193Contracts.Assert(0 <= ibit && ibit < CbitUlong, "UuMaskBelow is designed to work for 0 <= ibit < 64");
Utilities\Contracts.cs (1)
74Contracts.Assert(false, "Format string arg mismatch: " + ex.Message);
Utilities\DoubleParser.cs (34)
94Contracts.Assert(res != Result.Empty || ((flags & OptionFlags.EmptyAsNaN) == 0 && value == 0) || Single.IsNaN(value)); 104Contracts.Assert(res != Result.Empty || ((flags & OptionFlags.EmptyAsNaN) == 0 && value == 0) || Double.IsNaN(value)); 340Contracts.Assert((long)(Double)(long)num == (long)num); 360Contracts.Assert((long)(Double)(long)num == (long)num); 390Contracts.Assert((num & TopTwoBits) != 0); 391Contracts.Assert((mul & TopBit) != 0); 413Contracts.Assert((num & TopThreeBits) != 0); 433Contracts.Assert(exp > 0); 440Contracts.Assert(exp < 0); 444Contracts.Assert(e2 > 0); 448Contracts.Assert(0 < e2 && e2 < 0x7FF); 551Contracts.Assert(0 <= ich && ich <= span.Length); 552Contracts.Assert(!neg); 553Contracts.Assert(num == 0); 554Contracts.Assert(exp == 0); 616Contracts.Assert(i < span.Length); 632Contracts.Assert(i < span.Length); 638Contracts.Assert(i < span.Length); 639Contracts.Assert(span[i] == decimalMarker); 651Contracts.Assert(i < span.Length); 664Contracts.Assert(i < span.Length); 686Contracts.Assert(i < span.Length); 705Contracts.Assert(Math.Abs(exp) < int.MaxValue); 711Contracts.Assert(i < span.Length); 934Contracts.Assert(_mpe10Man.Length == _mpe10e2.Length); 935Contracts.Assert(_mpne10Man.Length == _mpne10ne2.Length); 939Contracts.Assert(_mpe10Dbl.Length <= _mpe10Man.Length); 952Contracts.Assert(0 < e2 && e2 < 0x7FF); 957Contracts.Assert((Single)_mpe10Dbl[_mpe10Dbl.Length - 1] == Single.PositiveInfinity); 958Contracts.Assert((Single)_mpe10Dbl[_mpe10Dbl.Length - 2] < Single.PositiveInfinity); 963Contracts.Assert(_mpne10Dbl.Length <= _mpne10Man.Length); 968Contracts.Assert(0 < e2 && e2 < 0x7FF); 975Contracts.Assert((Single)(_mpne10Dbl[_mpne10Dbl.Length - 1] * two64) == 0); 976Contracts.Assert((Single)(_mpne10Dbl[_mpne10Dbl.Length - 2] * two64) > 0);
Utilities\FixedSizeQueue.cs (9)
25Contracts.Assert(capacity > 0, "Array capacity should be greater than zero"); 33Contracts.Assert(Utils.Size(_array) >= 0); 34Contracts.Assert(0 <= _startIndex && _startIndex < _array.Length); 35Contracts.Assert(0 <= _count && _count <= _array.Length); 70Contracts.Assert(index >= 0 && index < _count); 96Contracts.Assert(_count != 0, "Array is empty"); 103Contracts.Assert(_count != 0, "Array is empty"); 110Contracts.Assert(_count != 0, "Array is empty"); 122Contracts.Assert(_count != 0, "Array is empty");
Utilities\FloatUtils.cs (8)
65Contracts.Assert(-RawExpZero < exp && exp < RawExpInf - RawExpZero); 109Contracts.Assert((man & ~MaskMan) == MaskMan + 1); 132Contracts.Assert(Bits != 0); 159Contracts.Assert(IsFiniteNormal()); 258Contracts.Assert(-RawExpZero < exp && exp < RawExpInf - RawExpZero); 302Contracts.Assert((man & ~MaskMan) == MaskMan + 1); 325Contracts.Assert(Bits != 0); 352Contracts.Assert(IsFiniteNormal());
Utilities\FuncInstanceMethodInfo1`2.cs (18)
39Contracts.CheckParam(!GenericMethodDefinition.IsStatic, nameof(methodInfo), "Should be an instance method"); 40Contracts.CheckParam(GenericMethodDefinition.DeclaringType == typeof(TTarget), nameof(methodInfo), _targetTypeCheckMessage); 60throw Contracts.ExceptParam(nameof(expression), "Unexpected expression form"); 64Contracts.CheckParam(methodCallExpression.Method.DeclaringType == typeof(MethodInfo), nameof(expression), "Unexpected expression form"); 65Contracts.CheckParam(methodCallExpression.Method.Name == nameof(MethodInfo.CreateDelegate), nameof(expression), "Unexpected expression form"); 66Contracts.CheckParam(methodCallExpression.Method.GetParameters().Length == 2, nameof(expression), "Unexpected expression form"); 67Contracts.CheckParam(methodCallExpression.Method.GetParameters()[0].ParameterType == typeof(Type), nameof(expression), "Unexpected expression form"); 68Contracts.CheckParam(methodCallExpression.Method.GetParameters()[1].ParameterType == typeof(object), nameof(expression), "Unexpected expression form"); 71Contracts.CheckParam(methodCallExpression.Arguments.Count == 2, nameof(expression), "Unexpected expression form"); 72Contracts.CheckParam(methodCallExpression.Arguments[0] is ConstantExpression, nameof(expression), "Unexpected expression form"); 73Contracts.CheckParam(((ConstantExpression)methodCallExpression.Arguments[0]).Type == typeof(Type), nameof(expression), "Unexpected expression form"); 74Contracts.CheckParam((Type)((ConstantExpression)methodCallExpression.Arguments[0]).Value == typeof(Func<TResult>), nameof(expression), "Unexpected expression form"); 75Contracts.CheckParam(methodCallExpression.Arguments[1] is ParameterExpression, nameof(expression), "Unexpected expression form"); 76Contracts.CheckParam(methodCallExpression.Arguments[1] == expression.Parameters[0], nameof(expression), "Unexpected expression form"); 79Contracts.CheckParam(methodCallExpression.Object is ConstantExpression, nameof(expression), "Unexpected expression form"); 80Contracts.CheckParam(((ConstantExpression)methodCallExpression.Object).Type == typeof(MethodInfo), nameof(expression), "Unexpected expression form"); 83Contracts.CheckParam(expression.Body is UnaryExpression, nameof(expression), "Unexpected expression form"); 84Contracts.CheckParam(((UnaryExpression)expression.Body).Operand is MethodCallExpression, nameof(expression), "Unexpected expression form");
Utilities\FuncInstanceMethodInfo1`3.cs (18)
40Contracts.CheckParam(!GenericMethodDefinition.IsStatic, nameof(methodInfo), "Should be an instance method"); 41Contracts.CheckParam(GenericMethodDefinition.DeclaringType == typeof(TTarget), nameof(methodInfo), _targetTypeCheckMessage); 61throw Contracts.ExceptParam(nameof(expression), "Unexpected expression form"); 65Contracts.CheckParam(methodCallExpression.Method.DeclaringType == typeof(MethodInfo), nameof(expression), "Unexpected expression form"); 66Contracts.CheckParam(methodCallExpression.Method.Name == nameof(MethodInfo.CreateDelegate), nameof(expression), "Unexpected expression form"); 67Contracts.CheckParam(methodCallExpression.Method.GetParameters().Length == 2, nameof(expression), "Unexpected expression form"); 68Contracts.CheckParam(methodCallExpression.Method.GetParameters()[0].ParameterType == typeof(Type), nameof(expression), "Unexpected expression form"); 69Contracts.CheckParam(methodCallExpression.Method.GetParameters()[1].ParameterType == typeof(object), nameof(expression), "Unexpected expression form"); 72Contracts.CheckParam(methodCallExpression.Arguments.Count == 2, nameof(expression), "Unexpected expression form"); 73Contracts.CheckParam(methodCallExpression.Arguments[0] is ConstantExpression, nameof(expression), "Unexpected expression form"); 74Contracts.CheckParam(((ConstantExpression)methodCallExpression.Arguments[0]).Type == typeof(Type), nameof(expression), "Unexpected expression form"); 75Contracts.CheckParam((Type)((ConstantExpression)methodCallExpression.Arguments[0]).Value == typeof(Func<T, TResult>), nameof(expression), "Unexpected expression form"); 76Contracts.CheckParam(methodCallExpression.Arguments[1] is ParameterExpression, nameof(expression), "Unexpected expression form"); 77Contracts.CheckParam(methodCallExpression.Arguments[1] == expression.Parameters[0], nameof(expression), "Unexpected expression form"); 80Contracts.CheckParam(methodCallExpression.Object is ConstantExpression, nameof(expression), "Unexpected expression form"); 81Contracts.CheckParam(((ConstantExpression)methodCallExpression.Object).Type == typeof(MethodInfo), nameof(expression), "Unexpected expression form"); 84Contracts.CheckParam(expression.Body is UnaryExpression, nameof(expression), "Unexpected expression form"); 85Contracts.CheckParam(((UnaryExpression)expression.Body).Operand is MethodCallExpression, nameof(expression), "Unexpected expression form");
Utilities\FuncInstanceMethodInfo1`4.cs (18)
41Contracts.CheckParam(!GenericMethodDefinition.IsStatic, nameof(methodInfo), "Should be an instance method"); 42Contracts.CheckParam(GenericMethodDefinition.DeclaringType == typeof(TTarget), nameof(methodInfo), _targetTypeCheckMessage); 62throw Contracts.ExceptParam(nameof(expression), "Unexpected expression form"); 66Contracts.CheckParam(methodCallExpression.Method.DeclaringType == typeof(MethodInfo), nameof(expression), "Unexpected expression form"); 67Contracts.CheckParam(methodCallExpression.Method.Name == nameof(MethodInfo.CreateDelegate), nameof(expression), "Unexpected expression form"); 68Contracts.CheckParam(methodCallExpression.Method.GetParameters().Length == 2, nameof(expression), "Unexpected expression form"); 69Contracts.CheckParam(methodCallExpression.Method.GetParameters()[0].ParameterType == typeof(Type), nameof(expression), "Unexpected expression form"); 70Contracts.CheckParam(methodCallExpression.Method.GetParameters()[1].ParameterType == typeof(object), nameof(expression), "Unexpected expression form"); 73Contracts.CheckParam(methodCallExpression.Arguments.Count == 2, nameof(expression), "Unexpected expression form"); 74Contracts.CheckParam(methodCallExpression.Arguments[0] is ConstantExpression, nameof(expression), "Unexpected expression form"); 75Contracts.CheckParam(((ConstantExpression)methodCallExpression.Arguments[0]).Type == typeof(Type), nameof(expression), "Unexpected expression form"); 76Contracts.CheckParam((Type)((ConstantExpression)methodCallExpression.Arguments[0]).Value == typeof(Func<T1, T2, TResult>), nameof(expression), "Unexpected expression form"); 77Contracts.CheckParam(methodCallExpression.Arguments[1] is ParameterExpression, nameof(expression), "Unexpected expression form"); 78Contracts.CheckParam(methodCallExpression.Arguments[1] == expression.Parameters[0], nameof(expression), "Unexpected expression form"); 81Contracts.CheckParam(methodCallExpression.Object is ConstantExpression, nameof(expression), "Unexpected expression form"); 82Contracts.CheckParam(((ConstantExpression)methodCallExpression.Object).Type == typeof(MethodInfo), nameof(expression), "Unexpected expression form"); 85Contracts.CheckParam(expression.Body is UnaryExpression, nameof(expression), "Unexpected expression form"); 86Contracts.CheckParam(((UnaryExpression)expression.Body).Operand is MethodCallExpression, nameof(expression), "Unexpected expression form");
Utilities\FuncInstanceMethodInfo2`4.cs (18)
41Contracts.CheckParam(!GenericMethodDefinition.IsStatic, nameof(methodInfo), "Should be an instance method"); 42Contracts.CheckParam(GenericMethodDefinition.DeclaringType == typeof(TTarget), nameof(methodInfo), _targetTypeCheckMessage); 62throw Contracts.ExceptParam(nameof(expression), "Unexpected expression form"); 66Contracts.CheckParam(methodCallExpression.Method.DeclaringType == typeof(MethodInfo), nameof(expression), "Unexpected expression form"); 67Contracts.CheckParam(methodCallExpression.Method.Name == nameof(MethodInfo.CreateDelegate), nameof(expression), "Unexpected expression form"); 68Contracts.CheckParam(methodCallExpression.Method.GetParameters().Length == 2, nameof(expression), "Unexpected expression form"); 69Contracts.CheckParam(methodCallExpression.Method.GetParameters()[0].ParameterType == typeof(Type), nameof(expression), "Unexpected expression form"); 70Contracts.CheckParam(methodCallExpression.Method.GetParameters()[1].ParameterType == typeof(object), nameof(expression), "Unexpected expression form"); 73Contracts.CheckParam(methodCallExpression.Arguments.Count == 2, nameof(expression), "Unexpected expression form"); 74Contracts.CheckParam(methodCallExpression.Arguments[0] is ConstantExpression, nameof(expression), "Unexpected expression form"); 75Contracts.CheckParam(((ConstantExpression)methodCallExpression.Arguments[0]).Type == typeof(Type), nameof(expression), "Unexpected expression form"); 76Contracts.CheckParam((Type)((ConstantExpression)methodCallExpression.Arguments[0]).Value == typeof(Func<T1, T2, TResult>), nameof(expression), "Unexpected expression form"); 77Contracts.CheckParam(methodCallExpression.Arguments[1] is ParameterExpression, nameof(expression), "Unexpected expression form"); 78Contracts.CheckParam(methodCallExpression.Arguments[1] == expression.Parameters[0], nameof(expression), "Unexpected expression form"); 81Contracts.CheckParam(methodCallExpression.Object is ConstantExpression, nameof(expression), "Unexpected expression form"); 82Contracts.CheckParam(((ConstantExpression)methodCallExpression.Object).Type == typeof(MethodInfo), nameof(expression), "Unexpected expression form"); 85Contracts.CheckParam(expression.Body is UnaryExpression, nameof(expression), "Unexpected expression form"); 86Contracts.CheckParam(((UnaryExpression)expression.Body).Operand is MethodCallExpression, nameof(expression), "Unexpected expression form");
Utilities\FuncInstanceMethodInfo3`3.cs (18)
40Contracts.CheckParam(!GenericMethodDefinition.IsStatic, nameof(methodInfo), "Should be an instance method"); 41Contracts.CheckParam(GenericMethodDefinition.DeclaringType == typeof(TTarget), nameof(methodInfo), _targetTypeCheckMessage); 61throw Contracts.ExceptParam(nameof(expression), "Unexpected expression form"); 65Contracts.CheckParam(methodCallExpression.Method.DeclaringType == typeof(MethodInfo), nameof(expression), "Unexpected expression form"); 66Contracts.CheckParam(methodCallExpression.Method.Name == nameof(MethodInfo.CreateDelegate), nameof(expression), "Unexpected expression form"); 67Contracts.CheckParam(methodCallExpression.Method.GetParameters().Length == 2, nameof(expression), "Unexpected expression form"); 68Contracts.CheckParam(methodCallExpression.Method.GetParameters()[0].ParameterType == typeof(Type), nameof(expression), "Unexpected expression form"); 69Contracts.CheckParam(methodCallExpression.Method.GetParameters()[1].ParameterType == typeof(object), nameof(expression), "Unexpected expression form"); 72Contracts.CheckParam(methodCallExpression.Arguments.Count == 2, nameof(expression), "Unexpected expression form"); 73Contracts.CheckParam(methodCallExpression.Arguments[0] is ConstantExpression, nameof(expression), "Unexpected expression form"); 74Contracts.CheckParam(((ConstantExpression)methodCallExpression.Arguments[0]).Type == typeof(Type), nameof(expression), "Unexpected expression form"); 75Contracts.CheckParam((Type)((ConstantExpression)methodCallExpression.Arguments[0]).Value == typeof(Func<T, TResult>), nameof(expression), "Unexpected expression form"); 76Contracts.CheckParam(methodCallExpression.Arguments[1] is ParameterExpression, nameof(expression), "Unexpected expression form"); 77Contracts.CheckParam(methodCallExpression.Arguments[1] == expression.Parameters[0], nameof(expression), "Unexpected expression form"); 80Contracts.CheckParam(methodCallExpression.Object is ConstantExpression, nameof(expression), "Unexpected expression form"); 81Contracts.CheckParam(((ConstantExpression)methodCallExpression.Object).Type == typeof(MethodInfo), nameof(expression), "Unexpected expression form"); 84Contracts.CheckParam(expression.Body is UnaryExpression, nameof(expression), "Unexpected expression form"); 85Contracts.CheckParam(((UnaryExpression)expression.Body).Operand is MethodCallExpression, nameof(expression), "Unexpected expression form");
Utilities\FuncInstanceMethodInfo3`4.cs (18)
41Contracts.CheckParam(!GenericMethodDefinition.IsStatic, nameof(methodInfo), "Should be an instance method"); 42Contracts.CheckParam(GenericMethodDefinition.DeclaringType == typeof(TTarget), nameof(methodInfo), _targetTypeCheckMessage); 62throw Contracts.ExceptParam(nameof(expression), "Unexpected expression form"); 66Contracts.CheckParam(methodCallExpression.Method.DeclaringType == typeof(MethodInfo), nameof(expression), "Unexpected expression form"); 67Contracts.CheckParam(methodCallExpression.Method.Name == nameof(MethodInfo.CreateDelegate), nameof(expression), "Unexpected expression form"); 68Contracts.CheckParam(methodCallExpression.Method.GetParameters().Length == 2, nameof(expression), "Unexpected expression form"); 69Contracts.CheckParam(methodCallExpression.Method.GetParameters()[0].ParameterType == typeof(Type), nameof(expression), "Unexpected expression form"); 70Contracts.CheckParam(methodCallExpression.Method.GetParameters()[1].ParameterType == typeof(object), nameof(expression), "Unexpected expression form"); 73Contracts.CheckParam(methodCallExpression.Arguments.Count == 2, nameof(expression), "Unexpected expression form"); 74Contracts.CheckParam(methodCallExpression.Arguments[0] is ConstantExpression, nameof(expression), "Unexpected expression form"); 75Contracts.CheckParam(((ConstantExpression)methodCallExpression.Arguments[0]).Type == typeof(Type), nameof(expression), "Unexpected expression form"); 76Contracts.CheckParam((Type)((ConstantExpression)methodCallExpression.Arguments[0]).Value == typeof(Func<T1, T2, TResult>), nameof(expression), "Unexpected expression form"); 77Contracts.CheckParam(methodCallExpression.Arguments[1] is ParameterExpression, nameof(expression), "Unexpected expression form"); 78Contracts.CheckParam(methodCallExpression.Arguments[1] == expression.Parameters[0], nameof(expression), "Unexpected expression form"); 81Contracts.CheckParam(methodCallExpression.Object is ConstantExpression, nameof(expression), "Unexpected expression form"); 82Contracts.CheckParam(((ConstantExpression)methodCallExpression.Object).Type == typeof(MethodInfo), nameof(expression), "Unexpected expression form"); 85Contracts.CheckParam(expression.Body is UnaryExpression, nameof(expression), "Unexpected expression form"); 86Contracts.CheckParam(((UnaryExpression)expression.Body).Operand is MethodCallExpression, nameof(expression), "Unexpected expression form");
Utilities\FuncMethodInfo`1.cs (3)
16Contracts.CheckValue(methodInfo, nameof(methodInfo)); 17Contracts.CheckParam(methodInfo.IsGenericMethod, nameof(methodInfo), "Should be generic but is not"); 20Contracts.CheckParam(typeof(TResult).IsAssignableFrom(GenericMethodDefinition.ReturnType), nameof(methodInfo), "Cannot be generic on return type");
Utilities\FuncMethodInfo`2.cs (3)
16Contracts.CheckValue(methodInfo, nameof(methodInfo)); 18Contracts.CheckParam(methodInfo.IsGenericMethod, nameof(methodInfo), "Should be generic but is not"); 21Contracts.CheckParam(typeof(TResult).IsAssignableFrom(GenericMethodDefinition.ReturnType), nameof(methodInfo), "Cannot be generic on return type");
Utilities\FuncMethodInfo`3.cs (3)
16Contracts.CheckValue(methodInfo, nameof(methodInfo)); 18Contracts.CheckParam(methodInfo.IsGenericMethod, nameof(methodInfo), "Should be generic but is not"); 21Contracts.CheckParam(typeof(TResult).IsAssignableFrom(GenericMethodDefinition.ReturnType), nameof(methodInfo), "Cannot be generic on return type");
Utilities\FuncMethodInfo1`1.cs (1)
33Contracts.CheckParam(GenericMethodDefinition.GetGenericArguments().Length == 1, nameof(methodInfo),
Utilities\FuncMethodInfo1`2.cs (1)
34Contracts.CheckParam(GenericMethodDefinition.GetGenericArguments().Length == 1, nameof(methodInfo),
Utilities\FuncMethodInfo1`3.cs (1)
35Contracts.CheckParam(GenericMethodDefinition.GetGenericArguments().Length == 1, nameof(methodInfo),
Utilities\FuncMethodInfo2`3.cs (1)
35Contracts.CheckParam(GenericMethodDefinition.GetGenericArguments().Length == 2, nameof(methodInfo),
Utilities\FuncMethodInfo3`2.cs (1)
34Contracts.CheckParam(GenericMethodDefinition.GetGenericArguments().Length == 3, nameof(methodInfo),
Utilities\FuncMethodInfo3`3.cs (1)
35Contracts.CheckParam(GenericMethodDefinition.GetGenericArguments().Length == 3, nameof(methodInfo),
Utilities\FuncStaticMethodInfo1`1.cs (1)
29Contracts.CheckParam(GenericMethodDefinition.IsStatic, nameof(function), "Should be a static method");
Utilities\FuncStaticMethodInfo1`2.cs (1)
30Contracts.CheckParam(GenericMethodDefinition.IsStatic, nameof(function), "Should be a static method");
Utilities\FuncStaticMethodInfo1`3.cs (1)
31Contracts.CheckParam(GenericMethodDefinition.IsStatic, nameof(function), "Should be a static method");
Utilities\FuncStaticMethodInfo2`3.cs (1)
31Contracts.CheckParam(GenericMethodDefinition.IsStatic, nameof(function), "Should be a static method");
Utilities\FuncStaticMethodInfo3`2.cs (1)
30Contracts.CheckParam(GenericMethodDefinition.IsStatic, nameof(function), "Should be a static method");
Utilities\FuncStaticMethodInfo3`3.cs (1)
31Contracts.CheckParam(GenericMethodDefinition.IsStatic, nameof(function), "Should be a static method");
Utilities\HashArray.cs (17)
62Contracts.AssertValue(_rgit); 63Contracts.AssertNonEmpty(_rgit); 65Contracts.Assert(0 <= _ct && _ct <= Utils.Size(_entries)); 69Contracts.Assert(Utils.Size(_rgit) >= _ct || Utils.Size(_rgit) == HashHelpers.MaxPrimeArrayLength); 79Contracts.Assert(0 <= it && it < _ct); 91Contracts.Assert(val != null); 100Contracts.Assert(0 <= iit && iit < _rgit.Length); 104Contracts.Assert(it < _ct); 110Contracts.Assert(it == -1); 150Contracts.Assert(val != null); 151Contracts.Assert(0 <= iit && iit < _rgit.Length); 155Contracts.Assert(_ct == Utils.Size(_entries)); 158Contracts.Assert(_ct < _entries.Length); 178Contracts.Assert(size >= _rgit.Length); 237Contracts.Check(destination.Length >= _ct); 262Contracts.Assert(0 <= min && min < MaxPrimeArrayLength); 271Contracts.Assert(false);
Utilities\Hashing.cs (27)
79Contracts.AssertValue(sb); 128Contracts.Assert((bits & 0x7) == 0); 129Contracts.Assert((uint)bits <= 24); 130Contracts.Assert(cur <= 0x00FFFFFF); 145Contracts.Assert(ch <= 0xFFFF); 158Contracts.Assert((bits & 0x7) == 0); 159Contracts.Assert((uint)bits <= 24); 160Contracts.Assert(cur <= 0x00FFFFFF); 194Contracts.Assert((bits & 0x7) == 0); 195Contracts.Assert((uint)bits <= 24); 196Contracts.Assert(cur <= 0x00FFFFFF); 218Contracts.Assert(ch <= 0x10FFFF); 232Contracts.Assert((bits & 0x7) == 0); 233Contracts.Assert((uint)bits <= 24); 234Contracts.Assert(cur <= 0x00FFFFFF); 277Contracts.Assert(0 <= ichMin && ichMin <= ichLim && ichLim <= Utils.Size(data)); 289Contracts.Assert((bits & 0x7) == 0); 290Contracts.Assert((uint)bits <= 24); 291Contracts.Assert(cur <= 0x00FFFFFF); 306Contracts.Assert(ch <= 0xFFFF); 319Contracts.Assert((bits & 0x7) == 0); 320Contracts.Assert((uint)bits <= 24); 321Contracts.Assert(cur <= 0x00FFFFFF); 335Contracts.Assert(hash == MurmurHash(seed, data.ToString().AsSpan())); 344Contracts.Check(0 <= min); 345Contracts.Check(min <= lim); 346Contracts.Check(lim <= Utils.Size(data));
Utilities\Heap.cs (31)
29Contracts.AssertValue(fnReverse); 46Contracts.AssertValue(fnReverse); 47Contracts.Assert(capacity >= 0); 59Contracts.AssertValue(_fnReverse); 60Contracts.AssertValue(_rgv); 61Contracts.Assert(_rgv.Count > 0); 103Contracts.Assert(iv > 0); 141Contracts.Check(cv > 1); 170Contracts.Assert(0 < iv && iv < _rgv.Count); 181Contracts.Assert(0 < iv && iv < _rgv.Count); 208Contracts.Assert(!InHeap); 229Contracts.AssertValue(fnReverse); 246Contracts.AssertValue(fnReverse); 247Contracts.Assert(capacity >= 0); 259Contracts.AssertValue(_fnReverse); 260Contracts.AssertValue(_rgv); 261Contracts.Assert(_rgv.Count > 0); 303Contracts.Assert(iv > 0); 311Contracts.Assert(0 < index && index < _rgv.Count); 313Contracts.Assert(result._index == index); 355Contracts.Check(iv > 0); 368Contracts.Assert(!vRes.InHeap); 380Contracts.AssertValue(item); 381Contracts.Check(!item.InHeap); 397Contracts.AssertValue(item); 398Contracts.Check(item.InHeap); 401Contracts.Check(Get(ivDst) == item); 404Contracts.Assert(ivSrc >= ivDst); 416Contracts.Assert(!item.InHeap); 421Contracts.Assert(0 < iv && iv < _rgv.Count); 432Contracts.Assert(0 < iv && iv < _rgv.Count);
Utilities\HybridMemoryStream.cs (23)
53throw Contracts.ExceptParam(nameof(maxLen), "must be in range [0,{0}]", Utils.ArrayMaxSize); 70Contracts.CheckValue(stream, nameof(stream)); 71Contracts.CheckParam(stream.CanRead, nameof(stream), "Cannot copy a stream we cannot read"); 73throw Contracts.ExceptParam(nameof(maxLen), "must be in range [0,{0}]", Utils.ArrayMaxSize); 79Contracts.CheckParam(stream.Position == 0, nameof(stream), "Should be at the head of the stream"); 100Contracts.Assert(_memStream == null); 101Contracts.Assert(_overflowStream == null); 105Contracts.Assert((_memStream == null) != (_overflowStream == null)); 106Contracts.Assert(Length <= _overflowBoundary || _overflowStream != null); 156Contracts.Check(!_disposed, "Stream already disposed"); 159Contracts.Assert(_memStream != null); 163Contracts.Check(_memStream.CanRead, "attempt to perform operation on closed stream"); 175Contracts.Assert(tmp, "TryGetBuffer failed in HybridMemoryStream"); 187Contracts.CheckParam(0 <= value, nameof(value), "cannot be negative"); 189Contracts.Check(!_disposed, "Stream already disposed"); 199Contracts.Check(!_disposed, "Stream already disposed"); 206Contracts.Check(!_disposed, "Stream already disposed"); 213Contracts.Check(!_disposed, "Stream already disposed"); 214Contracts.CheckValue(buffer, nameof(buffer)); 215Contracts.CheckParam(0 <= offset && offset <= buffer.Length, nameof(offset)); 216Contracts.CheckParam(0 <= count && count <= buffer.Length - offset, nameof(count)); 226Contracts.Check(!_disposed, "Stream already disposed"); 233Contracts.Check(!_disposed, "Stream already disposed");
Utilities\LruCache.cs (3)
33Contracts.CheckParam(size > 0, nameof(size), "Must be positive"); 47Contracts.Assert(key.GetHashCode() == node.Value.Key.GetHashCode()); 64Contracts.Assert(!_cache.ContainsKey(key));
Utilities\MathUtils.cs (40)
26Contracts.Assert(false, "Bad use of ToFloat"); 27throw Contracts.Except(); 59Contracts.CheckValue(x, nameof(x)); 60Contracts.CheckValue(y, nameof(y)); 61Contracts.Check(x.Length == y.Length, "Input and output must be same length."); 98Contracts.AssertValue(a); 112Contracts.AssertValue(a); 126Contracts.AssertValue(a); 285Contracts.Assert(FloatUtils.IsFinite(maxRelErr)); 286Contracts.Assert(FloatUtils.IsFinite(maxAbsError)); 307Contracts.CheckParam(x > 0, nameof(x), "LogGamma invalid for x <= 0"); 350Contracts.CheckParam(n >= 0, nameof(n), "LogFactorial is invalid for n < 0."); 379Contracts.CheckParam(df > 0, nameof(df), "Degrees of freedom must be positive"); 405Contracts.AssertValue(a); 406Contracts.AssertValue(b); 407Contracts.Assert(tol > 0); 436Contracts.Assert(0 <= x && x <= 1); 437Contracts.Assert(0 < a); 438Contracts.Assert(0 < b); 545Contracts.Assert(0 <= exp && exp < ExpInf); 572Contracts.Assert(0 <= n && n < ExpInf); 574Contracts.Assert(0 <= f && f < 1); 578Contracts.Assert(1 <= r && r < float.PositiveInfinity); 611Contracts.Assert(0 <= n && n < ExpInf); 613Contracts.Assert(0 <= f && f < 1); 617Contracts.Assert(1 <= r && r < float.PositiveInfinity); 651Contracts.Assert(0 <= n && n < ExpInf); 653Contracts.Assert(0 <= f && f < 1); 657Contracts.Assert(1 <= r && r < float.PositiveInfinity); 673Contracts.Assert(src.Length == dst.Length); 682Contracts.Assert(src.Length == dst.Length); 683Contracts.Assert(0 <= start && start <= end && end <= src.Length); 705Contracts.Assert(count >= 0); 706Contracts.Assert(Utils.Size(src) >= count); 718Contracts.Assert(ivMin <= ivLim); 724Contracts.Assert(!float.IsNaN(src[ivLim - 1])); 738Contracts.Assert(len > 0); 739Contracts.Assert(aIdx >= 0 && aIdx <= a.Length - len); 740Contracts.Assert(bIdx >= 0 && bIdx <= b.Length - len); 754Contracts.Assert(-1 - epsilon <= similarity && similarity <= 1 + epsilon);
Utilities\MatrixTransposeOps.cs (10)
31Contracts.AssertValue(src); 32Contracts.AssertValue(dst); 33Contracts.Assert(src != dst, "Transpose in place not supported"); 34Contracts.Assert(src.Length <= m * n); 35Contracts.Assert(dst.Length <= m * n); 82Contracts.AssertValue(src); 83Contracts.AssertValue(dst); 84Contracts.Assert(src != dst, "Transpose in place not supported"); 85Contracts.Assert(src.Length <= m * n); 86Contracts.Assert(dst.Length <= m * n);
Utilities\MinWaiter.cs (7)
58Contracts.CheckParam(waiters > 0, nameof(waiters), "Must have at least one waiter"); 78Contracts.Check(_maxWaiters > 0, "All waiters have been retired, Wait should not be called at this point"); 80Contracts.Assert(_waiters.Count < _maxWaiters); 85Contracts.Assert(_waiters.Count < _maxWaiters); 102Contracts.Check(_maxWaiters > 0, "Attempt to retire more waiters than were initially declared"); 103Contracts.Assert(_waiters.Count < _maxWaiters); 106Contracts.Assert(_maxWaiters == 0 || _waiters.Count < _maxWaiters);
Utilities\NormStr.cs (17)
31Contracts.Assert(id >= 0 || id == -1 && str.IsEmpty); 72Contracts.AssertValue(_rgins); 73Contracts.Assert(_rgins.Length == _mask + 1); 74Contracts.Assert(Utils.IsPowerOfTwo(_mask + 1)); 76Contracts.Assert(0 <= _cns && _cns <= Utils.Size(_rgns)); 77Contracts.Assert(Utils.Size(_rgns) == Utils.Size(_rgmeta)); 114Contracts.Assert(ins == -1); 137Contracts.Assert(ins == -1); 196Contracts.Assert(ins == -1); 214Contracts.Assert(str.Length >= 0); 215Contracts.Assert(Hashing.HashString(str.Span) == hash); 219Contracts.Assert(_cns == 0); 225Contracts.Assert(_cns == _rgns.Length); 230Contracts.Assert(_cns < _rgns.Length); 247Contracts.CheckParam(0 <= id && id < _cns, nameof(id)); 253Contracts.Assert(0 <= ins && ins < _cns); 254Contracts.Assert(_rgns[ins].Id == ins);
Utilities\OrderedWaiter.cs (4)
79throw Contracts.Except(_ex, "Event we were waiting on was subject to an exception"); 87throw Contracts.Except(_ex, "Event we were waiting on was subject to an exception"); 95throw Contracts.Except(_ex, "Event we were waiting on was subject to an exception"); 138Contracts.CheckValue(ex, nameof(ex));
Utilities\PathUtils.cs (2)
66Contracts.AssertNonWhiteSpace(fileName); 143throw Contracts.ExceptParam(nameof(folder), $"Failed to create folder for the provided path: {folder}. \nException: {exc.Message}");
Utilities\PlatformUtils.cs (3)
27Contracts.AssertValue(type); 28Contracts.AssertValue(typeDef); 35Contracts.AssertValue(type);
Utilities\Random.cs (6)
182Contracts.Assert(n >= 0); 188Contracts.CheckParam(maxValue >= 0, nameof(maxValue), "maxValue must be non-negative"); 193Contracts.Assert(0 <= res && (res < maxValue || res == 0)); 199Contracts.CheckParam(minValue <= maxValue, nameof(minValue), "minValue must be less than or equal to maxValue."); 207Contracts.CheckValue(buffer, nameof(buffer)); 233Contracts.Assert((uint)(float)u == u);
Utilities\ReservoirSampler.cs (11)
72Contracts.CheckValue(rnd, nameof(rnd)); 73Contracts.CheckParam(size > 0, nameof(size), "Reservoir size must be positive"); 74Contracts.CheckValue(getter, nameof(getter)); 84throw Contracts.Except("Cannot continue to sample after Lock() has been called"); 110throw Contracts.Except("Call Lock() before the call to GetSample()"); 151Contracts.CheckValue(rnd, nameof(rnd)); 152Contracts.CheckParam(size > 0, nameof(size), "Reservoir size must be positive"); 153Contracts.CheckValue(getter, nameof(getter)); 164Contracts.Check(!_locked, "Cannot continue to sample after Lock() has been called"); 195Contracts.Assert(_counts.Contains(0)); 248Contracts.Check(_locked, "Call Lock() before the call to GetSample()");
Utilities\Stats.cs (4)
24Contracts.CheckParam(rangeSize > 0, nameof(rangeSize), "rangeSize must be positive."); 29Contracts.Check(rangeSize <= (long)int.MaxValue * int.MaxValue, 79Contracts.CheckParam(alpha > 0, nameof(alpha), "alpha must be positive"); 128Contracts.Check(alphas.Length == result.Length,
Utilities\Stream.cs (85)
59Contracts.AssertValue(writer); 68Contracts.AssertValue(writer); 80Contracts.AssertValue(writer); 91Contracts.AssertValue(writer); 103Contracts.AssertValue(writer); 114Contracts.AssertValue(writer); 115Contracts.AssertValueOrNull(values); 134Contracts.AssertValue(writer); 147Contracts.AssertValue(writer); 148Contracts.AssertValueOrNull(values); 149Contracts.Assert(0 <= count && count <= Utils.Size(values)); 160Contracts.AssertValue(writer); 161Contracts.AssertValueOrNull(values); 162Contracts.Assert(0 <= count && count <= Utils.Size(values)); 172Contracts.AssertValue(writer); 184Contracts.AssertValue(writer); 185Contracts.AssertValue(values); 191Contracts.Assert(cv < count); 195Contracts.Assert(cv == count); 203Contracts.AssertValue(writer); 214Contracts.AssertValue(writer); 226Contracts.AssertValue(writer); 237Contracts.AssertValue(writer); 249Contracts.AssertValue(writer); 260Contracts.AssertValue(writer); 458Contracts.CheckDecode(b <= 1); 469Contracts.AssertValue(reader); 472Contracts.CheckDecode(size >= 0); 478Contracts.AssertValue(reader); 479Contracts.Assert(size >= 0); 507Contracts.AssertValue(reader); 508Contracts.AssertValue(array); 509Contracts.Assert(0 <= start && start < array.Length); 510Contracts.Assert(0 < count && count <= array.Length - start); 534Contracts.AssertValue(reader); 536Contracts.CheckDecode(size >= 0); 542Contracts.AssertValue(reader); 543Contracts.Assert(size >= 0); 570Contracts.AssertValue(reader); 573Contracts.CheckDecode(size >= 0); 579Contracts.AssertValue(reader); 580Contracts.Assert(size >= 0); 607Contracts.AssertValue(reader); 610Contracts.CheckDecode(size >= 0); 616Contracts.AssertValue(reader); 617Contracts.Assert(size >= 0); 645Contracts.AssertValue(reader); 648Contracts.CheckDecode(size >= 0); 654Contracts.AssertValue(reader); 655Contracts.Assert(size >= 0); 683Contracts.AssertValue(reader); 686Contracts.CheckDecode(size >= 0); 692Contracts.AssertValue(reader); 693Contracts.Assert(size >= 0); 721Contracts.AssertValue(reader); 724Contracts.CheckDecode(size >= 0); 730Contracts.AssertValue(reader); 731Contracts.Assert(size >= 0); 743Contracts.CheckDecode(b <= 1); 755Contracts.CheckDecode(*((byte*)dst + i) <= 1); 765Contracts.AssertValue(reader); 768Contracts.CheckDecode(size >= 0); 774Contracts.AssertValue(reader); 775Contracts.Assert(size >= 0); 803Contracts.AssertValue(reader); 806Contracts.CheckDecode(size >= 0); 812Contracts.AssertValue(reader); 813Contracts.Assert(size >= 0); 818Contracts.CheckDecode(bytes.Length == size); 825Contracts.CheckDecode(numBits >= 0); 837Contracts.AssertValue(reader); 838Contracts.Assert(bytesToRead >= 0); 839Contracts.Assert(destinationSizeInBytes >= bytesToRead); 840Contracts.Assert(destination != null); 841Contracts.AssertValueOrNull(work); 855Contracts.CheckDecode(read == toRead); 859Contracts.Assert(offset == bytesToRead); 884Contracts.CheckIO(read > 0, "Unexpected failure to read"); 923throw Contracts.ExceptDecode("LEB128 encoded integer exceeded expected length"); 938Contracts.CheckValue(stream, nameof(stream)); 939Contracts.CheckParam(0 < bufferSize, nameof(bufferSize), "buffer size must be positive"); 997throw Contracts.ExceptUserArg(userArgument, exc.Message); 1001throw Contracts.ExceptUserArg(userArgument, exc.Message); 1005throw Contracts.ExceptUserArg(userArgument, exc.Message); 1008throw Contracts.ExceptUserArg(userArgument, "Cannot find directory '{0}'.", dir);
Utilities\SubsetStream.cs (3)
43Contracts.AssertValue(stream); 44Contracts.Assert(!length.HasValue || length >= 0); 123throw Contracts.Except("cannot write {0} bytes to stream bounded at {1} bytes", count, _remaining);
Utilities\SupervisedBinFinder.cs (18)
69Contracts.Assert(_valueCount == labels.Count); 88Contracts.Assert(pair.Value >= curValue); 104Contracts.Assert(curIndex == _distinctValueCount - 1); 107Contracts.Assert(Utils.Size(boundaries) > 0); 108Contracts.Assert(boundaries.Length == 1 && boundaries[0] == 0 || boundaries[0] > 0, "boundaries are exclusive, can't have 0"); 109Contracts.Assert(boundaries[boundaries.Length - 1] == _distinctValueCount); 122Contracts.Assert(FloatUtils.IsFinite(result[i])); 147Contracts.Assert(_valueCount == labels.Count); 166Contracts.Assert(pair.Value >= curValue); 182Contracts.Assert(curIndex == _distinctValueCount - 1); 185Contracts.Assert(Utils.Size(boundaries) > 0); 186Contracts.Assert(boundaries.Length == 1 && boundaries[0] == 0 || boundaries[0] > 0, "boundaries are exclusive, can't have 0"); 187Contracts.Assert(boundaries[boundaries.Length - 1] == _distinctValueCount); 200Contracts.Assert(FloatUtils.IsFinite(result[i])); 214Contracts.Assert(result[i] > result[i - 1]); 223Contracts.Assert(result[i] > result[i - 1]); 259Contracts.Assert(leftCount + rightCount == totalCount); 337Contracts.Assert(intervals.Count == 0);
Utilities\TaskExtensions.cs (1)
16Contracts.Check(task.IsCompleted);
Utilities\TextReaderStream.cs (19)
43=> throw Contracts.ExceptNotSupp("Stream cannot determine length."); 52throw Contracts.ExceptNotSupp("Stream cannot seek."); 111Contracts.Assert(_buffCur == _buffLim); 116Contracts.Assert(_lineCur == 0); 124Contracts.AssertValue(_line); 125Contracts.Assert(_lineCur <= _line.Length); 134Contracts.Assert(0 < _buffLim && _buffLim <= _buff.Length); 141Contracts.Assert(charCount > 0); 143Contracts.Assert(0 < _buffLim && _buffLim <= _buff.Length); 145Contracts.Assert(_lineCur <= _line.Length); 150Contracts.CheckValue(buffer, nameof(buffer)); 151Contracts.CheckParam(0 <= offset && offset <= buffer.Length, nameof(offset), "invalid for this sized array"); 152Contracts.CheckParam(0 <= count && count <= buffer.Length - offset, nameof(count), "invalid for this sized array"); 159Contracts.Assert(_buffCur < _buffLim); 161Contracts.Assert(toCopy > 0); 174Contracts.Assert(_eof || _buffCur < _buffLim); 179=> throw Contracts.ExceptNotSupp("Stream cannot seek."); 182=> throw Contracts.ExceptNotSupp("Stream is not writable."); 185=> throw Contracts.ExceptNotSupp("Stream is not writable.");
Utilities\ThreadUtils.cs (2)
216Contracts.AssertNonEmpty(component); 217Contracts.AssertValue(ex);
Utilities\Tree.cs (3)
140Contracts.CheckValue(newChild, nameof(newChild)); 146Contracts.Assert(!ContainsKey(key)); 164Contracts.Assert(_parent._children.ContainsKey(Key));
Utilities\Utils.cs (106)
50Contracts.AssertValueOrNull(x); 56Contracts.AssertValueOrNull(x); 62Contracts.AssertValueOrNull(x); 68Contracts.AssertValueOrNull(x); 74Contracts.AssertValueOrNull(x); 80Contracts.AssertValueOrNull(x); 86Contracts.AssertValueOrNull(x); 92Contracts.AssertValueOrNull(x); 98Contracts.AssertValueOrNull(x); 104Contracts.AssertValueOrNull(x); 110Contracts.AssertValueOrNull(x); 116Contracts.AssertValueOrNull(x); 124Contracts.AssertValueOrNull(map); 135Contracts.AssertValueOrNull(list); 143Contracts.AssertValueOrNull(list); 151Contracts.AssertValueOrNull(set); 159Contracts.AssertValueOrNull(map); 167Contracts.AssertValueOrNull(map); 175Contracts.AssertValueOrNull(stack); 189Contracts.Assert(src != null); 190Contracts.Assert(!count.HasValue || (0 <= count && count <= src.Count)); 191Contracts.Assert(src.Count <= dst.Length); 208Contracts.AssertValue(input); 220Contracts.AssertValue(input); 232Contracts.AssertValue(input); 287Contracts.AssertValue(input); 288Contracts.Assert(0 <= min && min <= lim && lim <= input.Count); 295Contracts.Assert(minCur <= mid && mid < limCur); 302Contracts.Assert(min <= minCur && minCur <= limCur && limCur <= lim); 303Contracts.Assert(minCur == min || input[minCur - 1] < value); 304Contracts.Assert(limCur == lim || input[limCur] >= value); 306Contracts.Assert(min <= minCur && minCur == limCur && limCur <= lim); 307Contracts.Assert(minCur == min || input[minCur - 1] < value); 308Contracts.Assert(limCur == lim || input[limCur] >= value); 321Contracts.AssertValue(input); 322Contracts.Assert(0 <= min && min <= lim && lim <= input.Count); 323Contracts.Assert(!float.IsNaN(value)); 330Contracts.Assert(minCur <= mid && mid < limCur); 331Contracts.Assert(!float.IsNaN(input[mid])); 338Contracts.Assert(min <= minCur && minCur <= limCur && limCur <= lim); 339Contracts.Assert(minCur == min || input[minCur - 1] < value); 340Contracts.Assert(limCur == lim || input[limCur] >= value); 342Contracts.Assert(min <= minCur && minCur == limCur && limCur <= lim); 343Contracts.Assert(minCur == min || input[minCur - 1] < value); 344Contracts.Assert(limCur == lim || input[limCur] >= value); 357Contracts.AssertValue(input); 358Contracts.Assert(0 <= min && min <= lim && lim <= input.Length); 359Contracts.Assert(!Double.IsNaN(value)); 366Contracts.Assert(minCur <= mid && mid < limCur); 367Contracts.Assert(!Double.IsNaN(input[mid])); 374Contracts.Assert(min <= minCur && minCur <= limCur && limCur <= lim); 375Contracts.Assert(minCur == min || input[minCur - 1] < value); 376Contracts.Assert(limCur == lim || input[limCur] >= value); 378Contracts.Assert(min <= minCur && minCur == limCur && limCur <= lim); 379Contracts.Assert(minCur == min || input[minCur - 1] < value); 380Contracts.Assert(limCur == lim || input[limCur] >= value); 392Contracts.AssertValue(input); 393Contracts.Assert(0 <= min && min <= lim && lim <= input.Length); 400Contracts.Assert(minCur <= mid && mid < limCur); 407Contracts.Assert(min <= minCur && minCur <= limCur && limCur <= lim); 408Contracts.Assert(minCur == min || !func(input[minCur - 1])); 409Contracts.Assert(limCur == lim || func(input[limCur])); 411Contracts.Assert(min <= minCur && minCur == limCur && limCur <= lim); 412Contracts.Assert(minCur == min || !func(input[minCur - 1])); 413Contracts.Assert(limCur == lim || func(input[limCur])); 425Contracts.AssertValue(input); 426Contracts.Assert(0 <= min && min <= lim && lim <= input.Length); 433Contracts.Assert(minCur <= mid && mid < limCur); 440Contracts.Assert(min <= minCur && minCur <= limCur && limCur <= lim); 441Contracts.Assert(minCur == min || !func(input[minCur - 1], value)); 442Contracts.Assert(limCur == lim || func(input[limCur], value)); 444Contracts.Assert(min <= minCur && minCur == limCur && limCur <= lim); 445Contracts.Assert(minCur == min || !func(input[minCur - 1], value)); 446Contracts.Assert(limCur == lim || func(input[limCur], value)); 453Contracts.Assert(size >= 0); 463Contracts.Assert(0 <= lim && lim <= a.Length); 488Contracts.AssertValue(perm); 494Contracts.Assert(0 <= j && j < perm.Length); 495Contracts.Assert(res[j] == 0 && (j != perm[0] || i == 0)); 503Contracts.AssertValue(rand); 504Contracts.Assert(size >= 0); 547Contracts.AssertValue(rand); 700Contracts.Check(values.Length >= len); 721Contracts.Assert(length >= 0, "Length can't be negative"); 730Contracts.CheckParam(length >= 0, nameof(length)); 744Contracts.CheckParam(length >= 0, nameof(length)); 745Contracts.CheckValue(func, nameof(func)); 769Contracts.CheckValue(schema, nameof(schema)); 770Contracts.Check(schema.Count > 0, nameof(schema)); 771Contracts.CheckValue(pred, nameof(pred)); 804Contracts.CheckParam(lim >= 0, nameof(lim)); 805Contracts.CheckValue(pred, nameof(pred)); 839Contracts.CheckParam(lim >= 0, nameof(lim)); 840Contracts.CheckValue(columnsNeeded, nameof(columnsNeeded)); 848Contracts.Check(col.Index < lim); 890Contracts.Assert(nn != null || size == 0); 891Contracts.Assert((ne == null) == (size == 0)); 910Contracts.Assert(ivDst == size); 951Contracts.CheckValue(bitArray, nameof(bitArray)); 965throw Contracts.ExceptParam(nameof(func), "Cannot be generic on return type"); 1186Contracts.CheckValue(genArg, nameof(genArg)); 1187Contracts.CheckValue(func, nameof(func)); 1189Contracts.CheckParam(meth.IsGenericMethod, nameof(func), "Should be generic but is not"); 1190Contracts.CheckParam(meth.GetGenericArguments().Length == 1, nameof(func), 1269Contracts.CheckValue(predicate, nameof(predicate)); 1282Contracts.CheckValue(predicate, nameof(predicate));
Utilities\VBufferUtils.cs (53)
69Contracts.CheckParam(length >= 0, nameof(length)); 75Contracts.CheckParam(length >= 0, nameof(length)); 85Contracts.CheckValue(visitor, nameof(visitor)); 115Contracts.Check(a.Length == b.Length, "Vectors must have the same dimensionality."); 116Contracts.CheckValue(visitor, nameof(visitor)); 166Contracts.Check(a.Length == b.Length, "Vectors must have the same dimensionality."); 167Contracts.CheckValue(visitor, nameof(visitor)); 272Contracts.CheckValue(manip, nameof(manip)); 304Contracts.CheckParam(0 <= slot && slot < dst.Length, nameof(slot)); 305Contracts.CheckValue(manip, nameof(manip)); 306Contracts.CheckValueOrNull(pred); 370Contracts.Assert(i <= indices[i]); 401Contracts.Check(0 <= denseCount && denseCount <= dst.Length); 423Contracts.Assert(lim < denseCount); 450Contracts.CheckParam(0 < sparsityThreshold && sparsityThreshold < 1, nameof(sparsityThreshold)); 480Contracts.Assert(j < sparseCount); 487Contracts.Assert(j == sparseCount); 591Contracts.Check(src.Length == dst.Length, "Vectors must have the same dimensionality."); 592Contracts.CheckValue(manip, nameof(manip)); 718Contracts.Assert(newCount > 0); 719Contracts.Assert(0 < srcValues.Length && srcValues.Length <= newCount); 720Contracts.Assert(0 < dstValues.Length && dstValues.Length <= newCount); 779Contracts.Assert(sIndex >= 0); 780Contracts.Assert(sIndex == dIndex); 797Contracts.Assert(srcValues.Length == dstValues.Length); 800Contracts.Assert(srcIndices[i] == dstIndices[i]); 806Contracts.Assert(newCount > srcValues.Length); 830Contracts.Assert(dstIndices[dI] == sIndex); 850Contracts.Assert(srcIndices[sI] == bIndex); 867Contracts.Assert(false); 878Contracts.Check(src.Length == dst.Length, "Vectors must have the same dimensionality."); 879Contracts.CheckValue(manip, nameof(manip)); 894Contracts.Assert(srcValues.Length == src.Length); 904Contracts.Assert(0 < count && count < length); 938Contracts.Assert(srcValues.Length == src.Length); 947Contracts.Assert(0 < count && count < length); 988Contracts.Assert(dstCount > 0); 1032Contracts.Assert(srcValues.Length > 0); 1053Contracts.Assert(0 < resCount && resCount <= length); 1054Contracts.Assert(resCount <= srcValues.Length + dstCount); 1055Contracts.Assert(srcValues.Length <= resCount); 1056Contracts.Assert(dstCount <= resCount); 1077Contracts.Assert(i < length || j < length); 1107Contracts.Assert(ii == srcValues.Length && jj == dstCount); 1108Contracts.Assert(i == length && j == length); 1127Contracts.CheckValue(func, nameof(func)); 1169Contracts.Check(a.Length == b.Length, "Vectors must have the same dimensionality."); 1170Contracts.CheckValue(func, nameof(func)); 1264Contracts.Assert(aIndices[aI] == bIndices[aI]); 1275Contracts.Assert(aIndices[aI] >= bIndices[bI]); 1290Contracts.Assert(bIndices[bI] >= aIndices[aI]); 1323Contracts.Assert(index == bIndices[bI]); 1353Contracts.CheckParam(0 <= length && length <= Utils.Size(src), nameof(length));
Microsoft.ML.Data (2)
DataLoadSave\Transpose\TransposeLoader.cs (2)
202/// should be handle with <see cref="Contracts.CheckDecode(bool)"/> or by throwing 203/// <see cref="Contracts.ExceptDecode()"/>, as we consider the views not adhering to