language
stringclasses
1 value
repo
stringclasses
133 values
path
stringlengths
13
229
class_span
dict
source
stringlengths
14
2.92M
target
stringlengths
1
153
csharp
GtkSharp__GtkSharp
Source/Libs/GLibSharp/ParamSpec.cs
{ "start": 3349, "end": 5313 }
enum ____ cannot be enumerated */ else if (type == GType.Float) handle = g_param_spec_float (p_name, p_nick, p_blurb, Single.MinValue, Single.MaxValue, 0.0f, flags); else if (type == GType.Double) handle = g_param_spec_double (p_name, p_nick, p_blurb, Double.MinValue, Double.MaxValue, 0.0, flags); else if (type == GType.String) handle = g_param_spec_string (p_name, p_nick, p_blurb, IntPtr.Zero, flags); else if (type == GType.Pointer) handle = g_param_spec_pointer (p_name, p_nick, p_blurb, flags); else if (type.Val == g_gtype_get_type ()) handle = g_param_spec_gtype (p_name, p_nick, p_blurb, GType.None.Val, flags); else if (g_type_is_a (type.Val, GType.Boxed.Val)) handle = g_param_spec_boxed (p_name, p_nick, p_blurb, type.Val, flags); else if (g_type_is_a (type.Val, GType.Object.Val)) handle = g_param_spec_object (p_name, p_nick, p_blurb, type.Val, flags); else throw new ArgumentException ("type:" + type.ToString ()); GLib.Marshaller.Free (p_name); GLib.Marshaller.Free (p_nick); GLib.Marshaller.Free (p_blurb); } public ParamSpec (IntPtr native) { handle = native; } public IntPtr Handle { get { return handle; } } public GType ValueType { get { GParamSpec spec = (GParamSpec) Marshal.PtrToStructure (Handle, typeof (GParamSpec)); return new GType (spec.value_type); } } public string Name { get { GParamSpec spec = (GParamSpec) Marshal.PtrToStructure (Handle, typeof (GParamSpec)); return Marshaller.Utf8PtrToString (spec.name); } } public override string ToString () { GParamSpec spec = (GParamSpec) Marshal.PtrToStructure (Handle, typeof (GParamSpec)); GType valtype= new GType (spec.value_type); GType ownertype= new GType (spec.owner_type); return "ParamSpec: name=" + Marshaller.Utf8PtrToString (spec.name) + " value_type=" + valtype.ToString() + " owner_type=" + ownertype.ToString(); }
seemingly
csharp
dotnet__aspire
src/Aspire.Hosting/Dashboard/DashboardServiceHost.cs
{ "start": 1101, "end": 9171 }
internal sealed class ____ : IHostedService { /// <summary> /// Name of the environment variable that optionally specifies the resource service URL, /// which the dashboard will connect to over gRPC. /// </summary> /// <remarks> /// This is primarily intended for cases outside of the local developer environment. /// If no value exists for this variable, a port is assigned dynamically. /// </remarks> private const string ResourceServiceUrlVariableName = "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL"; /// <summary> /// Provides access to the URI at which the resource service endpoint is hosted. /// </summary> private readonly TaskCompletionSource<string> _resourceServiceUri = new(); /// <summary> /// <see langword="null"/> if <see cref="DistributedApplicationOptions.DashboardEnabled"/> is <see langword="false"/>. /// </summary> private readonly WebApplication? _app; private readonly ILogger<DashboardServiceHost> _logger; public DashboardServiceHost( DistributedApplicationOptions options, DistributedApplicationModel applicationModel, IConfiguration configuration, DistributedApplicationExecutionContext executionContext, ILoggerFactory loggerFactory, IConfigureOptions<LoggerFilterOptions> loggerOptions, ResourceNotificationService resourceNotificationService, ResourceLoggerService resourceLoggerService, ResourceCommandService resourceCommandService, InteractionService interactionService) { _logger = loggerFactory.CreateLogger<DashboardServiceHost>(); if (!options.DashboardEnabled || executionContext.IsPublishMode) { _logger.LogDebug("Dashboard is not enabled so skipping hosting the resource service."); _resourceServiceUri.SetCanceled(); return; } try { var builder = WebApplication.CreateSlimBuilder(); // Turn on HTTPS builder.WebHost.UseKestrelHttpsConfiguration(); // Configuration builder.Services.AddSingleton(configuration); var resourceServiceConfigSection = configuration.GetSection("AppHost:ResourceService"); builder.Services.AddOptions<ResourceServiceOptions>() .Bind(resourceServiceConfigSection) .ValidateOnStart(); builder.Services.AddSingleton<IValidateOptions<ResourceServiceOptions>, ValidateResourceServiceOptions>(); // Configure authentication scheme for the dashboard service builder.Services .AddAuthentication() .AddScheme<ResourceServiceApiKeyAuthenticationOptions, ResourceServiceApiKeyAuthenticationHandler>( ResourceServiceApiKeyAuthenticationDefaults.AuthenticationScheme, options => { }); // Configure authorization policy for the dashboard service. // The authorization policy accepts anyone who successfully authenticates via the // specified scheme, and that scheme enforces a valid API key (when configured to // use API keys for calls.) builder.Services .AddAuthorizationBuilder() .AddPolicy( name: ResourceServiceApiKeyAuthorization.PolicyName, policy: new AuthorizationPolicyBuilder( ResourceServiceApiKeyAuthenticationDefaults.AuthenticationScheme) .RequireAuthenticatedUser() .Build()); // Logging builder.Services.AddSingleton(loggerFactory); builder.Services.AddSingleton(loggerOptions); builder.Services.Add(ServiceDescriptor.Singleton(typeof(ILogger<>), typeof(Logger<>))); builder.Services.AddGrpc(); builder.Services.AddSingleton(applicationModel); builder.Services.AddSingleton(resourceCommandService); builder.Services.AddSingleton<DashboardServiceData>(); builder.Services.AddSingleton(resourceNotificationService); builder.Services.AddSingleton(resourceLoggerService); builder.Services.AddSingleton(interactionService); builder.WebHost.ConfigureKestrel(ConfigureKestrel); _app = builder.Build(); _app.UseAuthentication(); _app.UseAuthorization(); _app.MapGrpcService<DashboardService>(); } catch (Exception ex) { _resourceServiceUri.TrySetException(ex); throw; } return; void ConfigureKestrel(KestrelServerOptions kestrelOptions) { // Inspect environment for the address to listen on. var uri = configuration.GetUri(ResourceServiceUrlVariableName); string? scheme; if (uri is null) { // No URI available from the environment. scheme = null; // Listen on a random port. kestrelOptions.Listen(IPAddress.Loopback, port: 0, ConfigureListen); } else if (uri.IsLoopback) { scheme = uri.Scheme; // Listen on the requested localhost port. kestrelOptions.ListenLocalhost(uri.Port, ConfigureListen); } else { throw new ArgumentException($"{ResourceServiceUrlVariableName} must contain a local loopback address."); } void ConfigureListen(ListenOptions options) { // Force HTTP/2 for gRPC, so that it works over non-TLS connections // which cannot negotiate between HTTP/1.1 and HTTP/2. options.Protocols = HttpProtocols.Http2; if (string.Equals(scheme, "https", StringComparison.Ordinal)) { options.UseHttps(); } } } } /// <summary> /// Gets the URI upon which the resource service is listening. /// </summary> /// <remarks> /// Intended to be used by the app model when launching the dashboard process, populating its /// <c>DOTNET_RESOURCE_SERVICE_ENDPOINT_URL</c> environment variable with a single URI. /// </remarks> public async Task<string> GetResourceServiceUriAsync(CancellationToken cancellationToken = default) { var startTime = Stopwatch.GetTimestamp(); var uri = await _resourceServiceUri.Task.WaitAsync(cancellationToken).ConfigureAwait(false); var elapsed = Stopwatch.GetElapsedTime(startTime); if (elapsed > TimeSpan.FromSeconds(2)) { _logger.LogWarning("Unexpectedly long wait for resource service URI ({Elapsed}).", elapsed); } return uri; } async Task IHostedService.StartAsync(CancellationToken cancellationToken) { if (_app is not null) { await _app.StartAsync(cancellationToken).ConfigureAwait(false); var addressFeature = _app.Services.GetService<IServer>()?.Features.Get<IServerAddressesFeature>(); if (addressFeature is null) { _resourceServiceUri.SetException(new InvalidOperationException("Could not obtain IServerAddressesFeature. Resource service URI is not available.")); return; } _resourceServiceUri.SetResult(addressFeature.Addresses.Single()); } } async Task IHostedService.StopAsync(CancellationToken cancellationToken) { _resourceServiceUri.TrySetCanceled(cancellationToken); if (_app is not null) { await _app.StopAsync(cancellationToken).ConfigureAwait(false); } } } #pragma warning restore ASPIREINTERACTION001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
DashboardServiceHost
csharp
dotnet__orleans
src/api/Orleans.EventSourcing/Orleans.EventSourcing.cs
{ "start": 8569, "end": 9167 }
partial class ____ : Runtime.OrleansException { public ProtocolTransportException() { } [System.Obsolete] protected ProtocolTransportException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ProtocolTransportException(string msg, System.Exception exc) { } public ProtocolTransportException(string msg) { } public override string ToString() { throw null; } } } namespace Orleans.EventSourcing.Common { [GenerateSerializer] public sealed
ProtocolTransportException
csharp
graphql-dotnet__graphql-dotnet
src/GraphQL.Tests/Bugs/Bug2839NewtonsoftJson.cs
{ "start": 1849, "end": 2158 }
public class ____ { public string ThisIsAString { get; set; } public DateTime ThisIsADateTime { get; set; } public TestResponse() { ThisIsAString = "String Value"; ThisIsADateTime = new DateTime(2022, 1, 4, 10, 20, 30); } }
TestResponse
csharp
JamesNK__Newtonsoft.Json
Src/Newtonsoft.Json/Utilities/ConvertUtils.cs
{ "start": 1699, "end": 2774 }
internal enum ____ { Empty = 0, Object = 1, Char = 2, CharNullable = 3, Boolean = 4, BooleanNullable = 5, SByte = 6, SByteNullable = 7, Int16 = 8, Int16Nullable = 9, UInt16 = 10, UInt16Nullable = 11, Int32 = 12, Int32Nullable = 13, Byte = 14, ByteNullable = 15, UInt32 = 16, UInt32Nullable = 17, Int64 = 18, Int64Nullable = 19, UInt64 = 20, UInt64Nullable = 21, Single = 22, SingleNullable = 23, Double = 24, DoubleNullable = 25, DateTime = 26, DateTimeNullable = 27, DateTimeOffset = 28, DateTimeOffsetNullable = 29, Decimal = 30, DecimalNullable = 31, Guid = 32, GuidNullable = 33, TimeSpan = 34, TimeSpanNullable = 35, BigInteger = 36, BigIntegerNullable = 37, Uri = 38, String = 39, Bytes = 40, DBNull = 41 }
PrimitiveTypeCode
csharp
dotnet__maui
src/Controls/tests/BindingSourceGen.UnitTests/BindingRepresentationGenTests.cs
{ "start": 15477, "end": 16595 }
class ____ { public string? this[string key] => key; } """; var codeGeneratorResult = SourceGenHelpers.Run(source); var expectedBinding = new BindingInvocationDescription( new InterceptableLocationRecord(1, "serializedData"), new SimpleLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo"), new TypeDescription("int", IsValueType: true, IsNullable: true), new EquatableArray<IPathPart>([ new IndexAccess("Item", "key"), new ConditionalAccess(new MemberAccess("Length", IsValueType: true)), // TODO: Improve naming so this looks right ]), SetterOptions: new(IsWritable: false), NullableContextEnabled: true, MethodType: InterceptedMethodType.SetBinding); AssertExtensions.BindingsAreEqual(expectedBinding, codeGeneratorResult); } [Fact] public void GenerateBindingWhenGetterContainsConditionallyAccessedIndexer() { var source = """ using Microsoft.Maui.Controls; var label = new Label(); label.SetBinding(Label.RotationProperty, static (Foo f) => f.bar?["key"].Length);
Foo
csharp
rabbitmq__rabbitmq-dotnet-client
projects/RabbitMQ.Client/Exceptions/BrokerUnreachableException.cs
{ "start": 1607, "end": 2010 }
public class ____ : IOException { ///<summary>Construct a BrokerUnreachableException. The inner exception is ///an AggregateException holding the errors from multiple connection attempts.</summary> public BrokerUnreachableException(Exception Inner) : base("None of the specified endpoints were reachable", Inner) { } } }
BrokerUnreachableException
csharp
unoplatform__uno
src/Uno.UI.RuntimeTests/Tests/UnitTestsTests/Give_UnitTest_DynamicData_From_Property.cs
{ "start": 169, "end": 1429 }
public class ____ : IDisposable { static int TestSucces_Count; [TestMethod] [DynamicData(nameof(Data))] public void When_Get_Arguments_From_Property(int a, int b, int expected) { var actual = a + b; Assert.AreEqual(expected, actual); TestSucces_Count++; } public static IEnumerable<object[]> Data { get { yield return new object[] { 1, 1, 2 }; yield return new object[] { 12, 30, 42 }; yield return new object[] { 14, 1, 15 }; } } public void Dispose() => // TODO: This used to be Assert.Equals which **always** throws at runtime and everything was green. // This is because Dispose is never called, and the assert is not be doing what it's supposed to do! // This assert is also wrong altogether. // The correct test flow *should* be: // 1. Create instance of the test class // 2. Invoke the first test case. // 3. Dispose // 4. Repeat for the other two test cases. // So, Dispose should be called three times. First with value 1, then 2, then 3. // The current behavior is: // 1. Create a single instance of the test class. // 2. Invoke all test cases. // 3. Dispose is never called. Assert.AreEqual(3, TestSucces_Count); } }
Give_UnitTest_DynamicData_From_Property
csharp
microsoft__garnet
libs/common/MemoryResult.cs
{ "start": 173, "end": 332 }
struct ____ memory result from shared pool, of particular actual length /// </summary> /// <typeparam name="T">Type of memory elements</typeparam>
for
csharp
smartstore__Smartstore
src/Smartstore.Core/Common/Services/IGeoCountryLookup.cs
{ "start": 68, "end": 805 }
public sealed class ____ { /// <summary> /// The GeoName ID for the country. /// </summary> public long? GeoNameId { get; set; } /// <summary> /// The english name of the country. /// </summary> public string Name { get; set; } /// <summary> /// The two-letter ISO 3166-1 alpha code for the country /// </summary> public string IsoCode { get; set; } /// <summary> /// This is true if the country is a member state of the European Union. /// </summary> public bool IsInEu { get; set; } } /// <summary> /// Country lookup helper for IPv4/6 addresses /// </summary>
LookupCountryResponse
csharp
Xabaril__AspNetCore.Diagnostics.HealthChecks
src/HealthChecks.UI/Core/Extensions/StringExtensions.cs
{ "start": 19, "end": 230 }
public static class ____ { public static string AsRelativeResource(this string resourcePath) { return resourcePath.StartsWith("/") ? resourcePath.Substring(1) : resourcePath; } }
StringExtensions
csharp
dotnet__aspnetcore
src/Mvc/Mvc.Core/src/Infrastructure/ActionMethodExecutor.cs
{ "start": 11198, "end": 13032 }
private sealed class ____ : ActionMethodExecutor { public override async ValueTask<IActionResult> Execute( ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object?[]? arguments) { // Async method returning awaitable-of-IActionResult (e.g., Task<ViewResult>) // We have to use ExecuteAsync because we don't know the awaitable's type at compile time. var actionResult = (IActionResult)await executor.ExecuteAsync(controller, arguments); EnsureActionResultNotNull(executor, actionResult); return actionResult; } public override async ValueTask<object?> Execute(ControllerEndpointFilterInvocationContext invocationContext) { var executor = invocationContext.Executor; var controller = invocationContext.Controller; var arguments = (object[])invocationContext.Arguments; // Async method returning awaitable-of-IActionResult (e.g., Task<ViewResult>) // We have to use ExecuteAsync because we don't know the awaitable's type at compile time. var actionResult = (IActionResult)await executor.ExecuteAsync(controller, arguments); EnsureActionResultNotNull(executor, actionResult); return actionResult; } protected override bool CanExecute(ObjectMethodExecutor executor) { // Async method returning awaitable-of - IActionResult(e.g., Task<ViewResult>) return executor.IsMethodAsync && typeof(IActionResult).IsAssignableFrom(executor.AsyncResultType); } } // Task<object> GetPerson(..) // Task<Customer> GetCustomerAsync(..)
TaskOfActionResultExecutor
csharp
ServiceStack__ServiceStack
ServiceStack.OrmLite/src/ServiceStack.OrmLite/IOrmLiteConverter.cs
{ "start": 774, "end": 2689 }
public abstract class ____ : IOrmLiteConverter { public static ILog Log => OrmLiteLog.Log; /// <summary> /// RDBMS Dialect this Converter is for. Injected at registration. /// </summary> public IOrmLiteDialectProvider DialectProvider { get; set; } /// <summary> /// SQL Column Definition used in CREATE Table. /// </summary> public abstract string ColumnDefinition { get; } /// <summary> /// Used in DB Params. Defaults to DbType.String /// </summary> public virtual DbType DbType => DbType.String; /// <summary> /// Quoted Value in SQL Statement /// </summary> public virtual string ToQuotedString(Type fieldType, object value) { return DialectProvider.GetQuotedValue(value.ToString()); } /// <summary> /// Customize how DB Param is initialized. Useful for supporting RDBMS-specific Types. /// </summary> public virtual void InitDbParam(IDbDataParameter p, Type fieldType) { p.DbType = DbType; } /// <summary> /// Parameterized value in parameterized queries /// </summary> public virtual object ToDbValue(Type fieldType, object value) { return value; } /// <summary> /// Value from DB to Populate on POCO Data Model with /// </summary> public virtual object FromDbValue(Type fieldType, object value) { return value; } /// <summary> /// Retrieve Value from ADO.NET IDataReader. Defaults to reader.GetValue() /// </summary> public virtual object GetValue(IDataReader reader, int columnIndex, object[] values) { var value = values != null ? values[columnIndex] : reader.GetValue(columnIndex); return value == DBNull.Value ? null : value; } } /// <summary> /// For Types that are natively supported by RDBMS's and shouldn't be quoted /// </summary>
OrmLiteConverter
csharp
dotnet__extensions
src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/DelegatingAIFunction.cs
{ "start": 507, "end": 651 }
public class ____ : AIFunction { /// <summary> /// Initializes a new instance of the <see cref="DelegatingAIFunction"/>
DelegatingAIFunction
csharp
jellyfin__jellyfin
MediaBrowser.Providers/Plugins/AudioDb/Configuration/PluginConfiguration.cs
{ "start": 122, "end": 246 }
public class ____ : BasePluginConfiguration { public bool ReplaceAlbumName { get; set; } } }
PluginConfiguration
csharp
MassTransit__MassTransit
src/MassTransit.Abstractions/Attributes/NullableAttributes.cs
{ "start": 765, "end": 1286 }
sealed class ____ : Attribute { /// <summary>Initializes the attribute with the specified return value condition.</summary> /// <param name="returnValue"> /// The return value condition. If the method returns this value, the associated parameter will not be null. /// </param> public MaybeNullWhenAttribute(bool returnValue) { ReturnValue = returnValue; } /// <summary>Gets the return value condition.</summary> public bool ReturnValue { get; } } #endif
MaybeNullWhenAttribute
csharp
dotnet__BenchmarkDotNet
tests/BenchmarkDotNet.Tests/Validators/CompilationValidatorTests.cs
{ "start": 7526, "end": 7616 }
internal class ____ { [Benchmark] public void PublicMethod() { } } } }
InternalNestedClass
csharp
icsharpcode__ILSpy
ICSharpCode.Decompiler/IL/Instructions.cs
{ "start": 206061, "end": 208480 }
partial class ____ : ILInstruction { public Await(ILInstruction value) : base(OpCode.Await) { this.Value = value; } public static readonly SlotInfo ValueSlot = new SlotInfo("Value", canInlineInto: true); ILInstruction value = null!; public ILInstruction Value { get { return this.value; } set { ValidateChild(value); SetChildInstruction(ref this.value, value, 0); } } protected sealed override int GetChildCount() { return 1; } protected sealed override ILInstruction GetChild(int index) { switch (index) { case 0: return this.value; default: throw new IndexOutOfRangeException(); } } protected sealed override void SetChild(int index, ILInstruction value) { switch (index) { case 0: this.Value = value; break; default: throw new IndexOutOfRangeException(); } } protected sealed override SlotInfo GetChildSlot(int index) { switch (index) { case 0: return ValueSlot; default: throw new IndexOutOfRangeException(); } } public sealed override ILInstruction Clone() { var clone = (Await)ShallowClone(); clone.Value = this.value.Clone(); return clone; } public override StackType ResultType { get { return GetResultMethod?.ReturnType.GetStackType() ?? StackType.Unknown; } } protected override InstructionFlags ComputeFlags() { return InstructionFlags.SideEffect | value.Flags; } public override InstructionFlags DirectFlags { get { return InstructionFlags.SideEffect; } } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { WriteILRange(output, options); output.Write(OpCode); output.Write('('); this.value.WriteTo(output, options); output.Write(')'); } public override void AcceptVisitor(ILVisitor visitor) { visitor.VisitAwait(this); } public override T AcceptVisitor<T>(ILVisitor<T> visitor) { return visitor.VisitAwait(this); } public override T AcceptVisitor<C, T>(ILVisitor<C, T> visitor, C context) { return visitor.VisitAwait(this, context); } protected internal override bool PerformMatch(ILInstruction? other, ref Patterns.Match match) { var o = other as Await; return o != null && this.value.PerformMatch(o.value, ref match); } } } namespace ICSharpCode.Decompiler.IL { /// <summary>Deconstruction statement</summary> public sealed
Await
csharp
microsoft__PowerToys
src/modules/launcher/Wox.Test/Plugins/ToolTipDataTest.cs
{ "start": 320, "end": 700 }
public class ____ { [TestMethod] public void ConstructorThrowsNullArgumentExceptionWhenToolTipTitleIsNull() { // Arrange string title = null; string text = "text"; // Assert var ex = Assert.ThrowsException<ArgumentException>(() => new ToolTipData(title, text)); } } }
ToolTipDataTest
csharp
unoplatform__uno
src/Uno.UI.Composition/Generated/3.0.0.0/Microsoft.UI.Composition/AnimationControllerProgressBehavior.cs
{ "start": 262, "end": 587 }
public enum ____ { #if __ANDROID__ || __IOS__ || __TVOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ Default = 0, #endif #if __ANDROID__ || __IOS__ || __TVOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ IncludesDelayTime = 1, #endif } #endif }
AnimationControllerProgressBehavior
csharp
dotnet__machinelearning
src/Microsoft.ML.StandardTrainers/Standard/SdcaMulticlass.cs
{ "start": 36371, "end": 36870 }
public sealed class ____ : SdcaMulticlassTrainerBase<LinearMulticlassModelParameters> { /// <summary> /// <see cref="Options"/> for <see cref="SdcaNonCalibratedMulticlassTrainer"/> as used in /// <see cref="Microsoft.ML.StandardTrainersCatalog.SdcaNonCalibrated(MulticlassClassificationCatalog.MulticlassClassificationTrainers, string, string, string, ISupportSdcaClassificationLoss, float?, float?, int?)"/>. /// </summary>
SdcaNonCalibratedMulticlassTrainer
csharp
bitwarden__server
src/Api/Billing/Models/Requests/Payment/VerifyBankAccountRequest.cs
{ "start": 99, "end": 212 }
public class ____ { [Required] public required string DescriptorCode { get; set; } }
VerifyBankAccountRequest
csharp
nuke-build__nuke
source/Nuke.Common/Tools/Kubernetes/Kubernetes.Generated.cs
{ "start": 682976, "end": 683259 }
partial class ____ { } #endregion #region KubernetesUncordonSettingsExtensions /// <inheritdoc cref="KubernetesTasks.KubernetesUncordon(Nuke.Common.Tools.Kubernetes.KubernetesUncordonSettings)"/> [PublicAPI] [ExcludeFromCodeCoverage] public static
KubernetesApiVersionsSettingsExtensions
csharp
dotnet__efcore
test/EFCore.SqlServer.FunctionalTests/NotificationEntitiesSqlServerTest.cs
{ "start": 448, "end": 659 }
public class ____ : NotificationEntitiesFixtureBase { protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; } }
NotificationEntitiesSqlServerFixture
csharp
VerifyTests__Verify
src/Verify.Fixie.Tests/NugetTests.cs
{ "start": 31, "end": 1220 }
public class ____ // { // public async Task Run() // { // if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) // { // return; // } // // var version = GetType().Assembly // .GetCustomAttribute<AssemblyInformationalVersionAttribute>()! // .InformationalVersion.Split('+') // .First(); // var nugetPath = Path.Combine( // AttributeReader.GetSolutionDirectory(), // $"../nugets/Verify.Fixie.{version}.nupkg"); // await VerifyZip( // nugetPath, // include: _ => // { // var extension = Path.GetExtension(_.Name); // return !extension.Contains(".psmdc") && // !extension.Contains(".xml") && // !extension.Contains(".dll") && // !extension.Contains(".rels"); // }, // includeStructure: true) // .ScrubLinesContaining("psmdcp", "repository") // .ScrubLinesWithReplace(_ => _.Replace(version, "version")); // } // } // // #endif
NugetTests
csharp
cake-build__cake
src/Cake.Common.Tests/Unit/Solution/Project/ProjectParserTests.cs
{ "start": 504, "end": 1397 }
public sealed class ____ { [Fact] public void Should_Throw_If_File_System_Is_Null() { // Given var environment = Substitute.For<ICakeEnvironment>(); // When var result = Record.Exception(() => new ProjectParser(null, environment)); // Then AssertEx.IsArgumentNullException(result, "fileSystem"); } [Fact] public void Should_Throw_If_Environment_Is_Null() { // Given var fileSystem = Substitute.For<IFileSystem>(); // When var result = Record.Exception(() => new ProjectParser(fileSystem, null)); // Then AssertEx.IsArgumentNullException(result, "environment"); } }
TheConstructor
csharp
ChilliCream__graphql-platform
src/HotChocolate/Core/test/Fetching.Tests/BatchDispatcherTests.cs
{ "start": 2461, "end": 2872 }
public class ____ : IObserver<BatchDispatchEventArgs> { public ImmutableList<BatchDispatchEventType> Events { get; private set; } = []; public void OnNext(BatchDispatchEventArgs value) { Events = Events.Add(value.Type); } public void OnError(Exception error) { } public void OnCompleted() { } }
TestObserver
csharp
OrchardCMS__OrchardCore
src/OrchardCore.Modules/OrchardCore.Users/Drivers/UserDisplayDriver.cs
{ "start": 393, "end": 3650 }
public sealed class ____ : DisplayDriver<User> { private readonly IHttpContextAccessor _httpContextAccessor; private readonly IAuthorizationService _authorizationService; internal readonly IHtmlLocalizer H; internal readonly IStringLocalizer S; public UserDisplayDriver( IHttpContextAccessor httpContextAccessor, IAuthorizationService authorizationService, IHtmlLocalizer<UserDisplayDriver> htmlLocalizer, IStringLocalizer<UserDisplayDriver> stringLocalizer) { _httpContextAccessor = httpContextAccessor; _authorizationService = authorizationService; H = htmlLocalizer; S = stringLocalizer; } public override Task<IDisplayResult> DisplayAsync(User user, BuildDisplayContext context) { return CombineAsync( Initialize<SummaryAdminUserViewModel>("UserFields", model => model.User = user).Location(OrchardCoreConstants.DisplayType.SummaryAdmin, "Header:1"), Initialize<SummaryAdminUserViewModel>("UserInfo", model => model.User = user).Location(OrchardCoreConstants.DisplayType.DetailAdmin, "Content:5"), Initialize<SummaryAdminUserViewModel>("UserButtons", model => model.User = user).Location(OrchardCoreConstants.DisplayType.SummaryAdmin, "Actions:1"), Initialize<SummaryAdminUserViewModel>("UserActionsMenu", model => model.User = user).Location(OrchardCoreConstants.DisplayType.SummaryAdmin, "ActionsMenu:5") ); } public override async Task<IDisplayResult> EditAsync(User user, BuildEditorContext context) { if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, UsersPermissions.EditUsers, user)) { return null; } return Initialize<EditUserViewModel>("UserFields_Edit", model => { model.IsNewRequest = context.IsNew; }) .Location("Content:1.5"); } public override async Task<IDisplayResult> UpdateAsync(User user, UpdateEditorContext context) { // To prevent html injection when updating the user must meet all authorization requirements. if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, UsersPermissions.EditUsers, user)) { // When the user is only editing their profile never update this part of the user. return await EditAsync(user, context); } var model = new EditUserViewModel(); await context.Updater.TryUpdateModelAsync(model, Prefix); if (context.IsNew) { if (string.IsNullOrWhiteSpace(model.Password)) { context.Updater.ModelState.AddModelError(Prefix, nameof(model.Password), S["A password is required"]); } if (model.Password != model.PasswordConfirmation) { context.Updater.ModelState.AddModelError(Prefix, nameof(model.Password), S["The password and the password confirmation fields must match."]); } } if (!context.Updater.ModelState.IsValid) { return await EditAsync(user, context); } return await EditAsync(user, context); } }
UserDisplayDriver
csharp
NEventStore__NEventStore
src/NEventStore.Persistence.AcceptanceTests/PersistenceTests.cs
{ "start": 36925, "end": 38574 }
public class ____ : PersistenceEngineConcern { private const string _bucketAId = "a"; private const string _bucketBId = "b"; private string? _streamId; protected override void Context() { _streamId = Guid.NewGuid().ToString(); Persistence.Commit(_streamId.BuildAttempt(bucketId: _bucketAId)); Persistence.Commit(_streamId.BuildAttempt(bucketId: _bucketBId)); var _snapshotA = new Snapshot(bucketId: _bucketAId, _streamId, 1, "SnapshotA"); Persistence.AddSnapshot(_snapshotA); var _snapshotB = new Snapshot(bucketId: _bucketBId, _streamId, 1, "SnapshotB"); Persistence.AddSnapshot(_snapshotB); } protected override void Because() { Persistence.Purge(); } [Fact] public void should_purge_all_commits_stored_in_bucket_a() { Persistence.GetFrom(_bucketAId, 0).Count().Should().Be(0); } [Fact] public void should_purge_all_commits_stored_in_bucket_b() { Persistence.GetFrom(_bucketBId, 0).Count().Should().Be(0); } [Fact] public void should_purge_all_streams_to_snapshot_in_bucket_a() { Persistence.GetStreamsToSnapshot(_bucketAId, 0).Count().Should().Be(0); } [Fact] public void should_purge_all_streams_to_snapshot_in_bucket_b() { Persistence.GetStreamsToSnapshot(_bucketBId, 0).Count().Should().Be(0); } } [Serializable]
when_purging_all_commits_and_there_are_streams_in_multiple_buckets
csharp
xunit__xunit
src/xunit.v3.core.tests/TestDoubles/SpyBeforeAfterTest.cs
{ "start": 56, "end": 476 }
public class ____ : BeforeAfterTestAttribute { public bool ThrowInBefore { get; set; } public bool ThrowInAfter { get; set; } public override void Before( MethodInfo methodUnderTest, IXunitTest test) { if (ThrowInBefore) throw new BeforeException(); } public override void After( MethodInfo methodUnderTest, IXunitTest test) { if (ThrowInAfter) throw new AfterException(); }
SpyBeforeAfterTest
csharp
AvaloniaUI__Avalonia
src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlLayoutViewModel.cs
{ "start": 186, "end": 8620 }
internal class ____ : ViewModelBase { private readonly Visual _control; private Thickness _borderThickness; private double _height; private string? _heightConstraint; private HorizontalAlignment _horizontalAlignment; private Thickness _marginThickness; private Thickness _paddingThickness; private bool _updatingFromControl; private VerticalAlignment _verticalAlignment; private double _width; private string? _widthConstraint; public ControlLayoutViewModel(Visual control) { _control = control; HasPadding = AvaloniaPropertyRegistry.Instance.IsRegistered(control, Decorator.PaddingProperty); HasBorder = AvaloniaPropertyRegistry.Instance.IsRegistered(control, Border.BorderThicknessProperty); if (control is AvaloniaObject ao) { try { _updatingFromControl = true; MarginThickness = ao.GetValue(Layoutable.MarginProperty); if (HasPadding) { PaddingThickness = ao.GetValue(Decorator.PaddingProperty); } if (HasBorder) { BorderThickness = ao.GetValue(Border.BorderThicknessProperty); } HorizontalAlignment = ao.GetValue(Layoutable.HorizontalAlignmentProperty); VerticalAlignment = ao.GetValue(Layoutable.VerticalAlignmentProperty); } finally { _updatingFromControl = false; } } UpdateSize(); UpdateSizeConstraints(); } public Thickness MarginThickness { get => _marginThickness; set => RaiseAndSetIfChanged(ref _marginThickness, value); } public Thickness BorderThickness { get => _borderThickness; set => RaiseAndSetIfChanged(ref _borderThickness, value); } public Thickness PaddingThickness { get => _paddingThickness; set => RaiseAndSetIfChanged(ref _paddingThickness, value); } public double Width { get => _width; private set => RaiseAndSetIfChanged(ref _width, value); } public double Height { get => _height; private set => RaiseAndSetIfChanged(ref _height, value); } public string? WidthConstraint { get => _widthConstraint; private set => RaiseAndSetIfChanged(ref _widthConstraint, value); } public string? HeightConstraint { get => _heightConstraint; private set => RaiseAndSetIfChanged(ref _heightConstraint, value); } public HorizontalAlignment HorizontalAlignment { get => _horizontalAlignment; set => RaiseAndSetIfChanged(ref _horizontalAlignment, value); } public VerticalAlignment VerticalAlignment { get => _verticalAlignment; set => RaiseAndSetIfChanged(ref _verticalAlignment, value); } public bool HasPadding { get; } public bool HasBorder { get; } private void UpdateSizeConstraints() { if (_control is AvaloniaObject ao) { string? CreateConstraintInfo(StyledProperty<double> minProperty, StyledProperty<double> maxProperty) { bool hasMin = ao.IsSet(minProperty); bool hasMax = ao.IsSet(maxProperty); if (hasMin || hasMax) { var builder = new StringBuilder(); if (hasMin) { var minValue = ao.GetValue(minProperty); builder.AppendFormat("Min: {0}", Math.Round(minValue, 2)); builder.AppendLine(); } if (hasMax) { var maxValue = ao.GetValue(maxProperty); builder.AppendFormat("Max: {0}", Math.Round(maxValue, 2)); } return builder.ToString(); } return null; } WidthConstraint = CreateConstraintInfo(Layoutable.MinWidthProperty, Layoutable.MaxWidthProperty); HeightConstraint = CreateConstraintInfo(Layoutable.MinHeightProperty, Layoutable.MaxHeightProperty); } } protected override void OnPropertyChanged(PropertyChangedEventArgs e) { base.OnPropertyChanged(e); if (_updatingFromControl) { return; } if (_control is AvaloniaObject ao) { if (e.PropertyName == nameof(MarginThickness)) { ao.SetValue(Layoutable.MarginProperty, MarginThickness); } else if (HasPadding && e.PropertyName == nameof(PaddingThickness)) { ao.SetValue(Decorator.PaddingProperty, PaddingThickness); } else if (HasBorder && e.PropertyName == nameof(BorderThickness)) { ao.SetValue(Border.BorderThicknessProperty, BorderThickness); } else if (e.PropertyName == nameof(HorizontalAlignment)) { ao.SetValue(Layoutable.HorizontalAlignmentProperty, HorizontalAlignment); } else if (e.PropertyName == nameof(VerticalAlignment)) { ao.SetValue(Layoutable.VerticalAlignmentProperty, VerticalAlignment); } } } public void ControlPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e) { try { _updatingFromControl = true; if (e.Property == Visual.BoundsProperty) { UpdateSize(); } else { if (_control is AvaloniaObject ao) { if (e.Property == Layoutable.MarginProperty) { MarginThickness = ao.GetValue(Layoutable.MarginProperty); } else if (e.Property == Decorator.PaddingProperty) { PaddingThickness = ao.GetValue(Decorator.PaddingProperty); } else if (e.Property == Border.BorderThicknessProperty) { BorderThickness = ao.GetValue(Border.BorderThicknessProperty); } else if (e.Property == Layoutable.MinWidthProperty || e.Property == Layoutable.MaxWidthProperty || e.Property == Layoutable.MinHeightProperty || e.Property == Layoutable.MaxHeightProperty) { UpdateSizeConstraints(); } else if (e.Property == Layoutable.HorizontalAlignmentProperty) { HorizontalAlignment = ao.GetValue(Layoutable.HorizontalAlignmentProperty); } else if (e.Property == Layoutable.VerticalAlignmentProperty) { VerticalAlignment = ao.GetValue(Layoutable.VerticalAlignmentProperty); } } } } finally { _updatingFromControl = false; } } private void UpdateSize() { var size = _control.Bounds; Width = Math.Round(size.Width, 2); Height = Math.Round(size.Height, 2); } } }
ControlLayoutViewModel
csharp
dotnet__aspire
src/Aspire.Hosting/Dashboard/DashboardServiceAuth.cs
{ "start": 627, "end": 727 }
internal sealed class ____ : AuthenticationSchemeOptions { }
ResourceServiceApiKeyAuthenticationOptions
csharp
dotnet__aspnetcore
src/Mvc/Mvc.TagHelpers/test/SelectTagHelperTest.cs
{ "start": 478, "end": 34598 }
public class ____ { // Model (List<Model> or Model instance), container type (Model or NestModel), model accessor, // property path / id, expected content. public static TheoryData<object, Type, Func<object>, NameAndId, string> GeneratesExpectedDataSet { get { var modelWithNull = new Model { NestedModel = new NestedModel { Text = null, }, Text = null, }; var modelWithText = new Model { NestedModel = new NestedModel { Text = "inner text", }, Text = "outer text", }; var models = new List<Model> { modelWithNull, modelWithText, }; var noneSelected = "<option></option>" + Environment.NewLine + "<option>HtmlEncode[[outer text]]</option>" + Environment.NewLine + "<option>HtmlEncode[[inner text]]</option>" + Environment.NewLine + "<option>HtmlEncode[[other text]]</option>" + Environment.NewLine; var innerSelected = "<option></option>" + Environment.NewLine + "<option>HtmlEncode[[outer text]]</option>" + Environment.NewLine + "<option selected=\"HtmlEncode[[selected]]\">HtmlEncode[[inner text]]</option>" + Environment.NewLine + "<option>HtmlEncode[[other text]]</option>" + Environment.NewLine; var outerSelected = "<option></option>" + Environment.NewLine + "<option selected=\"HtmlEncode[[selected]]\">HtmlEncode[[outer text]]</option>" + Environment.NewLine + "<option>HtmlEncode[[inner text]]</option>" + Environment.NewLine + "<option>HtmlEncode[[other text]]</option>" + Environment.NewLine; return new TheoryData<object, Type, Func<object>, NameAndId, string> { { null, typeof(Model), () => null, new NameAndId("Text", "Text"), noneSelected }, // Imitate a temporary variable set from somewhere else in the view model. { null, typeof(Model), () => modelWithText.NestedModel.Text, new NameAndId("item.Text", "item_Text"), innerSelected }, { modelWithNull, typeof(Model), () => modelWithNull.Text, new NameAndId("Text", "Text"), noneSelected }, { modelWithText, typeof(Model), () => modelWithText.Text, new NameAndId("Text", "Text"), outerSelected }, { modelWithNull, typeof(NestedModel), () => modelWithNull.NestedModel.Text, new NameAndId("NestedModel.Text", "NestedModel_Text"), noneSelected }, { modelWithText, typeof(NestedModel), () => modelWithText.NestedModel.Text, new NameAndId("NestedModel.Text", "NestedModel_Text"), innerSelected }, { models, typeof(Model), () => models[0].Text, new NameAndId("[0].Text", "z0__Text"), noneSelected }, { models, typeof(NestedModel), () => models[0].NestedModel.Text, new NameAndId("[0].NestedModel.Text", "z0__NestedModel_Text"), noneSelected }, { models, typeof(Model), () => models[1].Text, new NameAndId("[1].Text", "z1__Text"), outerSelected }, { models, typeof(NestedModel), () => models[1].NestedModel.Text, new NameAndId("[1].NestedModel.Text", "z1__NestedModel_Text"), innerSelected }, }; } } // Items property value, attribute name, attribute value, expected items value (passed to generator). Provides // cross product of Items and attributes. These values should not interact. public static TheoryData<IEnumerable<SelectListItem>, string, string, IEnumerable<SelectListItem>> ItemsAndMultipleDataSet { get { var arrayItems = new[] { new SelectListItem() }; var listItems = new List<SelectListItem>(); var multiItems = new MultiSelectList(Enumerable.Range(0, 5)); var selectItems = new SelectList(Enumerable.Range(0, 5)); var itemsData = new[] { new[] { (IEnumerable<SelectListItem>)null, Enumerable.Empty<SelectListItem>() }, new[] { arrayItems, arrayItems }, new[] { listItems, listItems }, new[] { multiItems, multiItems }, new[] { selectItems, selectItems }, }; var attributeData = new Dictionary<string, string>(StringComparer.Ordinal) { // SelectTagHelper ignores all "multiple" attribute values. { "multiple", null }, { "mUltiple", string.Empty }, { "muLtiple", "true" }, { "Multiple", "false" }, { "MUltiple", "multiple" }, { "MuLtiple", "Multiple" }, { "mUlTiPlE", "mUlTiPlE" }, { "mULTiPlE", "MULTIPLE" }, { "mUlTIPlE", "Invalid" }, { "MULTiPLE", "0" }, { "MUlTIPLE", "1" }, { "MULTIPLE", "__true" }, // SelectTagHelper also ignores non-"multiple" attributes. { "multiple_", "multiple" }, { "not-multiple", "multiple" }, { "__multiple", "multiple" }, }; var theoryData = new TheoryData<IEnumerable<SelectListItem>, string, string, IEnumerable<SelectListItem>>(); foreach (var items in itemsData) { foreach (var attribute in attributeData) { theoryData.Add(items[0], attribute.Key, attribute.Value, items[1]); } } return theoryData; } } // Model type, model, allowMultiple expected value public static TheoryData<Type, object, bool> RealModelTypeDataSet { get { return new TheoryData<Type, object, bool> { { typeof(object), string.Empty, false }, { typeof(string), null, false }, { typeof(int?), null, false }, { typeof(int), 23, false }, { typeof(IEnumerable), null, true }, { typeof(IEnumerable<string>), null, true }, { typeof(List<int>), null, true }, { typeof(object), new[] { "", "", "" }, true }, { typeof(object), new List<string>(), true }, }; } } [Theory] [MemberData(nameof(GeneratesExpectedDataSet))] public async Task ProcessAsync_GeneratesExpectedOutput( object model, Type containerType, Func<object> modelAccessor, NameAndId nameAndId, string ignored) { // Arrange var originalAttributes = new TagHelperAttributeList { { "class", "form-control" }, }; var originalPostContent = "original content"; var expectedAttributes = new TagHelperAttributeList(originalAttributes) { { "id", nameAndId.Id }, { "name", nameAndId.Name }, { "valid", "from validation attributes" }, }; var expectedPreContent = "original pre-content"; var expectedContent = "original content"; var expectedPostContent = originalPostContent; var expectedTagName = "not-select"; var metadataProvider = new TestModelMetadataProvider(); var containerMetadata = metadataProvider.GetMetadataForType(containerType); var containerExplorer = metadataProvider.GetModelExplorerForType(containerType, model); var propertyMetadata = metadataProvider.GetMetadataForProperty(containerType, "Text"); var modelExplorer = containerExplorer.GetExplorerForExpression(propertyMetadata, modelAccessor()); var modelExpression = new ModelExpression(nameAndId.Name, modelExplorer); var tagHelperContext = new TagHelperContext( tagName: "select", allAttributes: new TagHelperAttributeList( Enumerable.Empty<TagHelperAttribute>()), items: new Dictionary<object, object>(), uniqueId: "test"); var output = new TagHelperOutput( expectedTagName, originalAttributes, getChildContentAsync: (useCachedResult, encoder) => { var tagHelperContent = new DefaultTagHelperContent(); tagHelperContent.SetContent("Something"); return Task.FromResult<TagHelperContent>(tagHelperContent); }) { TagMode = TagMode.SelfClosing, }; output.PreContent.SetContent(expectedPreContent); output.Content.SetContent(expectedContent); output.PostContent.SetContent(originalPostContent); var htmlGenerator = new TestableHtmlGenerator(metadataProvider) { ValidationAttributes = { { "valid", "from validation attributes" }, } }; var viewContext = TestableHtmlGenerator.GetViewContext(model, htmlGenerator, metadataProvider); var tagHelper = new SelectTagHelper(htmlGenerator) { For = modelExpression, ViewContext = viewContext, }; // Act tagHelper.Init(tagHelperContext); await tagHelper.ProcessAsync(tagHelperContext, output); // Assert Assert.Equal(TagMode.SelfClosing, output.TagMode); Assert.Equal(expectedAttributes, output.Attributes); Assert.Equal(expectedPreContent, output.PreContent.GetContent()); Assert.Equal(expectedContent, output.Content.GetContent()); Assert.Equal(expectedPostContent, output.PostContent.GetContent()); Assert.Equal(expectedTagName, output.TagName); Assert.Single( tagHelperContext.Items, entry => (Type)entry.Key == typeof(SelectTagHelper)); } [Theory] [MemberData(nameof(GeneratesExpectedDataSet))] public async Task ProcessAsync_WithItems_GeneratesExpectedOutput_DoesNotChangeSelectList( object model, Type containerType, Func<object> modelAccessor, NameAndId nameAndId, string expectedOptions) { // Arrange var originalAttributes = new TagHelperAttributeList { { "class", "form-control" }, }; var originalPostContent = "original content"; var expectedAttributes = new TagHelperAttributeList(originalAttributes) { { "id", nameAndId.Id }, { "name", nameAndId.Name }, { "valid", "from validation attributes" }, }; var expectedPreContent = "original pre-content"; var expectedContent = "original content"; var expectedPostContent = originalPostContent + expectedOptions; var expectedTagName = "select"; var metadataProvider = new TestModelMetadataProvider(); var containerMetadata = metadataProvider.GetMetadataForType(containerType); var containerExplorer = metadataProvider.GetModelExplorerForType(containerType, model); var propertyMetadata = metadataProvider.GetMetadataForProperty(containerType, "Text"); var modelExplorer = containerExplorer.GetExplorerForExpression(propertyMetadata, modelAccessor()); var modelExpression = new ModelExpression(nameAndId.Name, modelExplorer); var tagHelperContext = new TagHelperContext( tagName: "select", allAttributes: new TagHelperAttributeList( Enumerable.Empty<TagHelperAttribute>()), items: new Dictionary<object, object>(), uniqueId: "test"); var output = new TagHelperOutput( expectedTagName, originalAttributes, getChildContentAsync: (useCachedResult, encoder) => { var tagHelperContent = new DefaultTagHelperContent(); tagHelperContent.AppendHtml("Something"); return Task.FromResult<TagHelperContent>(tagHelperContent); }) { TagMode = TagMode.SelfClosing, }; output.PreContent.AppendHtml(expectedPreContent); output.Content.AppendHtml(expectedContent); output.PostContent.AppendHtml(originalPostContent); var htmlGenerator = new TestableHtmlGenerator(metadataProvider) { ValidationAttributes = { { "valid", "from validation attributes" }, } }; var viewContext = TestableHtmlGenerator.GetViewContext(model, htmlGenerator, metadataProvider); var items = new SelectList(new[] { "", "outer text", "inner text", "other text" }); var savedDisabled = items.Select(item => item.Disabled).ToList(); var savedGroup = items.Select(item => item.Group).ToList(); var savedSelected = items.Select(item => item.Selected).ToList(); var savedText = items.Select(item => item.Text).ToList(); var savedValue = items.Select(item => item.Value).ToList(); var tagHelper = new SelectTagHelper(htmlGenerator) { For = modelExpression, Items = items, ViewContext = viewContext, }; // Act tagHelper.Init(tagHelperContext); await tagHelper.ProcessAsync(tagHelperContext, output); // Assert Assert.Equal(TagMode.SelfClosing, output.TagMode); Assert.Equal(expectedAttributes, output.Attributes); Assert.Equal(expectedPreContent, output.PreContent.GetContent()); Assert.Equal(expectedContent, output.Content.GetContent()); Assert.Equal(expectedPostContent, HtmlContentUtilities.HtmlContentToString(output.PostContent)); Assert.Equal(expectedTagName, output.TagName); Assert.Single( tagHelperContext.Items, entry => (Type)entry.Key == typeof(SelectTagHelper)); Assert.Equal(savedDisabled, items.Select(item => item.Disabled)); Assert.Equal(savedGroup, items.Select(item => item.Group)); Assert.Equal(savedSelected, items.Select(item => item.Selected)); Assert.Equal(savedText, items.Select(item => item.Text)); Assert.Equal(savedValue, items.Select(item => item.Value)); } [Fact] public async Task ProcessAsync_WithItems_AndNoModelExpression_GeneratesExpectedOutput() { // Arrange var originalAttributes = new TagHelperAttributeList { { "class", "form-control" }, }; var originalPostContent = "original content"; var expectedAttributes = new TagHelperAttributeList(originalAttributes); var selectItems = new SelectList(Enumerable.Range(0, 5)); var expectedOptions = "<option>HtmlEncode[[0]]</option>" + Environment.NewLine + "<option>HtmlEncode[[1]]</option>" + Environment.NewLine + "<option>HtmlEncode[[2]]</option>" + Environment.NewLine + "<option>HtmlEncode[[3]]</option>" + Environment.NewLine + "<option>HtmlEncode[[4]]</option>" + Environment.NewLine; var expectedPreContent = "original pre-content"; var expectedContent = "original content"; var expectedPostContent = originalPostContent + expectedOptions; var expectedTagName = "select"; var tagHelperContext = new TagHelperContext( tagName: "select", allAttributes: new TagHelperAttributeList( Enumerable.Empty<TagHelperAttribute>()), items: new Dictionary<object, object>(), uniqueId: "test"); var output = new TagHelperOutput( expectedTagName, originalAttributes, getChildContentAsync: (useCachedResult, encoder) => { var tagHelperContent = new DefaultTagHelperContent(); tagHelperContent.AppendHtml("Something"); return Task.FromResult<TagHelperContent>(tagHelperContent); }) { TagMode = TagMode.SelfClosing, }; output.PreContent.AppendHtml(expectedPreContent); output.Content.AppendHtml(expectedContent); output.PostContent.AppendHtml(originalPostContent); var metadataProvider = new TestModelMetadataProvider(); var htmlGenerator = new TestableHtmlGenerator(metadataProvider); var viewContext = TestableHtmlGenerator.GetViewContext( model: null, htmlGenerator: htmlGenerator, metadataProvider: metadataProvider); var tagHelper = new SelectTagHelper(htmlGenerator) { Items = selectItems, ViewContext = viewContext, }; // Act tagHelper.Init(tagHelperContext); await tagHelper.ProcessAsync(tagHelperContext, output); // Assert Assert.Equal(TagMode.SelfClosing, output.TagMode); Assert.Equal(expectedAttributes, output.Attributes); Assert.Equal(expectedPreContent, output.PreContent.GetContent()); Assert.Equal(expectedContent, output.Content.GetContent()); Assert.Equal(expectedPostContent, HtmlContentUtilities.HtmlContentToString(output.PostContent)); Assert.Equal(expectedTagName, output.TagName); var kvp = Assert.Single(tagHelperContext.Items); Assert.Equal(typeof(SelectTagHelper), kvp.Key); Assert.Null(kvp.Value); } [Theory] [MemberData(nameof(GeneratesExpectedDataSet))] public async Task ProcessAsyncInTemplate_WithItems_GeneratesExpectedOutput_DoesNotChangeSelectList( object model, Type containerType, Func<object> modelAccessor, NameAndId nameAndId, string expectedOptions) { // Arrange var originalAttributes = new TagHelperAttributeList { { "class", "form-control" }, }; var originalPostContent = "original content"; var expectedAttributes = new TagHelperAttributeList(originalAttributes) { { "id", nameAndId.Id }, { "name", nameAndId.Name }, { "valid", "from validation attributes" }, }; var expectedPreContent = "original pre-content"; var expectedContent = "original content"; var expectedPostContent = originalPostContent + expectedOptions; var expectedTagName = "select"; var metadataProvider = new TestModelMetadataProvider(); var containerMetadata = metadataProvider.GetMetadataForType(containerType); var containerExplorer = metadataProvider.GetModelExplorerForType(containerType, model); var propertyMetadata = metadataProvider.GetMetadataForProperty(containerType, "Text"); var modelExplorer = containerExplorer.GetExplorerForExpression(propertyMetadata, modelAccessor()); var modelExpression = new ModelExpression(name: string.Empty, modelExplorer: modelExplorer); var tagHelperContext = new TagHelperContext( tagName: "select", allAttributes: new TagHelperAttributeList( Enumerable.Empty<TagHelperAttribute>()), items: new Dictionary<object, object>(), uniqueId: "test"); var output = new TagHelperOutput( expectedTagName, originalAttributes, getChildContentAsync: (useCachedResult, encoder) => { var tagHelperContent = new DefaultTagHelperContent(); tagHelperContent.AppendHtml("Something"); return Task.FromResult<TagHelperContent>(tagHelperContent); }) { TagMode = TagMode.SelfClosing, }; output.PreContent.AppendHtml(expectedPreContent); output.Content.AppendHtml(expectedContent); output.PostContent.AppendHtml(originalPostContent); var htmlGenerator = new TestableHtmlGenerator(metadataProvider) { ValidationAttributes = { { "valid", "from validation attributes" }, } }; var viewContext = TestableHtmlGenerator.GetViewContext(model, htmlGenerator, metadataProvider); viewContext.ViewData.TemplateInfo.HtmlFieldPrefix = nameAndId.Name; var items = new SelectList(new[] { "", "outer text", "inner text", "other text" }); var savedDisabled = items.Select(item => item.Disabled).ToList(); var savedGroup = items.Select(item => item.Group).ToList(); var savedSelected = items.Select(item => item.Selected).ToList(); var savedText = items.Select(item => item.Text).ToList(); var savedValue = items.Select(item => item.Value).ToList(); var tagHelper = new SelectTagHelper(htmlGenerator) { For = modelExpression, Items = items, ViewContext = viewContext, }; // Act tagHelper.Init(tagHelperContext); await tagHelper.ProcessAsync(tagHelperContext, output); // Assert Assert.Equal(TagMode.SelfClosing, output.TagMode); Assert.Equal(expectedAttributes, output.Attributes); Assert.Equal(expectedPreContent, output.PreContent.GetContent()); Assert.Equal(expectedContent, output.Content.GetContent()); Assert.Equal(expectedPostContent, HtmlContentUtilities.HtmlContentToString(output.PostContent)); Assert.Equal(expectedTagName, output.TagName); Assert.Single( tagHelperContext.Items, entry => (Type)entry.Key == typeof(SelectTagHelper)); Assert.Equal(savedDisabled, items.Select(item => item.Disabled)); Assert.Equal(savedGroup, items.Select(item => item.Group)); Assert.Equal(savedSelected, items.Select(item => item.Selected)); Assert.Equal(savedText, items.Select(item => item.Text)); Assert.Equal(savedValue, items.Select(item => item.Value)); } [Theory] [MemberData(nameof(ItemsAndMultipleDataSet))] public async Task ProcessAsync_CallsGeneratorWithExpectedValues_ItemsAndAttribute( IEnumerable<SelectListItem> inputItems, string attributeName, string attributeValue, IEnumerable<SelectListItem> expectedItems) { // Arrange var contextAttributes = new TagHelperAttributeList { // Provided for completeness. Select tag helper does not confirm AllAttributes set is consistent. { attributeName, attributeValue }, }; var originalAttributes = new TagHelperAttributeList { { attributeName, attributeValue }, }; var propertyName = "Property1"; var expectedTagName = "select"; var tagHelperContext = new TagHelperContext( tagName: "select", allAttributes: contextAttributes, items: new Dictionary<object, object>(), uniqueId: "test"); var output = new TagHelperOutput( expectedTagName, originalAttributes, getChildContentAsync: (useCachedResult, encoder) => { var tagHelperContent = new DefaultTagHelperContent(); tagHelperContent.SetContent("Something"); return Task.FromResult<TagHelperContent>(tagHelperContent); }); var metadataProvider = new EmptyModelMetadataProvider(); string model = null; var modelExplorer = metadataProvider.GetModelExplorerForType(typeof(string), model); var htmlGenerator = new Mock<IHtmlGenerator>(MockBehavior.Strict); var viewContext = TestableHtmlGenerator.GetViewContext(model, htmlGenerator.Object, metadataProvider); // Simulate a (model => model) scenario. E.g. the calling helper may appear in a low-level template. var modelExpression = new ModelExpression(string.Empty, modelExplorer); viewContext.ViewData.TemplateInfo.HtmlFieldPrefix = propertyName; var currentValues = new string[0]; htmlGenerator .Setup(real => real.GetCurrentValues( viewContext, modelExplorer, string.Empty, // expression false)) // allowMultiple .Returns(currentValues) .Verifiable(); htmlGenerator .Setup(real => real.GenerateSelect( viewContext, modelExplorer, null, // optionLabel string.Empty, // expression expectedItems, currentValues, false, // allowMultiple null)) // htmlAttributes .Returns((TagBuilder)null) .Verifiable(); var tagHelper = new SelectTagHelper(htmlGenerator.Object) { For = modelExpression, Items = inputItems, ViewContext = viewContext, }; // Act tagHelper.Init(tagHelperContext); await tagHelper.ProcessAsync(tagHelperContext, output); // Assert htmlGenerator.Verify(); var keyValuePair = Assert.Single( tagHelperContext.Items, entry => (Type)entry.Key == typeof(SelectTagHelper)); var actualCurrentValues = Assert.IsType<CurrentValues>(keyValuePair.Value); Assert.Same(currentValues, actualCurrentValues.Values); } [Theory] [MemberData(nameof(RealModelTypeDataSet))] public async Task TagHelper_CallsGeneratorWithExpectedValues_RealModelType( Type modelType, object model, bool allowMultiple) { // Arrange var contextAttributes = new TagHelperAttributeList( Enumerable.Empty<TagHelperAttribute>()); var originalAttributes = new TagHelperAttributeList(); var propertyName = "Property1"; var tagName = "select"; var tagHelperContext = new TagHelperContext( tagName: "select", allAttributes: contextAttributes, items: new Dictionary<object, object>(), uniqueId: "test"); var output = new TagHelperOutput( tagName, originalAttributes, getChildContentAsync: (useCachedResult, encoder) => { var tagHelperContent = new DefaultTagHelperContent(); tagHelperContent.SetContent("Something"); return Task.FromResult<TagHelperContent>(tagHelperContent); }); var metadataProvider = new EmptyModelMetadataProvider(); var modelExplorer = metadataProvider.GetModelExplorerForType(modelType, model); var modelExpression = new ModelExpression(propertyName, modelExplorer); var htmlGenerator = new Mock<IHtmlGenerator>(MockBehavior.Strict); var viewContext = TestableHtmlGenerator.GetViewContext(model, htmlGenerator.Object, metadataProvider); var currentValues = new string[0]; htmlGenerator .Setup(real => real.GetCurrentValues( viewContext, modelExplorer, propertyName, // expression allowMultiple)) .Returns(currentValues) .Verifiable(); htmlGenerator .Setup(real => real.GenerateSelect( viewContext, modelExplorer, null, // optionLabel propertyName, // expression It.IsAny<IEnumerable<SelectListItem>>(), currentValues, allowMultiple, null)) // htmlAttributes .Returns((TagBuilder)null) .Verifiable(); var tagHelper = new SelectTagHelper(htmlGenerator.Object) { For = modelExpression, ViewContext = viewContext, }; // Act tagHelper.Init(tagHelperContext); await tagHelper.ProcessAsync(tagHelperContext, output); // Assert htmlGenerator.Verify(); var keyValuePair = Assert.Single( tagHelperContext.Items, entry => (Type)entry.Key == typeof(SelectTagHelper)); var actualCurrentValues = Assert.IsType<CurrentValues>(keyValuePair.Value); Assert.Same(currentValues, actualCurrentValues.Values); } [Fact] public void Process_WithEmptyForName_Throws() { // Arrange var expectedMessage = "The name of an HTML field cannot be null or empty. Instead use methods " + "Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper.Editor or Microsoft.AspNetCore.Mvc.Rendering." + "IHtmlHelper`1.EditorFor with a non-empty htmlFieldName argument value."; var expectedTagName = "select"; var metadataProvider = new EmptyModelMetadataProvider(); var htmlGenerator = new TestableHtmlGenerator(metadataProvider); var model = "model-value"; var modelExplorer = metadataProvider.GetModelExplorerForType(typeof(string), model); var modelExpression = new ModelExpression(name: string.Empty, modelExplorer: modelExplorer); var viewContext = TestableHtmlGenerator.GetViewContext(model, htmlGenerator, metadataProvider); var tagHelper = new SelectTagHelper(htmlGenerator) { For = modelExpression, ViewContext = viewContext, }; var context = new TagHelperContext(new TagHelperAttributeList(), new Dictionary<object, object>(), "test"); var output = new TagHelperOutput( expectedTagName, new TagHelperAttributeList(), (_, __) => Task.FromResult<TagHelperContent>(new DefaultTagHelperContent())); // Act & Assert ExceptionAssert.ThrowsArgument( () => tagHelper.Process(context, output), paramName: "expression", exceptionMessage: expectedMessage); } [Fact] public void Process_WithEmptyForName_DoesNotThrow_WithName() { // Arrange var expectedAttributeValue = "-expression-"; var expectedTagName = "select"; var metadataProvider = new EmptyModelMetadataProvider(); var htmlGenerator = new TestableHtmlGenerator(metadataProvider); var model = "model-value"; var modelExplorer = metadataProvider.GetModelExplorerForType(typeof(string), model); var modelExpression = new ModelExpression(name: string.Empty, modelExplorer: modelExplorer); var viewContext = TestableHtmlGenerator.GetViewContext(model, htmlGenerator, metadataProvider); var tagHelper = new SelectTagHelper(htmlGenerator) { For = modelExpression, Name = expectedAttributeValue, ViewContext = viewContext, }; var attributes = new TagHelperAttributeList { { "name", expectedAttributeValue }, }; var context = new TagHelperContext(attributes, new Dictionary<object, object>(), "test"); var output = new TagHelperOutput( expectedTagName, new TagHelperAttributeList(), (_, __) => Task.FromResult<TagHelperContent>(new DefaultTagHelperContent())); // Act tagHelper.Process(context, output); // Assert Assert.Equal(expectedTagName, output.TagName); Assert.False(output.IsContentModified); var attribute = Assert.Single(output.Attributes); Assert.Equal("name", attribute.Name); Assert.Equal(expectedAttributeValue, attribute.Value); } [Fact] public void Process_PassesNameThrough_EvenIfNullFor() { // Arrange var expectedAttributeValue = "-expression-"; var expectedTagName = "span"; var selectList = Array.Empty<SelectListItem>(); var generator = new Mock<IHtmlGenerator>(MockBehavior.Strict); generator .Setup(gen => gen.GenerateGroupsAndOptions(/* optionLabel: */ null, selectList)) .Returns(HtmlString.Empty) .Verifiable(); var metadataProvider = new EmptyModelMetadataProvider(); var viewContext = TestableHtmlGenerator.GetViewContext( model: null, htmlGenerator: generator.Object, metadataProvider: metadataProvider); var tagHelper = new SelectTagHelper(generator.Object) { Items = selectList, Name = expectedAttributeValue, ViewContext = viewContext, }; var attributes = new TagHelperAttributeList { { "name", expectedAttributeValue }, }; var tagHelperContext = new TagHelperContext(attributes, new Dictionary<object, object>(), "test"); var output = new TagHelperOutput( expectedTagName, new TagHelperAttributeList(), (_, __) => Task.FromResult<TagHelperContent>(new DefaultTagHelperContent())); // Act tagHelper.Process(tagHelperContext, output); // Assert generator.VerifyAll(); Assert.Equal(expectedTagName, output.TagName); var attribute = Assert.Single(output.Attributes); Assert.Equal("name", attribute.Name); Assert.Equal(expectedAttributeValue, attribute.Value); }
SelectTagHelperTest
csharp
AvaloniaUI__Avalonia
src/Linux/Avalonia.LinuxFramebuffer/Input/EvDev/EvDevBackend.cs
{ "start": 235, "end": 3637 }
public class ____ : IInputBackend { private readonly EvDevDeviceDescription[] _deviceDescriptions; private readonly List<EvDevDeviceHandler> _handlers = new List<EvDevDeviceHandler>(); private int _epoll; private Action<RawInputEventArgs>? _onInput; private IInputRoot? _inputRoot; public EvDevBackend(EvDevDeviceDescription[] devices) { _deviceDescriptions = devices; } unsafe void InputThread() { const int MaxEvents = 16; var events = stackalloc epoll_event[MaxEvents]; while (true) { var eventCount = Math.Min(MaxEvents, epoll_wait(_epoll, events, MaxEvents, 1000)); for (var c = 0; c < eventCount; c++) { try { var ev = events[c]; var handler = _handlers[(int)ev.data.u32]; handler.HandleEvents(); } catch (Exception e) { Console.Error.WriteLine(e.ToString()); } } } } private void OnRawEvent(RawInputEventArgs obj) => _onInput?.Invoke(obj); public void Initialize(IScreenInfoProvider info, Action<RawInputEventArgs> onInput) { _onInput = onInput; _epoll = epoll_create1(0); for (var c = 0; c < _deviceDescriptions.Length; c++) { var description = _deviceDescriptions[c]; var dev = EvDevDevice.Open(description.Path ?? string.Empty); EvDevDeviceHandler handler; if (description is EvDevTouchScreenDeviceDescription touch) handler = new EvDevSingleTouchScreen(dev, touch, info) { InputRoot = _inputRoot }; else throw new Exception("Unknown device description type " + description.GetType().FullName); handler.OnEvent += OnRawEvent; _handlers.Add(handler); var ev = new epoll_event { events = EPOLLIN, data = { u32 = (uint)c } }; epoll_ctl(_epoll, EPOLL_CTL_ADD, dev.Fd, ref ev); } new Thread(InputThread) { IsBackground = true }.Start(); } public void SetInputRoot(IInputRoot root) { _inputRoot = root; foreach (var h in _handlers) h.InputRoot = root; } public static EvDevBackend CreateFromEnvironment() { var env = Environment.GetEnvironmentVariables(); var deviceDescriptions = new List<EvDevDeviceDescription>(); foreach (string key in env.Keys) { if (key.StartsWith("AVALONIA_EVDEV_DEVICE_")) { var value = (string)env[key]!; deviceDescriptions.Add(EvDevDeviceDescription.ParseFromEnv(value)); } } if (deviceDescriptions.Count == 0) throw new Exception( "No device device description found, specify devices by adding AVALONIA_EVDEV_DEVICE_{name} environment variables"); return new EvDevBackend(deviceDescriptions.ToArray()); } } }
EvDevBackend
csharp
CommunityToolkit__WindowsCommunityToolkit
Microsoft.Toolkit.Uwp.UI/Extensions/Markup/BitmapIconSourceExtension.cs
{ "start": 532, "end": 1213 }
public sealed class ____ : MarkupExtension { /// <summary> /// Gets or sets the <see cref="Uri"/> representing the image to display. /// </summary> public Uri Source { get; set; } /// <summary> /// Gets or sets a value indicating whether to display the icon as monochrome. /// </summary> public bool ShowAsMonochrome { get; set; } /// <inheritdoc/> protected override object ProvideValue() { return new BitmapIconSource { ShowAsMonochrome = ShowAsMonochrome, UriSource = Source }; } } }
BitmapIconSourceExtension
csharp
abpframework__abp
framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/ISecurityLogManager.cs
{ "start": 79, "end": 184 }
public interface ____ { Task SaveAsync(Action<SecurityLogInfo>? saveAction = null); }
ISecurityLogManager
csharp
DuendeSoftware__IdentityServer
identity-server/src/IdentityServer/Models/IdentityResources.cs
{ "start": 1046, "end": 1753 }
public class ____ : IdentityResource { /// <summary> /// Initializes a new instance of the <see cref="Profile"/> class. /// </summary> public Profile() { Name = IdentityServerConstants.StandardScopes.Profile; DisplayName = "User profile"; Description = "Your user profile information (first name, last name, etc.)"; Emphasize = true; UserClaims = Constants.ScopeToClaimsMapping[IdentityServerConstants.StandardScopes.Profile].ToList(); } } /// <summary> /// Models the standard email scope /// </summary> /// <seealso cref="IdentityServer.Models.IdentityResource" />
Profile
csharp
simplcommerce__SimplCommerce
src/Modules/SimplCommerce.Module.HangfireJobs/Internal/BackgroundJobArgsHelper.cs
{ "start": 265, "end": 1057 }
interface ____ jobType.GetInterfaces()) { if (!@interface.IsGenericType) { continue; } if (@interface.GetGenericTypeDefinition() != typeof(IBackgroundJob<>)) { continue; } var genericArgs = @interface.GetGenericArguments(); if (genericArgs.Length != 1) { continue; } return genericArgs[0]; } throw new Exception($"Could not find type of the job args. Ensure that given type implements the {typeof(IBackgroundJob<>).AssemblyQualifiedName} interface. Given job type: {jobType.AssemblyQualifiedName}"); } } }
in
csharp
grandnode__grandnode2
src/Modules/Grand.Module.Api/Commands/Handlers/Catalog/DeleteProductAttributeMappingCommandHandler.cs
{ "start": 210, "end": 939 }
public class ____ : IRequestHandler<DeleteProductAttributeMappingCommand, bool> { private readonly IProductAttributeService _productAttributeService; public DeleteProductAttributeMappingCommandHandler(IProductAttributeService productAttributeService) { _productAttributeService = productAttributeService; } public async Task<bool> Handle(DeleteProductAttributeMappingCommand request, CancellationToken cancellationToken) { //insert mapping var productAttributeMapping = request.Model.ToEntity(); await _productAttributeService.DeleteProductAttributeMapping(productAttributeMapping, request.Product.Id); return true; } }
DeleteProductAttributeMappingCommandHandler
csharp
JamesNK__Newtonsoft.Json
Src/Newtonsoft.Json/Bson/BsonToken.cs
{ "start": 4012, "end": 4290 }
internal class ____ : BsonValue { public BsonBinaryType BinaryType { get; set; } public BsonBinary(byte[] value, BsonBinaryType binaryType) : base(value, BsonType.Binary) { BinaryType = binaryType; } }
BsonBinary
csharp
dotnet__aspire
src/Shared/CompareHelpers.cs
{ "start": 261, "end": 1596 }
internal static class ____ { // This method is used to compare two keys in a way that avoids timing attacks. public static bool CompareKey(byte[] expectedKeyBytes, string requestKey) { const int StackAllocThreshold = 256; var requestByteCount = Encoding.UTF8.GetByteCount(requestKey); // A rented array could have previous data. However, we're trimming it to the exact byte count we need. // That means all used bytes are overwritten by the following Encoding.GetBytes call. byte[]? requestPooled = null; var requestBytesSpan = (requestByteCount <= StackAllocThreshold ? stackalloc byte[StackAllocThreshold] : (requestPooled = ArrayPool<byte>.Shared.Rent(requestByteCount))).Slice(0, requestByteCount); try { var encodedByteCount = Encoding.UTF8.GetBytes(requestKey, requestBytesSpan); Debug.Assert(encodedByteCount == requestBytesSpan.Length, "Should match because span was previously trimmed to byte count value."); return CryptographicOperations.FixedTimeEquals(expectedKeyBytes, requestBytesSpan); } finally { if (requestPooled != null) { ArrayPool<byte>.Shared.Return(requestPooled); } } } }
CompareHelpers
csharp
StackExchange__StackExchange.Redis
src/StackExchange.Redis/ResultProcessor.Digest.cs
{ "start": 87, "end": 260 }
partial class ____ { // VectorSet result processors public static readonly ResultProcessor<ValueCondition?> Digest = new DigestProcessor();
ResultProcessor
csharp
unoplatform__uno
src/Uno.UWP/Generated/3.0.0.0/Windows.System.RemoteSystems/RemoteSystemSessionParticipantWatcher.cs
{ "start": 303, "end": 7088 }
public partial class ____ { #if __ANDROID__ || __IOS__ || __TVOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ internal RemoteSystemSessionParticipantWatcher() { } #endif #if __ANDROID__ || __IOS__ || __TVOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "__TVOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__")] public global::Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcherStatus Status { get { throw new global::System.NotImplementedException("The member RemoteSystemSessionParticipantWatcherStatus RemoteSystemSessionParticipantWatcher.Status is not implemented. For more information, visit https://aka.platform.uno/notimplemented#m=RemoteSystemSessionParticipantWatcherStatus%20RemoteSystemSessionParticipantWatcher.Status"); } } #endif #if __ANDROID__ || __IOS__ || __TVOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "__TVOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__")] public void Start() { global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcher", "void RemoteSystemSessionParticipantWatcher.Start()"); } #endif #if __ANDROID__ || __IOS__ || __TVOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "__TVOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__")] public void Stop() { global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcher", "void RemoteSystemSessionParticipantWatcher.Stop()"); } #endif // Forced skipping of method Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcher.Status.get // Forced skipping of method Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcher.Added.add // Forced skipping of method Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcher.Added.remove // Forced skipping of method Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcher.Removed.add // Forced skipping of method Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcher.Removed.remove // Forced skipping of method Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcher.EnumerationCompleted.add // Forced skipping of method Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcher.EnumerationCompleted.remove #if __ANDROID__ || __IOS__ || __TVOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "__TVOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__")] public event global::Windows.Foundation.TypedEventHandler<global::Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcher, global::Windows.System.RemoteSystems.RemoteSystemSessionParticipantAddedEventArgs> Added { [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "__TVOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__")] add { global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcher", "event TypedEventHandler<RemoteSystemSessionParticipantWatcher, RemoteSystemSessionParticipantAddedEventArgs> RemoteSystemSessionParticipantWatcher.Added"); } [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "__TVOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__")] remove { global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcher", "event TypedEventHandler<RemoteSystemSessionParticipantWatcher, RemoteSystemSessionParticipantAddedEventArgs> RemoteSystemSessionParticipantWatcher.Added"); } } #endif #if __ANDROID__ || __IOS__ || __TVOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "__TVOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__")] public event global::Windows.Foundation.TypedEventHandler<global::Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcher, object> EnumerationCompleted { [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "__TVOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__")] add { global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcher", "event TypedEventHandler<RemoteSystemSessionParticipantWatcher, object> RemoteSystemSessionParticipantWatcher.EnumerationCompleted"); } [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "__TVOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__")] remove { global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcher", "event TypedEventHandler<RemoteSystemSessionParticipantWatcher, object> RemoteSystemSessionParticipantWatcher.EnumerationCompleted"); } } #endif #if __ANDROID__ || __IOS__ || __TVOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "__TVOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__")] public event global::Windows.Foundation.TypedEventHandler<global::Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcher, global::Windows.System.RemoteSystems.RemoteSystemSessionParticipantRemovedEventArgs> Removed { [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "__TVOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__")] add { global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcher", "event TypedEventHandler<RemoteSystemSessionParticipantWatcher, RemoteSystemSessionParticipantRemovedEventArgs> RemoteSystemSessionParticipantWatcher.Removed"); } [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "__TVOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__")] remove { global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcher", "event TypedEventHandler<RemoteSystemSessionParticipantWatcher, RemoteSystemSessionParticipantRemovedEventArgs> RemoteSystemSessionParticipantWatcher.Removed"); } } #endif } }
RemoteSystemSessionParticipantWatcher
csharp
CommunityToolkit__dotnet
tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests/Test_UsePartialPropertyForObservablePropertyCodeFixer.cs
{ "start": 13996, "end": 15516 }
partial class ____ : ObservableObject { // This is a comment. // This is more comment. [ObservableProperty] public partial int I { get; set; } } """; CSharpCodeFixTest test = new(LanguageVersion.Preview) { TestCode = original, FixedCode = @fixed, ReferenceAssemblies = ReferenceAssemblies.Net.Net80, }; test.TestState.AdditionalReferences.Add(typeof(ObservableObject).Assembly); test.ExpectedDiagnostics.AddRange(new[] { // /0/Test0.cs(8,17): info MVVMTK0042: The field C.i using [ObservableProperty] can be converted to a partial property instead, which is recommended (doing so improves the developer experience and allows other generators and analyzers to correctly see the generated property as well) CSharpCodeFixVerifier.Diagnostic().WithSpan(8, 17, 8, 18).WithArguments("C", "i"), }); test.FixedState.ExpectedDiagnostics.AddRange(new[] { // /0/Test0.cs(8,24): error CS9248: Partial property 'C.I' must have an implementation part. DiagnosticResult.CompilerError("CS9248").WithSpan(8, 24, 8, 25).WithArguments("C.I"), }); await test.RunAsync(); } [TestMethod] public async Task SimpleFieldWithNoReferences_WithXmlComment() { string original = """ using CommunityToolkit.Mvvm.ComponentModel;
C
csharp
graphql-dotnet__graphql-dotnet
src/GraphQL/Extensions/GraphQLExtensions.cs
{ "start": 3878, "end": 6631 }
interface ____ union). /// </summary> public static bool IsOutputType(this IGraphType type) { var (namedType, namedType2) = type.GetNamedTypes(); return namedType is ScalarGraphType || namedType is IObjectGraphType || namedType is IInterfaceGraphType || namedType is UnionGraphType || typeof(ScalarGraphType).IsAssignableFrom(namedType2) || typeof(IObjectGraphType).IsAssignableFrom(namedType2) || typeof(IInterfaceGraphType).IsAssignableFrom(namedType2) || typeof(UnionGraphType).IsAssignableFrom(namedType2); } /// <summary> /// Indicates if the graph type is an input object graph type. /// </summary> public static bool IsInputObjectType(this IGraphType type) { var (namedType, namedType2) = type.GetNamedTypes(); return namedType is IInputObjectGraphType || typeof(IInputObjectGraphType).IsAssignableFrom(namedType2); } internal static bool IsGraphQLTypeReference(this IGraphType? type) { var (namedType, _) = type.GetNamedTypes(); return namedType is GraphQLTypeReference; } internal static (IGraphType? resolvedType, Type? type) GetNamedTypes(this IGraphType? type) { return type switch { NonNullGraphType nonNull => nonNull.ResolvedType != null ? GetNamedTypes(nonNull.ResolvedType) : (null, GetNamedType(nonNull.Type!)), ListGraphType list => list.ResolvedType != null ? GetNamedTypes(list.ResolvedType) : (null, GetNamedType(list.Type!)), _ => (type, null) }; } /// <summary> /// Unwraps any list/non-null graph type wrappers from a graph type and returns the base graph type. /// </summary> public static IGraphType GetNamedType(this IGraphType type) { if (type == null) return null!; var (namedType, _) = type.GetNamedTypes(); return namedType ?? throw new NotSupportedException("Please set ResolvedType property before calling this method or call GetNamedType(this Type type) instead"); } /// <summary> /// Unwraps any list/non-null graph type wrappers from a graph type and returns the base graph type. /// </summary> public static Type GetNamedType(this Type type) { if (!type.IsGenericType) return type; var genericDef = type.GetGenericTypeDefinition(); return genericDef == typeof(NonNullGraphType<>) || genericDef == typeof(ListGraphType<>) ? GetNamedType(type.GenericTypeArguments[0]) : type; } /// <summary> /// An Interface defines a list of fields; Object types that implement that
or
csharp
bitwarden__server
util/PostgresMigrations/Migrations/20211021204521_SetMaxAutoscaleSeatsToCurrentSeatCount.cs
{ "start": 122, "end": 637 }
public partial class ____ : Migration { private const string _scriptLocation = "PostgresMigrations.HelperScripts.2021-10-21_00_SetMaxAutoscaleSeatCount.psql"; protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.Sql(CoreHelpers.GetEmbeddedResourceContentsAsync(_scriptLocation)); } protected override void Down(MigrationBuilder migrationBuilder) { throw new Exception("Irreversible migration"); } }
SetMaxAutoscaleSeatsToCurrentSeatCount
csharp
dotnet__orleans
src/Orleans.Transactions.TestKit.Base/Grains/ITransactionAttributionGrain.cs
{ "start": 1938, "end": 3532 }
public static class ____ { public static ITransactionAttributionGrain GetTransactionAttributionGrain(this IGrainFactory grainFactory, Guid id, TransactionOption? option = null) { if(!option.HasValue) { return new NoAttributionGrain(grainFactory.GetGrain<INoAttributionGrain>(id)); } switch(option.Value) { case TransactionOption.Suppress: return new SuppressAttributionGrain(grainFactory.GetGrain<ISuppressAttributionGrain>(id)); case TransactionOption.CreateOrJoin: return new CreateOrJoinAttributionGrain(grainFactory.GetGrain<ICreateOrJoinAttributionGrain>(id)); case TransactionOption.Create: return new CreateAttributionGrain(grainFactory.GetGrain<ICreateAttributionGrain>(id)); case TransactionOption.Join: return new JoinAttributionGrain(grainFactory.GetGrain<IJoinAttributionGrain>(id)); case TransactionOption.Supported: return new SupportedAttributionGrain(grainFactory.GetGrain<ISupportedAttributionGrain>(id)); case TransactionOption.NotAllowed: return new NotAllowedAttributionGrain(grainFactory.GetGrain<INotAllowedAttributionGrain>(id)); default: throw new NotSupportedException($"Transaction option {option.Value} is not supported."); } } [GenerateSerializer]
TransactionAttributionGrainExtensions
csharp
CommunityToolkit__dotnet
src/CommunityToolkit.Diagnostics/Generated/Guard.Comparable.Numeric.g.cs
{ "start": 390, "end": 191881 }
partial class ____ { /// <summary> /// Asserts that the input value must be equal to a specified value. /// </summary> /// <param name="value">The input <see cref="byte"/> value to test.</param> /// <param name="target">The target <see cref="byte"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is != <paramref name="target"/>.</exception> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsEqualTo(byte value, byte target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { return; } ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be not equal to a specified value. /// </summary> /// <param name="value">The input <see cref="byte"/> value to test.</param> /// <param name="target">The target <see cref="byte"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is == <paramref name="target"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotEqualTo(byte value, byte target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { return; } ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be less than a specified value. /// </summary> /// <param name="value">The input <see cref="byte"/> value to test.</param> /// <param name="maximum">The exclusive maximum <see cref="byte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThan(byte value, byte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name); } /// <summary> /// Asserts that the input value must be less than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="byte"/> value to test.</param> /// <param name="maximum">The inclusive maximum <see cref="byte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThanOrEqualTo(byte value, byte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name); } /// <summary> /// Asserts that the input value must be greater than a specified value. /// </summary> /// <param name="value">The input <see cref="byte"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="byte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThan(byte value, byte minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name); } /// <summary> /// Asserts that the input value must be greater than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="byte"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="byte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThanOrEqualTo(byte value, byte minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name); } /// <summary> /// Asserts that the input value must be in a given range. /// </summary> /// <param name="value">The input <see cref="byte"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="byte"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="byte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsInRange(byte value, byte minimum, byte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given range. /// </summary> /// <param name="value">The input <see cref="byte"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="byte"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="byte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotInRange(byte value, byte minimum, byte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="byte"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="byte"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="byte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetween(byte value, byte minimum, byte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="byte"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="byte"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="byte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetween(byte value, byte minimum, byte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="byte"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="byte"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="byte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or > <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetweenOrEqualTo(byte value, byte minimum, byte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="byte"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="byte"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="byte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt;= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetweenOrEqualTo(byte value, byte minimum, byte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be equal to a specified value. /// </summary> /// <param name="value">The input <see cref="sbyte"/> value to test.</param> /// <param name="target">The target <see cref="sbyte"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is != <paramref name="target"/>.</exception> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsEqualTo(sbyte value, sbyte target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { return; } ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be not equal to a specified value. /// </summary> /// <param name="value">The input <see cref="sbyte"/> value to test.</param> /// <param name="target">The target <see cref="sbyte"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is == <paramref name="target"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotEqualTo(sbyte value, sbyte target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { return; } ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be less than a specified value. /// </summary> /// <param name="value">The input <see cref="sbyte"/> value to test.</param> /// <param name="maximum">The exclusive maximum <see cref="sbyte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThan(sbyte value, sbyte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name); } /// <summary> /// Asserts that the input value must be less than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="sbyte"/> value to test.</param> /// <param name="maximum">The inclusive maximum <see cref="sbyte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThanOrEqualTo(sbyte value, sbyte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name); } /// <summary> /// Asserts that the input value must be greater than a specified value. /// </summary> /// <param name="value">The input <see cref="sbyte"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="sbyte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThan(sbyte value, sbyte minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name); } /// <summary> /// Asserts that the input value must be greater than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="sbyte"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="sbyte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThanOrEqualTo(sbyte value, sbyte minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name); } /// <summary> /// Asserts that the input value must be in a given range. /// </summary> /// <param name="value">The input <see cref="sbyte"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="sbyte"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="sbyte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsInRange(sbyte value, sbyte minimum, sbyte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given range. /// </summary> /// <param name="value">The input <see cref="sbyte"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="sbyte"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="sbyte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotInRange(sbyte value, sbyte minimum, sbyte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="sbyte"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="sbyte"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="sbyte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetween(sbyte value, sbyte minimum, sbyte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="sbyte"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="sbyte"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="sbyte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetween(sbyte value, sbyte minimum, sbyte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="sbyte"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="sbyte"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="sbyte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or > <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetweenOrEqualTo(sbyte value, sbyte minimum, sbyte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="sbyte"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="sbyte"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="sbyte"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt;= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetweenOrEqualTo(sbyte value, sbyte minimum, sbyte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be equal to a specified value. /// </summary> /// <param name="value">The input <see cref="short"/> value to test.</param> /// <param name="target">The target <see cref="short"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is != <paramref name="target"/>.</exception> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsEqualTo(short value, short target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { return; } ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be not equal to a specified value. /// </summary> /// <param name="value">The input <see cref="short"/> value to test.</param> /// <param name="target">The target <see cref="short"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is == <paramref name="target"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotEqualTo(short value, short target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { return; } ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be less than a specified value. /// </summary> /// <param name="value">The input <see cref="short"/> value to test.</param> /// <param name="maximum">The exclusive maximum <see cref="short"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThan(short value, short maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name); } /// <summary> /// Asserts that the input value must be less than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="short"/> value to test.</param> /// <param name="maximum">The inclusive maximum <see cref="short"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThanOrEqualTo(short value, short maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name); } /// <summary> /// Asserts that the input value must be greater than a specified value. /// </summary> /// <param name="value">The input <see cref="short"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="short"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThan(short value, short minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name); } /// <summary> /// Asserts that the input value must be greater than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="short"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="short"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThanOrEqualTo(short value, short minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name); } /// <summary> /// Asserts that the input value must be in a given range. /// </summary> /// <param name="value">The input <see cref="short"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="short"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="short"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsInRange(short value, short minimum, short maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given range. /// </summary> /// <param name="value">The input <see cref="short"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="short"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="short"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotInRange(short value, short minimum, short maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="short"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="short"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="short"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetween(short value, short minimum, short maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="short"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="short"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="short"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetween(short value, short minimum, short maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="short"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="short"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="short"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or > <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetweenOrEqualTo(short value, short minimum, short maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="short"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="short"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="short"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt;= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetweenOrEqualTo(short value, short minimum, short maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be equal to a specified value. /// </summary> /// <param name="value">The input <see cref="ushort"/> value to test.</param> /// <param name="target">The target <see cref="ushort"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is != <paramref name="target"/>.</exception> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsEqualTo(ushort value, ushort target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { return; } ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be not equal to a specified value. /// </summary> /// <param name="value">The input <see cref="ushort"/> value to test.</param> /// <param name="target">The target <see cref="ushort"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is == <paramref name="target"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotEqualTo(ushort value, ushort target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { return; } ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be less than a specified value. /// </summary> /// <param name="value">The input <see cref="ushort"/> value to test.</param> /// <param name="maximum">The exclusive maximum <see cref="ushort"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThan(ushort value, ushort maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name); } /// <summary> /// Asserts that the input value must be less than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="ushort"/> value to test.</param> /// <param name="maximum">The inclusive maximum <see cref="ushort"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThanOrEqualTo(ushort value, ushort maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name); } /// <summary> /// Asserts that the input value must be greater than a specified value. /// </summary> /// <param name="value">The input <see cref="ushort"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="ushort"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThan(ushort value, ushort minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name); } /// <summary> /// Asserts that the input value must be greater than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="ushort"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="ushort"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThanOrEqualTo(ushort value, ushort minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name); } /// <summary> /// Asserts that the input value must be in a given range. /// </summary> /// <param name="value">The input <see cref="ushort"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="ushort"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="ushort"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsInRange(ushort value, ushort minimum, ushort maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given range. /// </summary> /// <param name="value">The input <see cref="ushort"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="ushort"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="ushort"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotInRange(ushort value, ushort minimum, ushort maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="ushort"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="ushort"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="ushort"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetween(ushort value, ushort minimum, ushort maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="ushort"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="ushort"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="ushort"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetween(ushort value, ushort minimum, ushort maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="ushort"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="ushort"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="ushort"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or > <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetweenOrEqualTo(ushort value, ushort minimum, ushort maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="ushort"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="ushort"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="ushort"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt;= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetweenOrEqualTo(ushort value, ushort minimum, ushort maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be equal to a specified value. /// </summary> /// <param name="value">The input <see cref="char"/> value to test.</param> /// <param name="target">The target <see cref="char"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is != <paramref name="target"/>.</exception> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsEqualTo(char value, char target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { return; } ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be not equal to a specified value. /// </summary> /// <param name="value">The input <see cref="char"/> value to test.</param> /// <param name="target">The target <see cref="char"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is == <paramref name="target"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotEqualTo(char value, char target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { return; } ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be less than a specified value. /// </summary> /// <param name="value">The input <see cref="char"/> value to test.</param> /// <param name="maximum">The exclusive maximum <see cref="char"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThan(char value, char maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name); } /// <summary> /// Asserts that the input value must be less than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="char"/> value to test.</param> /// <param name="maximum">The inclusive maximum <see cref="char"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThanOrEqualTo(char value, char maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name); } /// <summary> /// Asserts that the input value must be greater than a specified value. /// </summary> /// <param name="value">The input <see cref="char"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="char"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThan(char value, char minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name); } /// <summary> /// Asserts that the input value must be greater than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="char"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="char"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThanOrEqualTo(char value, char minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name); } /// <summary> /// Asserts that the input value must be in a given range. /// </summary> /// <param name="value">The input <see cref="char"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="char"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="char"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsInRange(char value, char minimum, char maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given range. /// </summary> /// <param name="value">The input <see cref="char"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="char"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="char"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotInRange(char value, char minimum, char maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="char"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="char"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="char"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetween(char value, char minimum, char maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="char"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="char"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="char"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetween(char value, char minimum, char maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="char"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="char"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="char"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or > <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetweenOrEqualTo(char value, char minimum, char maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="char"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="char"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="char"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt;= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetweenOrEqualTo(char value, char minimum, char maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be equal to a specified value. /// </summary> /// <param name="value">The input <see cref="int"/> value to test.</param> /// <param name="target">The target <see cref="int"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is != <paramref name="target"/>.</exception> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsEqualTo(int value, int target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { return; } ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be not equal to a specified value. /// </summary> /// <param name="value">The input <see cref="int"/> value to test.</param> /// <param name="target">The target <see cref="int"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is == <paramref name="target"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotEqualTo(int value, int target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { return; } ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be less than a specified value. /// </summary> /// <param name="value">The input <see cref="int"/> value to test.</param> /// <param name="maximum">The exclusive maximum <see cref="int"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThan(int value, int maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name); } /// <summary> /// Asserts that the input value must be less than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="int"/> value to test.</param> /// <param name="maximum">The inclusive maximum <see cref="int"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThanOrEqualTo(int value, int maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name); } /// <summary> /// Asserts that the input value must be greater than a specified value. /// </summary> /// <param name="value">The input <see cref="int"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="int"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThan(int value, int minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name); } /// <summary> /// Asserts that the input value must be greater than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="int"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="int"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThanOrEqualTo(int value, int minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name); } /// <summary> /// Asserts that the input value must be in a given range. /// </summary> /// <param name="value">The input <see cref="int"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="int"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="int"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsInRange(int value, int minimum, int maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given range. /// </summary> /// <param name="value">The input <see cref="int"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="int"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="int"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotInRange(int value, int minimum, int maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="int"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="int"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="int"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetween(int value, int minimum, int maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="int"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="int"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="int"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetween(int value, int minimum, int maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="int"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="int"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="int"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or > <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetweenOrEqualTo(int value, int minimum, int maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="int"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="int"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="int"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt;= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetweenOrEqualTo(int value, int minimum, int maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be equal to a specified value. /// </summary> /// <param name="value">The input <see cref="uint"/> value to test.</param> /// <param name="target">The target <see cref="uint"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is != <paramref name="target"/>.</exception> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsEqualTo(uint value, uint target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { return; } ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be not equal to a specified value. /// </summary> /// <param name="value">The input <see cref="uint"/> value to test.</param> /// <param name="target">The target <see cref="uint"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is == <paramref name="target"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotEqualTo(uint value, uint target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { return; } ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be less than a specified value. /// </summary> /// <param name="value">The input <see cref="uint"/> value to test.</param> /// <param name="maximum">The exclusive maximum <see cref="uint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThan(uint value, uint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name); } /// <summary> /// Asserts that the input value must be less than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="uint"/> value to test.</param> /// <param name="maximum">The inclusive maximum <see cref="uint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThanOrEqualTo(uint value, uint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name); } /// <summary> /// Asserts that the input value must be greater than a specified value. /// </summary> /// <param name="value">The input <see cref="uint"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="uint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThan(uint value, uint minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name); } /// <summary> /// Asserts that the input value must be greater than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="uint"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="uint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThanOrEqualTo(uint value, uint minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name); } /// <summary> /// Asserts that the input value must be in a given range. /// </summary> /// <param name="value">The input <see cref="uint"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="uint"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="uint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsInRange(uint value, uint minimum, uint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given range. /// </summary> /// <param name="value">The input <see cref="uint"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="uint"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="uint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotInRange(uint value, uint minimum, uint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="uint"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="uint"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="uint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetween(uint value, uint minimum, uint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="uint"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="uint"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="uint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetween(uint value, uint minimum, uint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="uint"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="uint"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="uint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or > <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetweenOrEqualTo(uint value, uint minimum, uint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="uint"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="uint"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="uint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt;= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetweenOrEqualTo(uint value, uint minimum, uint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be equal to a specified value. /// </summary> /// <param name="value">The input <see cref="float"/> value to test.</param> /// <param name="target">The target <see cref="float"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is != <paramref name="target"/>.</exception> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsEqualTo(float value, float target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { return; } ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be not equal to a specified value. /// </summary> /// <param name="value">The input <see cref="float"/> value to test.</param> /// <param name="target">The target <see cref="float"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is == <paramref name="target"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotEqualTo(float value, float target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { return; } ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be less than a specified value. /// </summary> /// <param name="value">The input <see cref="float"/> value to test.</param> /// <param name="maximum">The exclusive maximum <see cref="float"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThan(float value, float maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name); } /// <summary> /// Asserts that the input value must be less than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="float"/> value to test.</param> /// <param name="maximum">The inclusive maximum <see cref="float"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThanOrEqualTo(float value, float maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name); } /// <summary> /// Asserts that the input value must be greater than a specified value. /// </summary> /// <param name="value">The input <see cref="float"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="float"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThan(float value, float minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name); } /// <summary> /// Asserts that the input value must be greater than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="float"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="float"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThanOrEqualTo(float value, float minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name); } /// <summary> /// Asserts that the input value must be in a given range. /// </summary> /// <param name="value">The input <see cref="float"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="float"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="float"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsInRange(float value, float minimum, float maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given range. /// </summary> /// <param name="value">The input <see cref="float"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="float"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="float"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotInRange(float value, float minimum, float maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="float"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="float"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="float"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetween(float value, float minimum, float maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="float"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="float"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="float"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetween(float value, float minimum, float maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="float"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="float"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="float"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or > <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetweenOrEqualTo(float value, float minimum, float maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="float"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="float"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="float"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt;= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetweenOrEqualTo(float value, float minimum, float maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be equal to a specified value. /// </summary> /// <param name="value">The input <see cref="long"/> value to test.</param> /// <param name="target">The target <see cref="long"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is != <paramref name="target"/>.</exception> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsEqualTo(long value, long target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { return; } ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be not equal to a specified value. /// </summary> /// <param name="value">The input <see cref="long"/> value to test.</param> /// <param name="target">The target <see cref="long"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is == <paramref name="target"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotEqualTo(long value, long target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { return; } ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be less than a specified value. /// </summary> /// <param name="value">The input <see cref="long"/> value to test.</param> /// <param name="maximum">The exclusive maximum <see cref="long"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThan(long value, long maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name); } /// <summary> /// Asserts that the input value must be less than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="long"/> value to test.</param> /// <param name="maximum">The inclusive maximum <see cref="long"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThanOrEqualTo(long value, long maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name); } /// <summary> /// Asserts that the input value must be greater than a specified value. /// </summary> /// <param name="value">The input <see cref="long"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="long"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThan(long value, long minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name); } /// <summary> /// Asserts that the input value must be greater than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="long"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="long"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThanOrEqualTo(long value, long minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name); } /// <summary> /// Asserts that the input value must be in a given range. /// </summary> /// <param name="value">The input <see cref="long"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="long"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="long"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsInRange(long value, long minimum, long maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given range. /// </summary> /// <param name="value">The input <see cref="long"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="long"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="long"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotInRange(long value, long minimum, long maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="long"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="long"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="long"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetween(long value, long minimum, long maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="long"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="long"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="long"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetween(long value, long minimum, long maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="long"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="long"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="long"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or > <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetweenOrEqualTo(long value, long minimum, long maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="long"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="long"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="long"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt;= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetweenOrEqualTo(long value, long minimum, long maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be equal to a specified value. /// </summary> /// <param name="value">The input <see cref="ulong"/> value to test.</param> /// <param name="target">The target <see cref="ulong"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is != <paramref name="target"/>.</exception> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsEqualTo(ulong value, ulong target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { return; } ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be not equal to a specified value. /// </summary> /// <param name="value">The input <see cref="ulong"/> value to test.</param> /// <param name="target">The target <see cref="ulong"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is == <paramref name="target"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotEqualTo(ulong value, ulong target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { return; } ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be less than a specified value. /// </summary> /// <param name="value">The input <see cref="ulong"/> value to test.</param> /// <param name="maximum">The exclusive maximum <see cref="ulong"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThan(ulong value, ulong maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name); } /// <summary> /// Asserts that the input value must be less than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="ulong"/> value to test.</param> /// <param name="maximum">The inclusive maximum <see cref="ulong"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThanOrEqualTo(ulong value, ulong maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name); } /// <summary> /// Asserts that the input value must be greater than a specified value. /// </summary> /// <param name="value">The input <see cref="ulong"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="ulong"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThan(ulong value, ulong minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name); } /// <summary> /// Asserts that the input value must be greater than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="ulong"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="ulong"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThanOrEqualTo(ulong value, ulong minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name); } /// <summary> /// Asserts that the input value must be in a given range. /// </summary> /// <param name="value">The input <see cref="ulong"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="ulong"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="ulong"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsInRange(ulong value, ulong minimum, ulong maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given range. /// </summary> /// <param name="value">The input <see cref="ulong"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="ulong"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="ulong"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotInRange(ulong value, ulong minimum, ulong maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="ulong"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="ulong"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="ulong"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetween(ulong value, ulong minimum, ulong maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="ulong"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="ulong"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="ulong"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetween(ulong value, ulong minimum, ulong maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="ulong"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="ulong"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="ulong"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or > <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetweenOrEqualTo(ulong value, ulong minimum, ulong maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="ulong"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="ulong"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="ulong"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt;= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetweenOrEqualTo(ulong value, ulong minimum, ulong maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be equal to a specified value. /// </summary> /// <param name="value">The input <see cref="double"/> value to test.</param> /// <param name="target">The target <see cref="double"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is != <paramref name="target"/>.</exception> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsEqualTo(double value, double target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { return; } ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be not equal to a specified value. /// </summary> /// <param name="value">The input <see cref="double"/> value to test.</param> /// <param name="target">The target <see cref="double"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is == <paramref name="target"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotEqualTo(double value, double target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { return; } ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be less than a specified value. /// </summary> /// <param name="value">The input <see cref="double"/> value to test.</param> /// <param name="maximum">The exclusive maximum <see cref="double"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThan(double value, double maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name); } /// <summary> /// Asserts that the input value must be less than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="double"/> value to test.</param> /// <param name="maximum">The inclusive maximum <see cref="double"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThanOrEqualTo(double value, double maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name); } /// <summary> /// Asserts that the input value must be greater than a specified value. /// </summary> /// <param name="value">The input <see cref="double"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="double"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThan(double value, double minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name); } /// <summary> /// Asserts that the input value must be greater than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="double"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="double"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThanOrEqualTo(double value, double minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name); } /// <summary> /// Asserts that the input value must be in a given range. /// </summary> /// <param name="value">The input <see cref="double"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="double"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="double"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsInRange(double value, double minimum, double maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given range. /// </summary> /// <param name="value">The input <see cref="double"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="double"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="double"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotInRange(double value, double minimum, double maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="double"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="double"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="double"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetween(double value, double minimum, double maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="double"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="double"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="double"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetween(double value, double minimum, double maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="double"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="double"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="double"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or > <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetweenOrEqualTo(double value, double minimum, double maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="double"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="double"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="double"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt;= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetweenOrEqualTo(double value, double minimum, double maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be equal to a specified value. /// </summary> /// <param name="value">The input <see cref="decimal"/> value to test.</param> /// <param name="target">The target <see cref="decimal"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is != <paramref name="target"/>.</exception> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsEqualTo(decimal value, decimal target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { return; } ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be not equal to a specified value. /// </summary> /// <param name="value">The input <see cref="decimal"/> value to test.</param> /// <param name="target">The target <see cref="decimal"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is == <paramref name="target"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotEqualTo(decimal value, decimal target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { return; } ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be less than a specified value. /// </summary> /// <param name="value">The input <see cref="decimal"/> value to test.</param> /// <param name="maximum">The exclusive maximum <see cref="decimal"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThan(decimal value, decimal maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name); } /// <summary> /// Asserts that the input value must be less than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="decimal"/> value to test.</param> /// <param name="maximum">The inclusive maximum <see cref="decimal"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThanOrEqualTo(decimal value, decimal maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name); } /// <summary> /// Asserts that the input value must be greater than a specified value. /// </summary> /// <param name="value">The input <see cref="decimal"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="decimal"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThan(decimal value, decimal minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name); } /// <summary> /// Asserts that the input value must be greater than or equal to a specified value. /// </summary> /// <param name="value">The input <see cref="decimal"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="decimal"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThanOrEqualTo(decimal value, decimal minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name); } /// <summary> /// Asserts that the input value must be in a given range. /// </summary> /// <param name="value">The input <see cref="decimal"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="decimal"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="decimal"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsInRange(decimal value, decimal minimum, decimal maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given range. /// </summary> /// <param name="value">The input <see cref="decimal"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="decimal"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="decimal"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotInRange(decimal value, decimal minimum, decimal maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="decimal"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="decimal"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="decimal"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetween(decimal value, decimal minimum, decimal maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="decimal"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see cref="decimal"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see cref="decimal"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetween(decimal value, decimal minimum, decimal maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see cref="decimal"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="decimal"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="decimal"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or > <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetweenOrEqualTo(decimal value, decimal minimum, decimal maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see cref="decimal"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see cref="decimal"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see cref="decimal"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt;= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetweenOrEqualTo(decimal value, decimal minimum, decimal maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be equal to a specified value. /// </summary> /// <param name="value">The input <see langword="nint"/> value to test.</param> /// <param name="target">The target <see langword="nint"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is != <paramref name="target"/>.</exception> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsEqualTo(nint value, nint target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { return; } ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be not equal to a specified value. /// </summary> /// <param name="value">The input <see langword="nint"/> value to test.</param> /// <param name="target">The target <see langword="nint"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is == <paramref name="target"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotEqualTo(nint value, nint target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { return; } ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be less than a specified value. /// </summary> /// <param name="value">The input <see langword="nint"/> value to test.</param> /// <param name="maximum">The exclusive maximum <see langword="nint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThan(nint value, nint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name); } /// <summary> /// Asserts that the input value must be less than or equal to a specified value. /// </summary> /// <param name="value">The input <see langword="nint"/> value to test.</param> /// <param name="maximum">The inclusive maximum <see langword="nint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThanOrEqualTo(nint value, nint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name); } /// <summary> /// Asserts that the input value must be greater than a specified value. /// </summary> /// <param name="value">The input <see langword="nint"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see langword="nint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThan(nint value, nint minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name); } /// <summary> /// Asserts that the input value must be greater than or equal to a specified value. /// </summary> /// <param name="value">The input <see langword="nint"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see langword="nint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThanOrEqualTo(nint value, nint minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name); } /// <summary> /// Asserts that the input value must be in a given range. /// </summary> /// <param name="value">The input <see langword="nint"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see langword="nint"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see langword="nint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsInRange(nint value, nint minimum, nint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given range. /// </summary> /// <param name="value">The input <see langword="nint"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see langword="nint"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see langword="nint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotInRange(nint value, nint minimum, nint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see langword="nint"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see langword="nint"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see langword="nint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetween(nint value, nint minimum, nint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see langword="nint"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see langword="nint"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see langword="nint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetween(nint value, nint minimum, nint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see langword="nint"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see langword="nint"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see langword="nint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or > <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetweenOrEqualTo(nint value, nint minimum, nint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see langword="nint"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see langword="nint"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see langword="nint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt;= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetweenOrEqualTo(nint value, nint minimum, nint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be equal to a specified value. /// </summary> /// <param name="value">The input <see langword="nuint"/> value to test.</param> /// <param name="target">The target <see langword="nuint"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is != <paramref name="target"/>.</exception> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsEqualTo(nuint value, nuint target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { return; } ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be not equal to a specified value. /// </summary> /// <param name="value">The input <see langword="nuint"/> value to test.</param> /// <param name="target">The target <see langword="nuint"/> value to test for.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is == <paramref name="target"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotEqualTo(nuint value, nuint target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { return; } ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name); } /// <summary> /// Asserts that the input value must be less than a specified value. /// </summary> /// <param name="value">The input <see langword="nuint"/> value to test.</param> /// <param name="maximum">The exclusive maximum <see langword="nuint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThan(nuint value, nuint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name); } /// <summary> /// Asserts that the input value must be less than or equal to a specified value. /// </summary> /// <param name="value">The input <see langword="nuint"/> value to test.</param> /// <param name="maximum">The inclusive maximum <see langword="nuint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="maximum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsLessThanOrEqualTo(nuint value, nuint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name); } /// <summary> /// Asserts that the input value must be greater than a specified value. /// </summary> /// <param name="value">The input <see langword="nuint"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see langword="nuint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThan(nuint value, nuint minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name); } /// <summary> /// Asserts that the input value must be greater than or equal to a specified value. /// </summary> /// <param name="value">The input <see langword="nuint"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see langword="nuint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/>.</exception> /// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsGreaterThanOrEqualTo(nuint value, nuint minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name); } /// <summary> /// Asserts that the input value must be in a given range. /// </summary> /// <param name="value">The input <see langword="nuint"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see langword="nuint"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see langword="nuint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsInRange(nuint value, nuint minimum, nuint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given range. /// </summary> /// <param name="value">The input <see langword="nuint"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see langword="nuint"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see langword="nuint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotInRange(nuint value, nuint minimum, nuint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see langword="nuint"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see langword="nuint"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see langword="nuint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt;= <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetween(nuint value, nuint minimum, nuint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see langword="nuint"/> value to test.</param> /// <param name="minimum">The exclusive minimum <see langword="nuint"/> value that is accepted.</param> /// <param name="maximum">The exclusive maximum <see langword="nuint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="minimum"/> or &lt; <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in (<paramref name="minimum"/>, <paramref name="maximum"/>)", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetween(nuint value, nuint minimum, nuint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must be in a given interval. /// </summary> /// <param name="value">The input <see langword="nuint"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see langword="nuint"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see langword="nuint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is &lt; <paramref name="minimum"/> or > <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsBetweenOrEqualTo(nuint value, nuint minimum, nuint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name); } /// <summary> /// Asserts that the input value must not be in a given interval. /// </summary> /// <param name="value">The input <see langword="nuint"/> value to test.</param> /// <param name="minimum">The inclusive minimum <see langword="nuint"/> value that is accepted.</param> /// <param name="maximum">The inclusive maximum <see langword="nuint"/> value that is accepted.</param> /// <param name="name">The name of the input parameter being tested.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or &lt;= <paramref name="maximum"/>.</exception> /// <remarks> /// This API asserts the equivalent of "<paramref name="value"/> not in [<paramref name="minimum"/>, <paramref name="maximum"/>]", using arithmetic notation. /// The method is generic to avoid boxing the parameters, if they are value types. /// </remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsNotBetweenOrEqualTo(nuint value, nuint minimum, nuint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { return; } ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name); } }
Guard
csharp
aspnetboilerplate__aspnetboilerplate
src/Abp.Web.Common/Web/Api/ProxyScripting/IApiProxyScriptManager.cs
{ "start": 43, "end": 157 }
public interface ____ { string GetScript(ApiProxyGenerationOptions options); } }
IApiProxyScriptManager
csharp
cake-build__cake
src/Cake.Common/Build/GitLabCI/Data/GitLabCIRunnerInfo.cs
{ "start": 389, "end": 1905 }
public sealed class ____ : GitLabCIInfo { /// <summary> /// Initializes a new instance of the <see cref="GitLabCIRunnerInfo"/> class. /// </summary> /// <param name="environment">The environment.</param> public GitLabCIRunnerInfo(ICakeEnvironment environment) : base(environment) { } /// <summary> /// Gets the unique id of runner being used. /// </summary> /// <value> /// The unique id of runner being used. /// </value> public int Id => GetEnvironmentInteger("CI_RUNNER_ID"); /// <summary> /// Gets the description of the runner as saved in GitLab. /// </summary> /// <value> /// The description of the runner as saved in GitLab. /// </value> public string Description => GetEnvironmentString("CI_RUNNER_DESCRIPTION"); /// <summary> /// Gets an array of the defined runner tags. /// </summary> /// <value> /// The defined runner tags. /// </value> public string[] Tags { get { var tags = GetEnvironmentString("CI_RUNNER_TAGS").Trim('[', ']').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < tags.Length; i++) { tags[i] = tags[i].Trim(' ', '"'); } return tags; } } } }
GitLabCIRunnerInfo
csharp
PrismLibrary__Prism
src/Maui/Prism.Maui/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs
{ "start": 230, "end": 4035 }
public class ____ : RegionBehavior { /// <summary> /// The key of this behavior. /// </summary> public const string BehaviorKey = "AutoPopulate"; private readonly IRegionViewRegistry regionViewRegistry; /// <summary> /// Creates a new instance of the AutoPopulateRegionBehavior /// associated with the <see cref="IRegionViewRegistry"/> received. /// </summary> /// <param name="regionViewRegistry"><see cref="IRegionViewRegistry"/> that the behavior will monitor for views to populate the region.</param> public AutoPopulateRegionBehavior(IRegionViewRegistry regionViewRegistry) { this.regionViewRegistry = regionViewRegistry; } /// <summary> /// Attaches the AutoPopulateRegionBehavior to the Region. /// </summary> protected override void OnAttach() { if (string.IsNullOrEmpty(Region.Name)) { Region.PropertyChanged += Region_PropertyChanged; } else { StartPopulatingContent(); } } private void StartPopulatingContent() { foreach (VisualElement view in CreateViewsToAutoPopulate()) { AddViewIntoRegion(view); } if (Region is ITargetAwareRegion targetAware && targetAware.TargetElement.GetValue(Xaml.RegionManager.DefaultViewProperty) != null) { var defaultView = targetAware.TargetElement.GetValue(Xaml.RegionManager.DefaultViewProperty); if (defaultView is string targetName) Region.Add(targetName); else if (defaultView is VisualElement element) Region.Add(element); else if (defaultView is Type type) { var container = targetAware.Container; var registry = container.Resolve<IRegionNavigationRegistry>(); var registration = registry.Registrations.FirstOrDefault(x => x.View == type); if (registration is not null) { var view = registry.CreateView(container, registration.Name) as VisualElement; Region.Add(view); } } } regionViewRegistry.ContentRegistered += OnViewRegistered; } /// <summary> /// Returns a collection of views that will be added to the /// View collection. /// </summary> /// <returns></returns> protected virtual IEnumerable<object> CreateViewsToAutoPopulate() { return regionViewRegistry.GetContents(Region.Name, Region.Container()); } /// <summary> /// Adds a view into the views collection of this region. /// </summary> /// <param name="viewToAdd"></param> protected virtual void AddViewIntoRegion(VisualElement viewToAdd) { Region.Add(viewToAdd); } private void Region_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "Name" && !string.IsNullOrEmpty(Region.Name)) { Region.PropertyChanged -= Region_PropertyChanged; StartPopulatingContent(); } } /// <summary> /// Handler of the event that fires when a new viewtype is registered to the registry. /// </summary> /// <remarks>Although this is a public method to support Weak Delegates in Silverlight, it should not be called by the user.</remarks> /// <param name="sender"></param> /// <param name="e"></param> public virtual void OnViewRegistered(object sender, ViewRegisteredEventArgs e) { if (e == null) throw new ArgumentNullException(nameof(e)); if (e.RegionName == Region.Name) { AddViewIntoRegion((VisualElement)e.GetView(Region.Container())); } } }
AutoPopulateRegionBehavior
csharp
PrismLibrary__Prism
tests/Avalonia/Prism.Avalonia.Tests/PrismBootstrapperBaseFixture.cs
{ "start": 8494, "end": 14053 }
public class ____ : PrismBootstrapperBase { public Mock<IContainerExtension> MockContainer { get; private set; } public IModuleCatalog DefaultModuleCatalog => Container.Resolve<IModuleCatalog>(); public IRegionBehaviorFactory DefaultRegionBehaviorTypes => Container.Resolve<IRegionBehaviorFactory>(); public RegionAdapterMappings DefaultRegionAdapterMappings => Container.Resolve<RegionAdapterMappings>(); public bool ConfigureViewModelLocatorWasCalled { get; set; } public bool CreateShellWasCalled { get; set; } public bool InitializeShellWasCalled { get; set; } public bool OnInitializedWasCalled { get; set; } public bool RegisterTypesWasCalled { get; set; } public bool InitializeModulesCalled { get; internal set; } public bool ConfigureModuleCatalogCalled { get; internal set; } public bool RegisterFrameworkExceptionTypesCalled { get; internal set; } public bool ConfigureRegionAdapterMappingsCalled { get; internal set; } public bool ConfigureDefaultRegionBehaviorsCalled { get; internal set; } public bool RegisterRequiredTypesCalled { get; internal set; } public bool CreateModuleCatalogCalled { get; internal set; } public bool CreateContainerExtensionCalled { get; internal set; } public bool InitializeCalled { get; internal set; } protected override void Initialize() { InitializeCalled = true; ContainerLocator.ResetContainer(); MockContainer = new Mock<IContainerExtension>(); base.Initialize(); } protected override IContainerExtension CreateContainerExtension() { CreateContainerExtensionCalled = true; return MockContainer.Object; } protected override void ConfigureViewModelLocator() { ConfigureViewModelLocatorWasCalled = true; //setting this breaks other tests using VML. //We need to revist those tests to ensure it is being reset each time. //base.ConfigureViewModelLocator(); } protected override IModuleCatalog CreateModuleCatalog() { CreateModuleCatalogCalled = true; var moduleCatalog = base.CreateModuleCatalog(); MockContainer.Setup(x => x.Resolve(typeof(IModuleCatalog))).Returns(moduleCatalog); return moduleCatalog; } protected override AvaloniaObject CreateShell() { CreateShellWasCalled = true; return null; } protected override void InitializeShell(AvaloniaObject shell) { InitializeShellWasCalled = false; } protected override void RegisterRequiredTypes(IContainerRegistry containerRegistry) { RegisterRequiredTypesCalled = true; base.RegisterRequiredTypes(containerRegistry); var moduleInitializer = new ModuleInitializer(MockContainer.Object); MockContainer.Setup(x => x.Resolve(typeof(IModuleInitializer))).Returns(moduleInitializer); MockContainer.Setup(x => x.Resolve(typeof(IModuleManager))).Returns(new ModuleManager(moduleInitializer, DefaultModuleCatalog)); MockContainer.Setup(x => x.Resolve(typeof(IRegionBehaviorFactory))).Returns(new RegionBehaviorFactory(MockContainer.Object)); var regionBehaviorFactory = new RegionBehaviorFactory(MockContainer.Object); MockContainer.Setup(x => x.Resolve(typeof(IRegionBehaviorFactory))).Returns(regionBehaviorFactory); MockContainer.Setup(x => x.Resolve(typeof(RegionAdapterMappings))).Returns(new RegionAdapterMappings()); //// TODO: MockContainer.Setup(x => x.Resolve(typeof(SelectorRegionAdapter))).Returns(new SelectorRegionAdapter(regionBehaviorFactory)); MockContainer.Setup(x => x.Resolve(typeof(ItemsControlRegionAdapter))).Returns(new ItemsControlRegionAdapter(regionBehaviorFactory)); MockContainer.Setup(x => x.Resolve(typeof(ContentControlRegionAdapter))).Returns(new ContentControlRegionAdapter(regionBehaviorFactory)); } protected override void RegisterTypes(IContainerRegistry containerRegistry) { RegisterTypesWasCalled = true; } protected override void OnInitialized() { OnInitializedWasCalled = true; } protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog) { ConfigureModuleCatalogCalled = true; base.ConfigureModuleCatalog(moduleCatalog); } protected override void InitializeModules() { InitializeModulesCalled = true; base.InitializeModules(); } protected override void RegisterFrameworkExceptionTypes() { RegisterFrameworkExceptionTypesCalled = true; base.RegisterFrameworkExceptionTypes(); } protected override void ConfigureRegionAdapterMappings(RegionAdapterMappings regionAdapterMappings) { ConfigureRegionAdapterMappingsCalled = true; base.ConfigureRegionAdapterMappings(regionAdapterMappings); } protected override void ConfigureDefaultRegionBehaviors(IRegionBehaviorFactory regionBehaviors) { ConfigureDefaultRegionBehaviorsCalled = true; base.ConfigureDefaultRegionBehaviors(regionBehaviors); } } }
PrismBootstrapper
csharp
nopSolutions__nopCommerce
src/Libraries/Nop.Services/Catalog/ProductAttributeFormatter.cs
{ "start": 411, "end": 13855 }
public partial class ____ : IProductAttributeFormatter { #region Fields protected readonly ICurrencyService _currencyService; protected readonly IDownloadService _downloadService; protected readonly IHtmlFormatter _htmlFormatter; protected readonly ILocalizationService _localizationService; protected readonly IPriceCalculationService _priceCalculationService; protected readonly IPriceFormatter _priceFormatter; protected readonly IProductAttributeParser _productAttributeParser; protected readonly IProductAttributeService _productAttributeService; protected readonly ITaxService _taxService; protected readonly IWebHelper _webHelper; protected readonly IWorkContext _workContext; protected readonly IStoreContext _storeContext; protected readonly ShoppingCartSettings _shoppingCartSettings; #endregion #region Ctor public ProductAttributeFormatter(ICurrencyService currencyService, IDownloadService downloadService, IHtmlFormatter htmlFormatter, ILocalizationService localizationService, IPriceCalculationService priceCalculationService, IPriceFormatter priceFormatter, IProductAttributeParser productAttributeParser, IProductAttributeService productAttributeService, ITaxService taxService, IWebHelper webHelper, IWorkContext workContext, IStoreContext storeContext, ShoppingCartSettings shoppingCartSettings) { _currencyService = currencyService; _downloadService = downloadService; _htmlFormatter = htmlFormatter; _localizationService = localizationService; _priceCalculationService = priceCalculationService; _priceFormatter = priceFormatter; _productAttributeParser = productAttributeParser; _productAttributeService = productAttributeService; _taxService = taxService; _webHelper = webHelper; _workContext = workContext; _storeContext = storeContext; _shoppingCartSettings = shoppingCartSettings; } #endregion #region Methods /// <summary> /// Formats attributes /// </summary> /// <param name="product">Product</param> /// <param name="attributesXml">Attributes in XML format</param> /// <returns> /// A task that represents the asynchronous operation /// The task result contains the attributes /// </returns> public virtual async Task<string> FormatAttributesAsync(Product product, string attributesXml) { var customer = await _workContext.GetCurrentCustomerAsync(); var currentStore = await _storeContext.GetCurrentStoreAsync(); return await FormatAttributesAsync(product, attributesXml, customer, currentStore); } /// <summary> /// Formats attributes /// </summary> /// <param name="product">Product</param> /// <param name="attributesXml">Attributes in XML format</param> /// <param name="customer">Customer</param> /// <param name="store">Store</param> /// <param name="separator">Separator</param> /// <param name="htmlEncode">A value indicating whether to encode (HTML) values</param> /// <param name="renderPrices">A value indicating whether to render prices</param> /// <param name="renderProductAttributes">A value indicating whether to render product attributes</param> /// <param name="renderGiftCardAttributes">A value indicating whether to render gift card attributes</param> /// <param name="allowHyperlinks">A value indicating whether to HTML hyperink tags could be rendered (if required)</param> /// <returns> /// A task that represents the asynchronous operation /// The task result contains the attributes /// </returns> public virtual async Task<string> FormatAttributesAsync(Product product, string attributesXml, Customer customer, Store store, string separator = "<br />", bool htmlEncode = true, bool renderPrices = true, bool renderProductAttributes = true, bool renderGiftCardAttributes = true, bool allowHyperlinks = true) { var result = new StringBuilder(); var currentLanguage = await _workContext.GetWorkingLanguageAsync(); //attributes if (renderProductAttributes) { foreach (var attribute in await _productAttributeParser.ParseProductAttributeMappingsAsync(attributesXml)) { var productAttribute = await _productAttributeService.GetProductAttributeByIdAsync(attribute.ProductAttributeId); var attributeName = await _localizationService.GetLocalizedAsync(productAttribute, a => a.Name, currentLanguage.Id); //attributes without values if (!attribute.ShouldHaveValues()) { foreach (var value in _productAttributeParser.ParseValues(attributesXml, attribute.Id)) { var formattedAttribute = string.Empty; if (attribute.AttributeControlType == AttributeControlType.MultilineTextbox) { //encode (if required) if (htmlEncode) attributeName = WebUtility.HtmlEncode(attributeName); //we never encode multiline textbox input formattedAttribute = $"{attributeName}: {_htmlFormatter.FormatText(value, false, true, false, false, false, false)}"; } else if (attribute.AttributeControlType == AttributeControlType.FileUpload) { //file upload _ = Guid.TryParse(value, out var downloadGuid); var download = await _downloadService.GetDownloadByGuidAsync(downloadGuid); if (download != null) { var fileName = $"{download.Filename ?? download.DownloadGuid.ToString()}{download.Extension}"; //encode (if required) if (htmlEncode) fileName = WebUtility.HtmlEncode(fileName); var attributeText = allowHyperlinks ? $"<a href=\"{_webHelper.GetStoreLocation()}download/getfileupload/?downloadId={download.DownloadGuid}\" class=\"fileuploadattribute\">{fileName}</a>" : fileName; //encode (if required) if (htmlEncode) attributeName = WebUtility.HtmlEncode(attributeName); formattedAttribute = $"{attributeName}: {attributeText}"; } } else { //other attributes (textbox, datepicker) formattedAttribute = $"{attributeName}: {value}"; //encode (if required) if (htmlEncode) formattedAttribute = WebUtility.HtmlEncode(formattedAttribute); } if (string.IsNullOrEmpty(formattedAttribute)) continue; if (result.Length > 0) result.Append(separator); result.Append(formattedAttribute); } } //product attribute values else { foreach (var attributeValue in await _productAttributeParser.ParseProductAttributeValuesAsync(attributesXml, attribute.Id)) { var formattedAttribute = $"{attributeName}: {await _localizationService.GetLocalizedAsync(attributeValue, a => a.Name, currentLanguage.Id)}"; if (renderPrices) { if (attributeValue.PriceAdjustmentUsePercentage) { if (attributeValue.PriceAdjustment > decimal.Zero) { formattedAttribute += string.Format( await _localizationService.GetResourceAsync("FormattedAttributes.PriceAdjustment"), "+", attributeValue.PriceAdjustment.ToString("G29"), "%"); } else if (attributeValue.PriceAdjustment < decimal.Zero) { formattedAttribute += string.Format( await _localizationService.GetResourceAsync("FormattedAttributes.PriceAdjustment"), string.Empty, attributeValue.PriceAdjustment.ToString("G29"), "%"); } } else { var attributeValuePriceAdjustment = await _priceCalculationService.GetProductAttributeValuePriceAdjustmentAsync(product, attributeValue, customer, store); var (priceAdjustmentBase, _) = await _taxService.GetProductPriceAsync(product, attributeValuePriceAdjustment, customer); var priceAdjustment = await _currencyService.ConvertFromPrimaryStoreCurrencyAsync(priceAdjustmentBase, await _workContext.GetWorkingCurrencyAsync()); if (priceAdjustmentBase > decimal.Zero) { formattedAttribute += string.Format( await _localizationService.GetResourceAsync("FormattedAttributes.PriceAdjustment"), "+", await _priceFormatter.FormatPriceAsync(priceAdjustment, false, false), string.Empty); } else if (priceAdjustmentBase < decimal.Zero) { formattedAttribute += string.Format( await _localizationService.GetResourceAsync("FormattedAttributes.PriceAdjustment"), "-", await _priceFormatter.FormatPriceAsync(-priceAdjustment, false, false), string.Empty); } } } //display quantity if (_shoppingCartSettings.RenderAssociatedAttributeValueQuantity && attributeValue.AttributeValueType == AttributeValueType.AssociatedToProduct) { //render only when more than 1 if (attributeValue.Quantity > 1) formattedAttribute += string.Format(await _localizationService.GetResourceAsync("ProductAttributes.Quantity"), attributeValue.Quantity); } //encode (if required) if (htmlEncode) formattedAttribute = WebUtility.HtmlEncode(formattedAttribute); if (string.IsNullOrEmpty(formattedAttribute)) continue; if (result.Length > 0) result.Append(separator); result.Append(formattedAttribute); } } } } //gift cards if (!renderGiftCardAttributes) return result.ToString(); if (!product.IsGiftCard) return result.ToString(); _productAttributeParser.GetGiftCardAttribute(attributesXml, out var giftCardRecipientName, out var giftCardRecipientEmail, out var giftCardSenderName, out var giftCardSenderEmail, out var _); //sender var giftCardFrom = product.GiftCardType == GiftCardType.Virtual ? string.Format(await _localizationService.GetResourceAsync("GiftCardAttribute.From.Virtual"), giftCardSenderName, giftCardSenderEmail) : string.Format(await _localizationService.GetResourceAsync("GiftCardAttribute.From.Physical"), giftCardSenderName); //recipient var giftCardFor = product.GiftCardType == GiftCardType.Virtual ? string.Format(await _localizationService.GetResourceAsync("GiftCardAttribute.For.Virtual"), giftCardRecipientName, giftCardRecipientEmail) : string.Format(await _localizationService.GetResourceAsync("GiftCardAttribute.For.Physical"), giftCardRecipientName); //encode (if required) if (htmlEncode) { giftCardFrom = WebUtility.HtmlEncode(giftCardFrom); giftCardFor = WebUtility.HtmlEncode(giftCardFor); } if (!string.IsNullOrEmpty(result.ToString())) { result.Append(separator); } result.Append(giftCardFrom); result.Append(separator); result.Append(giftCardFor); return result.ToString(); } #endregion }
ProductAttributeFormatter
csharp
files-community__Files
src/Files.Shared/Helpers/ChecksumHelpers.cs
{ "start": 270, "end": 2033 }
public static class ____ { public static string CalculateChecksumForPath(string path) { var buffer = Encoding.UTF8.GetBytes(path); Span<byte> hash = stackalloc byte[MD5.HashSizeInBytes]; MD5.HashData(buffer, hash); return Convert.ToHexString(hash); } public async static Task<string> CreateCRC32(Stream stream, CancellationToken cancellationToken) { var crc32 = new Crc32(); await crc32.AppendAsync(stream, cancellationToken); var hashBytes = crc32.GetCurrentHash(); Array.Reverse(hashBytes); return Convert.ToHexString(hashBytes); } public async static Task<string> CreateMD5(Stream stream, CancellationToken cancellationToken) { var hashBytes = await MD5.HashDataAsync(stream, cancellationToken); return Convert.ToHexString(hashBytes).ToLower(); } public async static Task<string> CreateSHA1(Stream stream, CancellationToken cancellationToken) { var hashBytes = await SHA1.HashDataAsync(stream, cancellationToken); return Convert.ToHexString(hashBytes).ToLower(); } public async static Task<string> CreateSHA256(Stream stream, CancellationToken cancellationToken) { var hashBytes = await SHA256.HashDataAsync(stream, cancellationToken); return Convert.ToHexString(hashBytes).ToLower(); } public async static Task<string> CreateSHA384(Stream stream, CancellationToken cancellationToken) { var hashBytes = await SHA384.HashDataAsync(stream, cancellationToken); return Convert.ToHexString(hashBytes).ToLower(); } public async static Task<string> CreateSHA512(Stream stream, CancellationToken cancellationToken) { var hashBytes = await SHA512.HashDataAsync(stream, cancellationToken); return Convert.ToHexString(hashBytes).ToLower(); } } }
ChecksumHelpers
csharp
dotnet__efcore
test/EFCore.Tests/ChangeTracking/GraphTrackingTest.cs
{ "start": 16122, "end": 16421 }
private class ____ { public int Id { get; set; } public int? AuthorId { get; set; } public Author Author { get; set; } public int BlogId { get; set; } public Blog Blog { get; set; } public ICollection<Comment> Comments { get; set; } }
Post
csharp
EventStore__EventStore
src/KurrentDB.Core.Tests/Services/Replication/LogReplication/Tests/data_chunk_replication.cs
{ "start": 8303, "end": 10714 }
record ____ properly rolled back by checking if the // replica's writer position is at the writer checkpoint's position. var replicaWriterChk = ReplicaWriterCheckpoint; Assert.AreEqual(0, replicaWriterChk / ChunkSize); var replicaWriterPos = await WriteEventsToReplica("s", string.Empty); Assert.AreEqual(replicaWriterChk, replicaWriterPos - emptyEventSize); // check if we can create new chunks without any issue replicaWriterPos = await WriteEventsToFillChunks( numChunksToFill: 2, numEventsPerChunk: 128, numEventsPerTransaction: 2, async events => await WriteEventsToReplica("stream", events)); Assert.AreEqual(2, replicaWriterPos / ChunkSize); Assert.AreEqual(ReplicaWriterCheckpoint, replicaWriterPos); } [Test] public async Task when_replica_becomes_leader_it_can_rollback_an_incomplete_transaction_spanning_one_chunk_file() { // see above notes regarding why we calculate an empty event's size var emptyEventSize = await WriteEvents("s", string.Empty); // chunk bulk 0 var eventData = new string(' ', LeaderReplicationService.BulkSize / 4); var events = Enumerable.Repeat(eventData, 6).ToArray(); var leaderWriterPos = await WriteEvents("stream", events); // chunk bulk 0-1 (the transaction that'll be "half replicated") Assert.AreEqual(0, leaderWriterPos / ChunkSize); await ConnectReplica(pauseReplication: true); await ResumeReplicationUntil(maxLogPosition: leaderWriterPos - 1, expectedFlushes: 1); await ReplicaBecomesLeader(); // verify if the incomplete transaction was properly rolled back by checking if the // replica's writer position is at the writer checkpoint's position. var replicaWriterChk = ReplicaWriterCheckpoint; Assert.AreEqual(0, replicaWriterChk / ChunkSize); var replicaWriterPos = await WriteEventsToReplica("s", string.Empty); Assert.AreEqual(replicaWriterChk, replicaWriterPos - emptyEventSize); // check if we can create new chunks without any issue replicaWriterPos = await WriteEventsToFillChunks( numChunksToFill: 2, numEventsPerChunk: 128, numEventsPerTransaction: 2, async evts => await WriteEventsToReplica("stream", evts)); Assert.AreEqual(2, replicaWriterPos / ChunkSize); Assert.AreEqual(ReplicaWriterCheckpoint, replicaWriterPos); } // note: we do not have tests for incomplete transactions that span more than one chunk file as this scenario is no longer possible. }
was
csharp
ServiceStack__ServiceStack
ServiceStack/tests/NorthwindAuto/ServiceInterface/MyCommandsServices.cs
{ "start": 1740, "end": 2121 }
public class ____(ILogger<AddTodoCommand> log, IDbConnection db) : IAsyncCommand<CreateTodo> { public async Task ExecuteAsync(CreateTodo request) { var newTodo = request.ConvertTo<Todo>(); newTodo.Id = await db.InsertAsync(newTodo, selectIdentity:true); log.LogDebug("Created Todo {Id}: {Text}", newTodo.Id, newTodo.Text); } }
AddOneWayTodoCommand
csharp
protobuf-net__protobuf-net
src/BuildToolsUnitTests/CodeFixes/ShouldDeclareDefaultCodeFixProviderTests.cs
{ "start": 882, "end": 1063 }
public class ____ {{ public {propertyType} Bar {{ get; set; }} = {propertyDefaultValue}; }} "; var expectedCode = $@" using ProtoBuf; using System; [ProtoContract]
Foo
csharp
dotnetcore__Util
src/Util.Ui.NgZorro/Components/Containers/ContainerTagHelper.cs
{ "start": 326, "end": 1021 }
public class ____ : AngularTagHelperBase { /// <summary> /// *ngTemplateOutlet,模板出口 /// </summary> public string NgTemplateOutlet { get; set; } /// <summary> /// *nzMentionSuggestion,提及建议渲染模板 /// </summary> public string MentionSuggestion { get; set; } /// <summary> /// *nzSpaceItem,值为 true 时设置为间距项,放入 &lt;util-space> 中使用 /// </summary> public bool SpaceItem { get; set; } /// <inheritdoc /> protected override IRender GetRender( TagHelperContext context, TagHelperOutput output, TagHelperContent content ) { var config = new Config( context, output, content ); return new ContainerRender( config ); } }
ContainerTagHelper
csharp
protobuf-net__protobuf-net
src/CSharpTest/Class1.cs
{ "start": 2272, "end": 3400 }
public static class ____ { public static global::System.Collections.Generic.IEnumerable<global::System.DateTime> GetSystemIsOnPeripherals(SystemConfig obj) => obj == null ? null : global::ProtoBuf.Extensible.GetValues<global::System.DateTime>(obj, 900001, global::ProtoBuf.DataFormat.WellKnown); public static void AddSystemIsOnPeripherals(SystemConfig obj, global::System.DateTime value) => global::ProtoBuf.Extensible.AppendValue<global::System.DateTime>(obj, 900001, global::ProtoBuf.DataFormat.WellKnown, value); public static global::System.DateTime? GetSystemOwnedByAccount(SystemConfig obj) => obj == null ? default : global::ProtoBuf.Extensible.GetValue<global::System.DateTime?>(obj, 900002, global::ProtoBuf.DataFormat.WellKnown); public static void SetSystemOwnedByAccount(SystemConfig obj, global::System.DateTime value) => global::ProtoBuf.Extensible.AppendValue<global::System.DateTime>(obj, 900002, global::ProtoBuf.DataFormat.WellKnown, value); } } #pragma warning restore CS1591, CS0612, CS0618, CS3021, IDE1006
Extensions
csharp
dotnet__efcore
test/EFCore.InMemory.FunctionalTests/GraphUpdates/GraphUpdatesInMemoryTestBase.cs
{ "start": 180, "end": 7773 }
public abstract class ____<TFixture>(TFixture fixture) : GraphUpdatesTestBase<TFixture>(fixture) where TFixture : GraphUpdatesInMemoryTestBase<TFixture>.GraphUpdatesInMemoryFixtureBase, new() { // In-memory database does not have database default values public override Task Can_insert_when_bool_PK_in_composite_key_has_sentinel_value(bool async, bool initialValue) => Task.CompletedTask; // In-memory database does not have database default values public override Task Can_insert_when_int_PK_in_composite_key_has_sentinel_value(bool async, int initialValue) => Task.CompletedTask; // In-memory database does not have database default values public override Task Can_insert_when_nullable_bool_PK_in_composite_key_has_sentinel_value(bool async, bool? initialValue) => Task.CompletedTask; // In-memory database does not have database default values public override Task Throws_for_single_property_bool_key_with_default_value_generation(bool async, bool initialValue) => Task.CompletedTask; // In-memory database does not have database default values public override Task Throws_for_single_property_nullable_bool_key_with_default_value_generation(bool async, bool? initialValue) => Task.CompletedTask; // In-memory database does not have database default values public override Task Can_insert_when_composite_FK_has_default_value_for_one_part(bool async) => Task.CompletedTask; // In-memory database does not have database default values public override Task Can_insert_when_FK_has_default_value(bool async) => Task.CompletedTask; // In-memory database does not have database default values public override Task Can_insert_when_FK_has_sentinel_value(bool async) => Task.CompletedTask; public override Task Required_many_to_one_dependents_are_cascade_deleted_in_store( CascadeTiming? cascadeDeleteTiming, CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; public override Task Optional_many_to_one_dependents_are_orphaned_in_store( CascadeTiming? cascadeDeleteTiming, CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; public override Task Required_many_to_one_dependents_with_alternate_key_are_cascade_deleted_in_store( CascadeTiming? cascadeDeleteTiming, CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; public override Task Optional_many_to_one_dependents_with_alternate_key_are_orphaned_in_store( CascadeTiming? cascadeDeleteTiming, CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; public override Task Optional_one_to_one_relationships_are_one_to_one( CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; public override Task Required_one_to_one_relationships_are_one_to_one( CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; public override Task Save_required_one_to_one_changed_by_reference( ChangeMechanism changeMechanism, CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; public override Task Sever_required_one_to_one( ChangeMechanism changeMechanism, CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; public override Task Required_one_to_one_are_cascade_deleted_in_store( CascadeTiming? cascadeDeleteTiming, CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; public override Task Required_non_PK_one_to_one_are_cascade_deleted_in_store( CascadeTiming? cascadeDeleteTiming, CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; public override Task Optional_one_to_one_are_orphaned_in_store( CascadeTiming? cascadeDeleteTiming, CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; public override Task Required_one_to_one_are_cascade_detached_when_Added( CascadeTiming? cascadeDeleteTiming, CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; public override Task Required_non_PK_one_to_one_are_cascade_detached_when_Added( CascadeTiming? cascadeDeleteTiming, CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; public override Task Optional_one_to_one_with_AK_relationships_are_one_to_one( CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; public override Task Required_one_to_one_with_AK_relationships_are_one_to_one( CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; public override Task Required_one_to_one_with_alternate_key_are_cascade_deleted_in_store( CascadeTiming? cascadeDeleteTiming, CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; public override Task Required_non_PK_one_to_one_with_alternate_key_are_cascade_deleted_in_store( CascadeTiming? cascadeDeleteTiming, CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; public override Task Optional_one_to_one_with_alternate_key_are_orphaned_in_store( CascadeTiming? cascadeDeleteTiming, CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; public override Task Required_non_PK_one_to_one_with_alternate_key_are_cascade_detached_when_Added( CascadeTiming? cascadeDeleteTiming, CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; public override Task Required_one_to_one_with_alternate_key_are_cascade_detached_when_Added( CascadeTiming? cascadeDeleteTiming, CascadeTiming? deleteOrphansTiming) // FK uniqueness not enforced in in-memory database => Task.CompletedTask; protected override async Task ExecuteWithStrategyInTransactionAsync( Func<DbContext, Task> testOperation, Func<DbContext, Task> nestedTestOperation1 = null, Func<DbContext, Task> nestedTestOperation2 = null, Func<DbContext, Task> nestedTestOperation3 = null) { await base.ExecuteWithStrategyInTransactionAsync( testOperation, nestedTestOperation1, nestedTestOperation2, nestedTestOperation3); await Fixture.ReseedAsync(); }
GraphUpdatesInMemoryTestBase
csharp
unoplatform__uno
src/Uno.UI.RemoteControl/HotReload/Messages/HotReloadStatusMessage.cs
{ "start": 207, "end": 325 }
internal class ____ : Attribute { } } #endif namespace Uno.UI.RemoteControl.HotReload.Messages {
JsonPropertyAttribute
csharp
OrchardCMS__OrchardCore
src/OrchardCore/OrchardCore/Modules/Overrides/HttpClient/LifetimeTrackingHttpMessageHandler.cs
{ "start": 398, "end": 664 }
internal sealed class ____ : DelegatingHandler { public LifetimeTrackingHttpMessageHandler(HttpMessageHandler innerHandler) : base(innerHandler) { } #pragma warning disable CA2215 // Dispose methods should call base
LifetimeTrackingHttpMessageHandler
csharp
EventStore__EventStore
src/KurrentDB.Common/Configuration/MetricsConfiguration.cs
{ "start": 1190, "end": 1257 }
public enum ____ { FlushSize = 1, FlushDuration, }
WriterTracker
csharp
MahApps__MahApps.Metro
src/Mahapps.Metro.Tests/TestWindow.cs
{ "start": 234, "end": 495 }
public class ____ : MetroWindow, IDisposable #endif { public void Dispose() { this.Close(); } #if NET6_0_OR_GREATER public ValueTask DisposeAsync() { this.Close(); return ValueTask.CompletedTask; } #endif }
TestWindow
csharp
grpc__grpc-dotnet
test/FunctionalTests/Infrastructure/HttpResponseMessageExtensions.cs
{ "start": 909, "end": 3484 }
internal static class ____ { public static void AssertIsSuccessfulGrpcRequest(this HttpResponseMessage response, string contentType = GrpcProtocolConstants.GrpcContentType) { Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); Assert.AreEqual(contentType, response.Content?.Headers?.ContentType?.MediaType); } public static async Task<T> GetSuccessfulGrpcMessageAsync<T>(this HttpResponseMessage response, string contentType = GrpcProtocolConstants.GrpcContentType) where T : class, IMessage, new() { response.AssertIsSuccessfulGrpcRequest(contentType); var data = await response.Content.ReadAsByteArrayAsync().DefaultTimeout(); response.AssertTrailerStatus(); return MessageHelpers.AssertReadMessage<T>(data); } public static void AssertTrailerStatus(this HttpResponseMessage response) => response.AssertTrailerStatus(StatusCode.OK, string.Empty); public static void AssertTrailerStatus(this HttpResponseMessage response, StatusCode statusCode, string details) { HttpResponseHeaders statusHeadersCollection; var statusString = GetStatusValue(response.TrailingHeaders, GrpcProtocolConstants.StatusTrailer); if (statusString != null) { statusHeadersCollection = response.TrailingHeaders; } else { statusString = GetStatusValue(response.Headers, GrpcProtocolConstants.StatusTrailer); statusHeadersCollection = response.Headers; if (statusString == null) { Assert.Fail($"Could not get {GrpcProtocolConstants.StatusTrailer} from response."); } } // Get message from the same collection as the status var messageString = GetStatusValue(statusHeadersCollection, GrpcProtocolConstants.MessageTrailer); Assert.AreEqual(statusCode.ToTrailerString(), statusString, $"Expected grpc-status {statusCode} but got {(StatusCode)Convert.ToInt32(statusString, CultureInfo.InvariantCulture)}. Message: {messageString}"); if (messageString != null) { Assert.AreEqual(PercentEncodingHelpers.PercentEncode(details), messageString); } else { Assert.IsTrue(string.IsNullOrEmpty(details)); } } private static string? GetStatusValue(HttpResponseHeaders headers, string name) { if (headers.TryGetValues(name, out var values)) { return values.Single(); } return null; } }
HttpResponseMessageExtensions
csharp
dotnet__extensions
test/Libraries/Microsoft.Extensions.AI.Tests/Functions/AIFunctionFactoryTest.cs
{ "start": 52768, "end": 52829 }
private partial class ____ : JsonSerializerContext; }
JsonContext
csharp
dotnet__aspnetcore
src/Shared/SignalR/InProcessTestServer.cs
{ "start": 686, "end": 1007 }
public abstract class ____ : IAsyncDisposable { internal abstract event Action<LogRecord> ServerLogged; public abstract string WebSocketsUrl { get; } public abstract string Url { get; } public abstract IServiceProvider Services { get; } public abstract ValueTask DisposeAsync(); }
InProcessTestServer
csharp
unoplatform__uno
src/Uno.UI/DirectUI/JoltCollections.h.cs
{ "start": 20197, "end": 22265 }
class ____ marked novtable, so must not be instantiated directly. // ObservablePresentationFrameworkCollectionTemplateBase() // { // m_pEventSource = NULL; // } // public: // typedef CEventSource<VectorChangedEventHandler<T>, IObservableVector<T>, IVectorChangedEventArgs> VectorChangedEventSourceType; // ~ObservablePresentationFrameworkCollectionTemplateBase() // { // ctl.release_interface(m_pEventSource); // } // void OnReferenceTrackerWalk(int walkType) override // { // if( m_pEventSource != NULL ) // m_pEventSource.ReferenceTrackerWalk((EReferenceTrackerWalkType)(walkType)); // PresentationFrameworkCollectionTemplateBase<T>.OnReferenceTrackerWalk( walkType ); // } // add_VectorChanged( VectorChangedEventHandler<T>* pHandler, out EventRegistrationToken ptToken) override // { // VectorChangedEventSourceType pEventSource = NULL; // pEventSource = GetVectorChangedEventSource); // pEventSource.AddHandler(pHandler); // ptToken.value = (INT64)pHandler; // Cleanup: // ctl.release_interface(pEventSource); // return hr; // } // remove_VectorChanged( EventRegistrationToken tToken) override // { // VectorChangedEventSourceType pEventSource = NULL; // VectorChangedEventHandler<T>* pHandler = (VectorChangedEventHandler<T>*)tToken.value; // pEventSource = GetVectorChangedEventSource); // pEventSource.RemoveHandler(pHandler); // tToken.value = 0; // Cleanup: // ctl.release_interface(pEventSource); // return hr; // } // protected: // private void GetVectorChangedEventSource(out VectorChangedEventSourceType* ppEventSource) // { // this.CheckThread(); // if (!m_pEventSource) // { // m_pEventSource = ctl.ComObject<VectorChangedEventSourceType>.CreateInstance); // m_pEventSource.Initialize(KnownEventIndex.UnknownType_UnknownEvent, this, false); // } // ppEventSource = m_pEventSource; // ctl.addref_interface(m_pEventSource); // } // private: // VectorChangedEventSourceType m_pEventSource; // }; // template <
is
csharp
unoplatform__uno
src/Uno.UI/Generated/3.0.0.0/Microsoft.UI.Xaml.Controls/TeachingTipCloseReason.cs
{ "start": 224, "end": 573 }
public enum ____ { // Skipping already declared field Microsoft.UI.Xaml.Controls.TeachingTipCloseReason.CloseButton // Skipping already declared field Microsoft.UI.Xaml.Controls.TeachingTipCloseReason.LightDismiss // Skipping already declared field Microsoft.UI.Xaml.Controls.TeachingTipCloseReason.Programmatic } #endif }
TeachingTipCloseReason
csharp
pythonnet__pythonnet
src/testing/generictest.cs
{ "start": 2582, "end": 2735 }
public abstract class ____ { public virtual Q VirtMethod<Q>(Q arg1) { return arg1; } } }
GenericVirtualMethodTest
csharp
dotnetcore__FreeSql
FreeSql/Extensions/FreeSqlGlobalExtensions.cs
{ "start": 47921, "end": 48272 }
class ____ T3 : class { var newQuery = (query as Select0Provider)._orm.Select<T1, T2, T3>(); Select0Provider.CopyData(query as Select0Provider, newQuery as Select0Provider, null); return newQuery; } public static ISelect<T1, T2, T3, T4> Clone<T1, T2, T3, T4>(this ISelect<T1, T2, T3, T4> query) where T1 :
where
csharp
npgsql__efcore.pg
test/EFCore.PG.FunctionalTests/OptimisticConcurrencyNpgsqlTest.cs
{ "start": 128, "end": 391 }
public class ____(F1BytesNpgsqlFixture fixture) : OptimisticConcurrencyNpgsqlTestBase<F1BytesNpgsqlFixture, byte[]>(fixture); // uint maps directly to xid, which is the PG type of the xmin column that we use as a row version.
OptimisticConcurrencyBytesNpgsqlTest
csharp
dotnet__aspnetcore
src/Middleware/Microsoft.AspNetCore.OutputCaching.StackExchangeRedis/src/RedisOutputCacheStore.Log.cs
{ "start": 282, "end": 1058 }
internal partial class ____ { [LoggerMessage(1, LogLevel.Warning, "Transient error occurred executing redis output-cache GC loop.", EventName = "RedisOutputCacheGCTransientError")] internal static partial void RedisOutputCacheGCTransientFault(ILogger logger, Exception exception); [LoggerMessage(2, LogLevel.Error, "Fatal error occurred executing redis output-cache GC loop.", EventName = "RedisOutputCacheGCFatalError")] internal static partial void RedisOutputCacheGCFatalError(ILogger logger, Exception exception); [LoggerMessage(3, LogLevel.Debug, "Unable to add library name suffix.", EventName = "UnableToAddLibraryNameSuffix")] internal static partial void UnableToAddLibraryNameSuffix(ILogger logger, Exception exception); }
RedisOutputCacheStore
csharp
protobuf-net__protobuf-net
src/protogen.site/Controllers/HomeController.cs
{ "start": 3880, "end": 7755 }
public class ____ { public string Caption { get; } public string Tooling { get; } public ProtocTooling(string tooling, string caption) { Tooling = tooling; Caption = caption; } public static ReadOnlyCollection<ProtocTooling> Options { get; } = new List<ProtocTooling> { new ProtocTooling ("cpp", "C++"), new ProtocTooling ("csharp", "C#"), new ProtocTooling ("java", "Java"), new ProtocTooling ("javanano", "Java Nano"), new ProtocTooling ("js", "JavaScript"), new ProtocTooling ("objc", "Objective-C"), new ProtocTooling ("php", "PHP"), new ProtocTooling ("python", "Python"), new ProtocTooling ("ruby", "Ruby"), }.AsReadOnly(); public static bool IsDefined(string tooling) => Options.Any(x => x.Tooling == tooling); } private CodeFile[] RunProtoc(IWebHostEnvironment host, string schema, string tooling, out string stdout, out string stderr, out int exitCode) { var tmp = Path.GetTempPath(); var session = Path.Combine(tmp, Guid.NewGuid().ToString()); Directory.CreateDirectory(session); try { const string file = "my.proto"; var fullPath = Path.Combine(session, file); System.IO.File.WriteAllText(fullPath, schema); var includeRoot = Path.Combine(host.WebRootPath, "protoc"); var args = $"--experimental_allow_proto3_optional --{tooling}_out=\"{session}\" --proto_path=\"{session}\" --proto_path=\"{includeRoot}\" \"{fullPath}\""; var exePath = Path.Combine(host.WebRootPath, "protoc\\protoc.exe"); if (!System.IO.File.Exists(exePath)) { throw new FileNotFoundException("protoc not found"); } using (var proc = new Process()) { var psi = proc.StartInfo; psi.FileName = exePath; psi.Arguments = args; if (!string.IsNullOrEmpty(session)) psi.WorkingDirectory = session; psi.CreateNoWindow = true; psi.RedirectStandardError = psi.RedirectStandardOutput = true; psi.UseShellExecute = false; proc.Start(); var stdoutTask = proc.StandardOutput.ReadToEndAsync(); var stderrTask = proc.StandardError.ReadToEndAsync(); if (!proc.WaitForExit(5000)) { try { proc.Kill(); } catch { } } exitCode = proc.ExitCode; stderr = stdout = ""; if (stdoutTask.Wait(1000)) stdout = stdoutTask.Result; if (stderrTask.Wait(1000)) stderr = stderrTask.Result; } List<CodeFile> files = new List<CodeFile>(); if (exitCode == 0) { foreach (var generated in Directory.EnumerateFiles(session, "*.*", SearchOption.AllDirectories)) { var name = Path.GetFileName(generated); if (name == file) continue; // that's our input! files.Add(new CodeFile(name, System.IO.File.ReadAllText(generated))); } return files.ToArray(); } else { return null; } } finally { Directory.Delete(session, true); } } } }
ProtocTooling
csharp
MassTransit__MassTransit
src/MassTransit/SagaStateMachine/ScheduleDateTimeExtensions.cs
{ "start": 6399, "end": 10953 }
class ____ TMessage : class { return source.Add( new ScheduleActivity<TInstance, TData, TMessage>(schedule, timeProvider, MessageFactory<TMessage>.Create(messageFactory, callback))); } public static ExceptionActivityBinder<TInstance, TException> Schedule<TInstance, TException, TMessage>( this ExceptionActivityBinder<TInstance, TException> source, Schedule<TInstance, TMessage> schedule, TMessage message, ScheduleTimeExceptionProvider<TInstance, TException> timeProvider, Action<SendContext<TMessage>> callback = null) where TInstance : class, SagaStateMachineInstance where TException : Exception where TMessage : class { return source.Add(new FaultedScheduleActivity<TInstance, TException, TMessage>(schedule, timeProvider, MessageFactory<TMessage>.Create(message, callback))); } public static ExceptionActivityBinder<TInstance, TException> Schedule<TInstance, TException, TMessage>( this ExceptionActivityBinder<TInstance, TException> source, Schedule<TInstance, TMessage> schedule, Task<TMessage> message, ScheduleTimeExceptionProvider<TInstance, TException> timeProvider, Action<SendContext<TMessage>> callback = null) where TInstance : class, SagaStateMachineInstance where TException : Exception where TMessage : class { return source.Add(new FaultedScheduleActivity<TInstance, TException, TMessage>(schedule, timeProvider, MessageFactory<TMessage>.Create(message, callback))); } public static ExceptionActivityBinder<TInstance, TException> Schedule<TInstance, TException, TMessage>( this ExceptionActivityBinder<TInstance, TException> source, Schedule<TInstance, TMessage> schedule, EventExceptionMessageFactory<TInstance, TException, TMessage> messageFactory, ScheduleTimeExceptionProvider<TInstance, TException> timeProvider, Action<SendContext<TMessage>> callback = null) where TInstance : class, SagaStateMachineInstance where TException : Exception where TMessage : class { return source.Add(new FaultedScheduleActivity<TInstance, TException, TMessage>(schedule, timeProvider, MessageFactory<TMessage>.Create(messageFactory, callback))); } public static ExceptionActivityBinder<TInstance, TException> Schedule<TInstance, TException, TMessage>( this ExceptionActivityBinder<TInstance, TException> source, Schedule<TInstance, TMessage> schedule, AsyncEventExceptionMessageFactory<TInstance, TException, TMessage> messageFactory, ScheduleTimeExceptionProvider<TInstance, TException> timeProvider, Action<SendContext<TMessage>> callback = null) where TInstance : class, SagaStateMachineInstance where TException : Exception where TMessage : class { return source.Add(new FaultedScheduleActivity<TInstance, TException, TMessage>(schedule, timeProvider, MessageFactory<TMessage>.Create(messageFactory, callback))); } public static ExceptionActivityBinder<TInstance, TException> Schedule<TInstance, TException, TMessage>( this ExceptionActivityBinder<TInstance, TException> source, Schedule<TInstance, TMessage> schedule, Func<BehaviorExceptionContext<TInstance, TException>, Task<SendTuple<TMessage>>> messageFactory, ScheduleTimeExceptionProvider<TInstance, TException> timeProvider, Action<SendContext<TMessage>> callback = null) where TInstance : class, SagaStateMachineInstance where TException : Exception where TMessage : class { return source.Add(new FaultedScheduleActivity<TInstance, TException, TMessage>(schedule, timeProvider, MessageFactory<TMessage>.Create(messageFactory, callback))); } public static ExceptionActivityBinder<TInstance, TData, TException> Schedule<TInstance, TData, TException, TMessage>( this ExceptionActivityBinder<TInstance, TData, TException> source, Schedule<TInstance, TMessage> schedule, TMessage message, ScheduleTimeExceptionProvider<TInstance, TData, TException> timeProvider, Action<SendContext<TMessage>> callback = null) where TInstance : class, SagaStateMachineInstance where TData :
where
csharp
dotnet__aspnetcore
src/Identity/UI/src/Areas/Identity/Pages/V4/Account/ConfirmEmail.cshtml.cs
{ "start": 1398, "end": 2327 }
internal sealed class ____<TUser> : ConfirmEmailModel where TUser : class { private readonly UserManager<TUser> _userManager; public ConfirmEmailModel(UserManager<TUser> userManager) { _userManager = userManager; } public override async Task<IActionResult> OnGetAsync(string userId, string code) { if (userId == null || code == null) { return RedirectToPage("/Index"); } var user = await _userManager.FindByIdAsync(userId); if (user == null) { return NotFound($"Unable to load user with ID '{userId}'."); } code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code)); var result = await _userManager.ConfirmEmailAsync(user, code); StatusMessage = result.Succeeded ? "Thank you for confirming your email." : "Error confirming your email."; return Page(); } }
ConfirmEmailModel
csharp
AvaloniaUI__Avalonia
samples/GpuInterop/VulkanDemo/VulkanContent.cs
{ "start": 29178, "end": 30914 }
private struct ____ { public Vector3 Position; public Vector3 Normal; public static unsafe VertexInputBindingDescription VertexInputBindingDescription { get { return new VertexInputBindingDescription() { Binding = 0, Stride = (uint)Marshal.SizeOf<Vertex>(), InputRate = VertexInputRate.Vertex }; } } public static unsafe VertexInputAttributeDescription[] VertexInputAttributeDescription { get { return new VertexInputAttributeDescription[] { new VertexInputAttributeDescription { Binding = 0, Location = 0, Format = Format.R32G32B32Sfloat, Offset = (uint)Marshal.OffsetOf<Vertex>("Position") }, new VertexInputAttributeDescription { Binding = 0, Location = 1, Format = Format.R32G32B32Sfloat, Offset = (uint)Marshal.OffsetOf<Vertex>("Normal") } }; } } } private readonly Vertex[] _points; private readonly ushort[] _indices; private readonly float _minY; private readonly float _maxY; static Stopwatch St = Stopwatch.StartNew(); private bool _isInit; private VulkanImage? _colorAttachment; private DescriptorSet _descriptorSet; [StructLayout(LayoutKind.Sequential, Pack = 4)]
Vertex
csharp
dotnetcore__WTM
demo/WalkingTec.Mvvm.BlazorDemo/WalkingTec.Mvvm.BlazorDemo.ViewModel/BasicData/MajorVMs/MajorListVM.cs
{ "start": 2149, "end": 2353 }
public class ____ : Major{ [Display(Name = "学校名称")] public String SchoolName_view { get; set; } [Display(Name = "姓名")] public String Name_view { get; set; } } }
Major_View
csharp
NEventStore__NEventStore
src/NEventStore/Serialization/ByteStreamDocumentSerializer.cs
{ "start": 258, "end": 2465 }
public class ____ : IDocumentSerializer { private static readonly ILogger Logger = LogFactory.BuildLogger(typeof(ByteStreamDocumentSerializer)); private readonly ISerialize _serializer; /// <summary> /// Initializes a new instance of the ByteStreamDocumentSerializer class. /// </summary> public ByteStreamDocumentSerializer(ISerialize serializer) { _serializer = serializer; } /// <inheritdoc/> /// <remarks>Serializes the object graph in a byte array</remarks> public object Serialize<T>(T graph) where T : notnull { if (graph == null) { throw new ArgumentNullException(nameof(graph)); } if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace(Messages.SerializingGraph, typeof(T)); } return _serializer.Serialize(graph); } /// <inheritdoc/> /// <remarks> /// Accepts a byte array (in the form of a byte array or a base64 encoded string) /// and deserialize it to an object graph. /// </remarks> public T? Deserialize<T>(object document) { var bytes = (FromBase64(document as string) ?? document as byte[]) ?? throw new NotSupportedException("document must be byte[] or a string representing base64 encoded byte[]"); if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace(Messages.DeserializingStream, typeof(T)); } return _serializer.Deserialize<T>(bytes); } private static byte[]? FromBase64(string? value) { if (string.IsNullOrEmpty(value)) { return null; } if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace(Messages.InspectingTextStream); } try { return Convert.FromBase64String(value); } catch (FormatException) { return null; } } } }
ByteStreamDocumentSerializer
csharp
microsoft__garnet
libs/server/Objects/ItemBroker/CollectionItemObserver.cs
{ "start": 179, "end": 261 }
class ____ an observer for a specific blocking command /// </summary>
defines
csharp
dotnet__orleans
test/Tester/TestDirectoryCache.cs
{ "start": 2063, "end": 2116 }
public record ____() {
CacheOperation
csharp
AvaloniaUI__Avalonia
src/Avalonia.Base/Rendering/Composition/Server/ServerList.cs
{ "start": 346, "end": 1080 }
class ____<T> : ServerObject where T : ServerObject { public List<T> List { get; } = new List<T>(); protected override void DeserializeChangesCore(BatchStreamReader reader, TimeSpan committedAt) { if (reader.Read<byte>() == 1) { List.Clear(); var count = reader.Read<int>(); for (var c = 0; c < count; c++) List.Add(reader.ReadObject<T>()); } base.DeserializeChangesCore(reader, committedAt); } public List<T>.Enumerator GetEnumerator() => List.GetEnumerator(); public ServerList(ServerCompositor compositor) : base(compositor) { } } }
ServerList
csharp
ServiceStack__ServiceStack
ServiceStack/tests/NorthwindBlazor/Markdown.WhatsNew.cs
{ "start": 126, "end": 2538 }
public class ____(ILogger<MarkdownWhatsNew> log, IWebHostEnvironment env, IVirtualFiles fs) : MarkdownPagesBase<MarkdownFileInfo>(log, env, fs) { public override string Id => "whatsnew"; public Dictionary<string, List<MarkdownFileInfo>> Features { get; set; } = new(); public List<MarkdownFileInfo> GetFeatures(string release) { return Features.TryGetValue(release, out var docs) ? Fresh(docs.Where(IsVisible).OrderBy(x => x.Order).ThenBy(x => x.FileName).ToList()) : []; } public void LoadFrom(string fromDirectory) { Features.Clear(); var dirs = VirtualFiles.GetDirectory(fromDirectory).GetDirectories().ToList(); log.LogInformation("Found {Count} whatsnew directories", dirs.Count); var pipeline = CreatePipeline(); foreach (var dir in dirs) { var datePart = dir.Name.LeftPart('_'); if (!DateTime.TryParseExact(datePart, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out var date)) { log.LogWarning("Could not parse date '{DatePart}', ignoring...", datePart); continue; } var releaseVersion = dir.Name.RightPart('_'); var releaseDate = date; foreach (var file in dir.GetFiles().OrderBy(x => x.Name)) { try { var doc = Load(file.VirtualPath, pipeline); if (doc == null) continue; doc.Date = releaseDate; doc.Group = releaseVersion; var releaseFeatures = Features.GetOrAdd(dir.Name, v => new List<MarkdownFileInfo>()); releaseFeatures.Add(doc); } catch (Exception e) { log.LogError(e, "Couldn't load {VirtualPath}: {Message}", file.VirtualPath, e.Message); } } } } public override List<MarkdownFileBase> GetAll() { var to = new List<MarkdownFileBase>(); foreach (var entry in Features) { to.AddRange(entry.Value.Where(IsVisible).Map(doc => ToMetaDoc(doc, x => x.Content = StripFrontmatter(doc.Content)))); } return to; } }
MarkdownWhatsNew
csharp
dotnet__aspnetcore
src/SignalR/server/SignalR/test/Microsoft.AspNetCore.SignalR.Tests/HubConnectionHandlerTestUtils/Hubs.cs
{ "start": 25262, "end": 25404 }
public abstract class ____ : IDerivedParameterTestObject { public string Value { get; set; } }
DerivedParameterTestObjectBase
csharp
unoplatform__uno
src/Uno.UWP/Generated/3.0.0.0/Windows.Devices.Geolocation/PositionSource.cs
{ "start": 225, "end": 888 }
public enum ____ { // Skipping already declared field Windows.Devices.Geolocation.PositionSource.Cellular // Skipping already declared field Windows.Devices.Geolocation.PositionSource.Satellite // Skipping already declared field Windows.Devices.Geolocation.PositionSource.WiFi // Skipping already declared field Windows.Devices.Geolocation.PositionSource.IPAddress // Skipping already declared field Windows.Devices.Geolocation.PositionSource.Unknown // Skipping already declared field Windows.Devices.Geolocation.PositionSource.Default // Skipping already declared field Windows.Devices.Geolocation.PositionSource.Obfuscated } #endif }
PositionSource
csharp
ChilliCream__graphql-platform
src/HotChocolate/Core/test/Validation.Tests/Models/Alien.cs
{ "start": 36, "end": 214 }
public class ____(string name, string? homePlanet = null) : ISentient { public string Name { get; set; } = name; public string? HomePlanet { get; set; } = homePlanet; }
Alien
csharp
cake-build__cake
src/Cake.Common.Tests/Unit/Build/GitLabCI/GitLabCICommandsTests.cs
{ "start": 814, "end": 3025 }
public sealed class ____ { [Fact] public void Should_Throw_If_EnvPath_Is_Null() { // Given var commands = new GitLabCIFixture().CreateGitLabCIService().Commands; // When var result = Record.Exception(() => commands.SetEnvironmentVariable(null, null, null)); // Then AssertEx.IsArgumentNullException(result, "envPath"); } [Fact] public void Should_Throw_If_Key_Is_Null() { // Given var commands = new GitLabCIFixture().CreateGitLabCIService().Commands; var envPath = "cake.env"; // When var result = Record.Exception(() => commands.SetEnvironmentVariable(envPath, null, null)); // Then AssertEx.IsArgumentNullException(result, "key"); } [Fact] public void Should_Throw_If_Value_Is_Null() { // Given var commands = new GitLabCIFixture().CreateGitLabCIService().Commands; var envPath = "cake.env"; var key = "Key"; // When var result = Record.Exception(() => commands.SetEnvironmentVariable(envPath, key, null)); // Then AssertEx.IsArgumentNullException(result, "value"); } [Fact] public void Should_SetEnvironmentVariable() { // Given var gitLabCIFixture = new GitLabCIFixture(); var commands = gitLabCIFixture.CreateGitLabCIService().Commands; var envPath = "cake.env"; var key = "Key"; var value = "Value"; // When commands.SetEnvironmentVariable(envPath, key, value); // Then Assert.Equal( @"Key=Value ".NormalizeLineEndings(), gitLabCIFixture.FileSystem.GetFile("cake.env").GetTextContent().NormalizeLineEndings()); } } } }
TheSetEnvironmentVariableMethod
csharp
dotnet__orleans
src/api/Orleans.Runtime/Orleans.Runtime.cs
{ "start": 21399, "end": 21700 }
partial class ____ { public static ISiloBuilder AddGrainExtension<TExtensionInterface, TExtension>(this ISiloBuilder builder) where TExtensionInterface : class, Runtime.IGrainExtension where TExtension : class, TExtensionInterface { throw null; } }
HostingGrainExtensions
csharp
dotnet__reactive
AsyncRx.NET/System.Reactive.Async/Disposables/StableCompositeAsyncDisposable.cs
{ "start": 339, "end": 1433 }
public abstract class ____ : IAsyncDisposable { public static StableCompositeAsyncDisposable Create(IAsyncDisposable disposable1, IAsyncDisposable disposable2) { if (disposable1 == null) throw new ArgumentNullException(nameof(disposable1)); if (disposable2 == null) throw new ArgumentNullException(nameof(disposable2)); return new Binary(disposable1, disposable2); } public static StableCompositeAsyncDisposable Create(params IAsyncDisposable[] disposables) { if (disposables == null) throw new ArgumentNullException(nameof(disposables)); return new NAry(disposables); } public static StableCompositeAsyncDisposable Create(IEnumerable<IAsyncDisposable> disposables) { if (disposables == null) throw new ArgumentNullException(nameof(disposables)); return new NAry(disposables); } public abstract ValueTask DisposeAsync();
StableCompositeAsyncDisposable
csharp
bitwarden__server
test/Core.Test/Auth/Services/EmergencyAccessServiceTests.cs
{ "start": 646, "end": 63326 }
public class ____ { [Theory, BitAutoData] public async Task InviteAsync_UserWithOutPremium_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User invitingUser, string email, int waitTime) { sutProvider.GetDependency<IUserService>().CanAccessPremium(invitingUser).Returns(false); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.InviteAsync(invitingUser, email, EmergencyAccessType.Takeover, waitTime)); Assert.Contains("Not a premium user.", exception.Message); await sutProvider.GetDependency<IEmergencyAccessRepository>() .DidNotReceiveWithAnyArgs().CreateAsync(default); } [Theory, BitAutoData] public async Task InviteAsync_UserWithKeyConnector_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User invitingUser, string email, int waitTime) { invitingUser.UsesKeyConnector = true; sutProvider.GetDependency<IUserService>().CanAccessPremium(invitingUser).Returns(true); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.InviteAsync(invitingUser, email, EmergencyAccessType.Takeover, waitTime)); Assert.Contains("You cannot use Emergency Access Takeover because you are using Key Connector", exception.Message); await sutProvider.GetDependency<IEmergencyAccessRepository>() .DidNotReceiveWithAnyArgs().CreateAsync(default); } [Theory] [BitAutoData(EmergencyAccessType.Takeover)] [BitAutoData(EmergencyAccessType.View)] public async Task InviteAsync_ReturnsEmergencyAccessObject( EmergencyAccessType accessType, SutProvider<EmergencyAccessService> sutProvider, User invitingUser, string email, int waitTime) { sutProvider.GetDependency<IUserService>().CanAccessPremium(invitingUser).Returns(true); var result = await sutProvider.Sut.InviteAsync(invitingUser, email, accessType, waitTime); Assert.NotNull(result); Assert.Equal(accessType, result.Type); Assert.Equal(invitingUser.Id, result.GrantorId); Assert.Equal(email, result.Email); Assert.Equal(EmergencyAccessStatusType.Invited, result.Status); await sutProvider.GetDependency<IEmergencyAccessRepository>() .Received(1) .CreateAsync(Arg.Any<EmergencyAccess>()); sutProvider.GetDependency<IDataProtectorTokenFactory<EmergencyAccessInviteTokenable>>() .Received(1) .Protect(Arg.Any<EmergencyAccessInviteTokenable>()); await sutProvider.GetDependency<IMailService>() .Received(1) .SendEmergencyAccessInviteEmailAsync(Arg.Any<EmergencyAccess>(), Arg.Any<string>(), Arg.Any<string>()); } [Theory, BitAutoData] public async Task GetAsync_EmergencyAccessNull_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User user) { EmergencyAccessDetails emergencyAccess = null; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetDetailsByIdGrantorIdAsync(Arg.Any<Guid>(), Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.GetAsync(new Guid(), user.Id)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory, BitAutoData] public async Task ResendInviteAsync_EmergencyAccessNull_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User invitingUser, Guid emergencyAccessId) { EmergencyAccess emergencyAccess = null; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.ResendInviteAsync(invitingUser, emergencyAccessId)); Assert.Contains("Emergency Access not valid.", exception.Message); await sutProvider.GetDependency<IMailService>() .DidNotReceiveWithAnyArgs() .SendEmergencyAccessInviteEmailAsync(default, default, default); } [Theory, BitAutoData] public async Task ResendInviteAsync_InvitingUserIdNotGrantorUserId_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User invitingUser, Guid emergencyAccessId) { var emergencyAccess = new EmergencyAccess { Status = EmergencyAccessStatusType.Invited, GrantorId = Guid.NewGuid(), Type = EmergencyAccessType.Takeover, }; ; sutProvider.GetDependency<IEmergencyAccessRepository>().GetByIdAsync(Arg.Any<Guid>()).Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.ResendInviteAsync(invitingUser, emergencyAccessId)); Assert.Contains("Emergency Access not valid.", exception.Message); await sutProvider.GetDependency<IMailService>() .DidNotReceiveWithAnyArgs() .SendEmergencyAccessInviteEmailAsync(default, default, default); } [Theory] [BitAutoData(EmergencyAccessStatusType.Accepted)] [BitAutoData(EmergencyAccessStatusType.Confirmed)] [BitAutoData(EmergencyAccessStatusType.RecoveryInitiated)] [BitAutoData(EmergencyAccessStatusType.RecoveryApproved)] public async Task ResendInviteAsync_EmergencyAccessStatusInvalid_ThrowsBadRequest( EmergencyAccessStatusType statusType, SutProvider<EmergencyAccessService> sutProvider, User invitingUser, Guid emergencyAccessId) { var emergencyAccess = new EmergencyAccess { Status = statusType, GrantorId = invitingUser.Id, Type = EmergencyAccessType.Takeover, }; sutProvider.GetDependency<IEmergencyAccessRepository>().GetByIdAsync(Arg.Any<Guid>()).Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.ResendInviteAsync(invitingUser, emergencyAccessId)); Assert.Contains("Emergency Access not valid.", exception.Message); await sutProvider.GetDependency<IMailService>() .DidNotReceiveWithAnyArgs() .SendEmergencyAccessInviteEmailAsync(default, default, default); } [Theory, BitAutoData] public async Task ResendInviteAsync_SendsInviteAsync( SutProvider<EmergencyAccessService> sutProvider, User invitingUser, Guid emergencyAccessId) { var emergencyAccess = new EmergencyAccess { Status = EmergencyAccessStatusType.Invited, GrantorId = invitingUser.Id, Type = EmergencyAccessType.Takeover, }; ; sutProvider.GetDependency<IEmergencyAccessRepository>().GetByIdAsync(Arg.Any<Guid>()).Returns(emergencyAccess); await sutProvider.Sut.ResendInviteAsync(invitingUser, emergencyAccessId); sutProvider.GetDependency<IDataProtectorTokenFactory<EmergencyAccessInviteTokenable>>() .Received(1) .Protect(Arg.Any<EmergencyAccessInviteTokenable>()); await sutProvider.GetDependency<IMailService>() .Received(1) .SendEmergencyAccessInviteEmailAsync(emergencyAccess, invitingUser.Name, Arg.Any<string>()); } [Theory, BitAutoData] public async Task AcceptUserAsync_EmergencyAccessNull_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User acceptingUser, string token) { EmergencyAccess emergencyAccess = null; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.AcceptUserAsync(new Guid(), acceptingUser, token, sutProvider.GetDependency<IUserService>())); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory, BitAutoData] public async Task AcceptUserAsync_CannotUnprotectToken_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User acceptingUser, EmergencyAccess emergencyAccess, string token) { sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IDataProtectorTokenFactory<EmergencyAccessInviteTokenable>>() .TryUnprotect(token, out Arg.Any<EmergencyAccessInviteTokenable>()) .Returns(false); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.AcceptUserAsync(emergencyAccess.Id, acceptingUser, token, sutProvider.GetDependency<IUserService>())); Assert.Contains("Invalid token.", exception.Message); } [Theory, BitAutoData] public async Task AcceptUserAsync_TokenDataInvalid_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User acceptingUser, EmergencyAccess emergencyAccess, EmergencyAccess wrongEmergencyAccess, string token) { sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IDataProtectorTokenFactory<EmergencyAccessInviteTokenable>>() .TryUnprotect(token, out Arg.Any<EmergencyAccessInviteTokenable>()) .Returns(callInfo => { callInfo[1] = new EmergencyAccessInviteTokenable(wrongEmergencyAccess, 1); return true; }); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.AcceptUserAsync(emergencyAccess.Id, acceptingUser, token, sutProvider.GetDependency<IUserService>())); Assert.Contains("Invalid token.", exception.Message); } [Theory, BitAutoData] public async Task AcceptUserAsync_AcceptedStatus_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User acceptingUser, EmergencyAccess emergencyAccess, string token) { emergencyAccess.Status = EmergencyAccessStatusType.Accepted; emergencyAccess.Email = acceptingUser.Email; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IDataProtectorTokenFactory<EmergencyAccessInviteTokenable>>() .TryUnprotect(token, out Arg.Any<EmergencyAccessInviteTokenable>()) .Returns(callInfo => { callInfo[1] = new EmergencyAccessInviteTokenable(emergencyAccess, 1); return true; }); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.AcceptUserAsync(emergencyAccess.Id, acceptingUser, token, sutProvider.GetDependency<IUserService>())); Assert.Contains("Invitation already accepted. You will receive an email when the grantor confirms you as an emergency access contact.", exception.Message); } [Theory, BitAutoData] public async Task AcceptUserAsync_NotInvitedStatus_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User acceptingUser, EmergencyAccess emergencyAccess, string token) { emergencyAccess.Status = EmergencyAccessStatusType.Confirmed; emergencyAccess.Email = acceptingUser.Email; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IDataProtectorTokenFactory<EmergencyAccessInviteTokenable>>() .TryUnprotect(token, out Arg.Any<EmergencyAccessInviteTokenable>()) .Returns(callInfo => { callInfo[1] = new EmergencyAccessInviteTokenable(emergencyAccess, 1); return true; }); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.AcceptUserAsync(emergencyAccess.Id, acceptingUser, token, sutProvider.GetDependency<IUserService>())); Assert.Contains("Invitation already accepted.", exception.Message); } [Theory(Skip = "Code not reachable, Tokenable checks email match in IsValid()"), BitAutoData] public async Task AcceptUserAsync_EmergencyAccessEmailDoesNotMatch_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User acceptingUser, EmergencyAccess emergencyAccess, string token) { emergencyAccess.Status = EmergencyAccessStatusType.Invited; emergencyAccess.Email = acceptingUser.Email; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IDataProtectorTokenFactory<EmergencyAccessInviteTokenable>>() .TryUnprotect(token, out Arg.Any<EmergencyAccessInviteTokenable>()) .Returns(callInfo => { callInfo[1] = new EmergencyAccessInviteTokenable(emergencyAccess, 1); return true; }); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.AcceptUserAsync(emergencyAccess.Id, acceptingUser, token, sutProvider.GetDependency<IUserService>())); Assert.Contains("User email does not match invite.", exception.Message); } [Theory, BitAutoData] public async Task AcceptUserAsync_ReplaceEmergencyAccess_SendsEmail_Success( SutProvider<EmergencyAccessService> sutProvider, User acceptingUser, User invitingUser, EmergencyAccess emergencyAccess, string token) { emergencyAccess.Status = EmergencyAccessStatusType.Invited; emergencyAccess.Email = acceptingUser.Email; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IUserService>() .GetUserByIdAsync(Arg.Any<Guid>()) .Returns(invitingUser); sutProvider.GetDependency<IDataProtectorTokenFactory<EmergencyAccessInviteTokenable>>() .TryUnprotect(token, out Arg.Any<EmergencyAccessInviteTokenable>()) .Returns(callInfo => { callInfo[1] = new EmergencyAccessInviteTokenable(emergencyAccess, 1); return true; }); await sutProvider.Sut.AcceptUserAsync(emergencyAccess.Id, acceptingUser, token, sutProvider.GetDependency<IUserService>()); await sutProvider.GetDependency<IEmergencyAccessRepository>() .Received(1) .ReplaceAsync(Arg.Is<EmergencyAccess>(x => x.Status == EmergencyAccessStatusType.Accepted)); await sutProvider.GetDependency<IMailService>() .Received(1) .SendEmergencyAccessAcceptedEmailAsync(acceptingUser.Email, invitingUser.Email); } [Theory, BitAutoData] public async Task DeleteAsync_EmergencyAccessNull_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User invitingUser, EmergencyAccess emergencyAccess) { sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns((EmergencyAccess)null); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.DeleteAsync(emergencyAccess.Id, invitingUser.Id)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory, BitAutoData] public async Task DeleteAsync_EmergencyAccessGrantorIdNotEqual_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User invitingUser, EmergencyAccess emergencyAccess) { emergencyAccess.GrantorId = Guid.NewGuid(); sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.DeleteAsync(emergencyAccess.Id, invitingUser.Id)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory, BitAutoData] public async Task DeleteAsync_EmergencyAccessGranteeIdNotEqual_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User invitingUser, EmergencyAccess emergencyAccess) { emergencyAccess.GranteeId = Guid.NewGuid(); sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.DeleteAsync(emergencyAccess.Id, invitingUser.Id)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory, BitAutoData] public async Task DeleteAsync_EmergencyAccessIsDeleted_Success( SutProvider<EmergencyAccessService> sutProvider, User user, EmergencyAccess emergencyAccess) { emergencyAccess.GranteeId = user.Id; emergencyAccess.GrantorId = user.Id; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); await sutProvider.Sut.DeleteAsync(emergencyAccess.Id, user.Id); await sutProvider.GetDependency<IEmergencyAccessRepository>() .Received(1) .DeleteAsync(emergencyAccess); } [Theory, BitAutoData] public async Task ConfirmUserAsync_EmergencyAccessNull_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, string key, User grantorUser) { emergencyAccess.GrantorId = grantorUser.Id; emergencyAccess.Status = EmergencyAccessStatusType.RecoveryInitiated; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns((EmergencyAccess)null); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.ConfirmUserAsync(emergencyAccess.Id, key, grantorUser.Id)); Assert.Contains("Emergency Access not valid.", exception.Message); await sutProvider.GetDependency<IEmergencyAccessRepository>().DidNotReceiveWithAnyArgs().ReplaceAsync(default); } [Theory, BitAutoData] public async Task ConfirmUserAsync_EmergencyAccessStatusIsNotAccepted_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, string key, User grantorUser) { emergencyAccess.GrantorId = grantorUser.Id; emergencyAccess.Status = EmergencyAccessStatusType.RecoveryInitiated; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(emergencyAccess.Id) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.ConfirmUserAsync(emergencyAccess.Id, key, grantorUser.Id)); Assert.Contains("Emergency Access not valid.", exception.Message); await sutProvider.GetDependency<IEmergencyAccessRepository>().DidNotReceiveWithAnyArgs().ReplaceAsync(default); } [Theory, BitAutoData] public async Task ConfirmUserAsync_EmergencyAccessGrantorIdNotEqualToConfirmingUserId_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, string key, User grantorUser) { emergencyAccess.Status = EmergencyAccessStatusType.RecoveryInitiated; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.ConfirmUserAsync(emergencyAccess.Id, key, grantorUser.Id)); Assert.Contains("Emergency Access not valid.", exception.Message); await sutProvider.GetDependency<IEmergencyAccessRepository>().DidNotReceiveWithAnyArgs().ReplaceAsync(default); } [Theory, BitAutoData] public async Task ConfirmUserAsync_UserWithKeyConnectorCannotUseTakeover_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User confirmingUser, string key) { confirmingUser.UsesKeyConnector = true; var emergencyAccess = new EmergencyAccess { Status = EmergencyAccessStatusType.Accepted, GrantorId = confirmingUser.Id, Type = EmergencyAccessType.Takeover, }; sutProvider.GetDependency<IUserRepository>() .GetByIdAsync(confirmingUser.Id) .Returns(confirmingUser); sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.ConfirmUserAsync(new Guid(), key, confirmingUser.Id)); Assert.Contains("You cannot use Emergency Access Takeover because you are using Key Connector", exception.Message); await sutProvider.GetDependency<IEmergencyAccessRepository>().DidNotReceiveWithAnyArgs().ReplaceAsync(default); } [Theory, BitAutoData] public async Task ConfirmUserAsync_ConfirmsAndReplacesEmergencyAccess_Success( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, string key, User grantorUser, User granteeUser) { emergencyAccess.GrantorId = grantorUser.Id; emergencyAccess.Status = EmergencyAccessStatusType.Accepted; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IUserRepository>() .GetByIdAsync(grantorUser.Id) .Returns(grantorUser); sutProvider.GetDependency<IUserRepository>() .GetByIdAsync(emergencyAccess.GranteeId.Value) .Returns(granteeUser); await sutProvider.Sut.ConfirmUserAsync(emergencyAccess.Id, key, grantorUser.Id); await sutProvider.GetDependency<IEmergencyAccessRepository>() .Received(1) .ReplaceAsync(Arg.Is<EmergencyAccess>(x => x.Status == EmergencyAccessStatusType.Confirmed)); await sutProvider.GetDependency<IMailService>() .Received(1) .SendEmergencyAccessConfirmedEmailAsync(grantorUser.Name, granteeUser.Email); } [Theory, BitAutoData] public async Task SaveAsync_PremiumCannotUpdate_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User savingUser) { var emergencyAccess = new EmergencyAccess { Type = EmergencyAccessType.Takeover, GrantorId = savingUser.Id, }; sutProvider.GetDependency<IUserService>() .CanAccessPremium(savingUser) .Returns(false); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.SaveAsync(emergencyAccess, savingUser)); Assert.Contains("Not a premium user.", exception.Message); await sutProvider.GetDependency<IEmergencyAccessRepository>().DidNotReceiveWithAnyArgs().ReplaceAsync(default); } [Theory, BitAutoData] public async Task SaveAsync_EmergencyAccessGrantorIdNotEqualToSavingUserId_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User savingUser) { savingUser.Premium = true; var emergencyAccess = new EmergencyAccess { Type = EmergencyAccessType.Takeover, GrantorId = new Guid(), }; sutProvider.GetDependency<IUserService>() .GetUserByIdAsync(savingUser.Id) .Returns(savingUser); sutProvider.GetDependency<IUserService>() .CanAccessPremium(savingUser) .Returns(true); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.SaveAsync(emergencyAccess, savingUser)); Assert.Contains("Emergency Access not valid.", exception.Message); await sutProvider.GetDependency<IEmergencyAccessRepository>().DidNotReceiveWithAnyArgs().ReplaceAsync(default); } [Theory, BitAutoData] public async Task SaveAsync_GrantorUserWithKeyConnectorCannotTakeover_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User grantorUser) { grantorUser.UsesKeyConnector = true; var emergencyAccess = new EmergencyAccess { Type = EmergencyAccessType.Takeover, GrantorId = grantorUser.Id, }; var userService = sutProvider.GetDependency<IUserService>(); userService.GetUserByIdAsync(grantorUser.Id).Returns(grantorUser); userService.CanAccessPremium(grantorUser).Returns(true); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.SaveAsync(emergencyAccess, grantorUser)); Assert.Contains("You cannot use Emergency Access Takeover because you are using Key Connector", exception.Message); await sutProvider.GetDependency<IEmergencyAccessRepository>().DidNotReceiveWithAnyArgs().ReplaceAsync(default); } [Theory, BitAutoData] public async Task SaveAsync_GrantorUserWithKeyConnectorCanView_SavesEmergencyAccess( SutProvider<EmergencyAccessService> sutProvider, User grantorUser) { grantorUser.UsesKeyConnector = true; var emergencyAccess = new EmergencyAccess { Type = EmergencyAccessType.View, GrantorId = grantorUser.Id, }; var userService = sutProvider.GetDependency<IUserService>(); userService.GetUserByIdAsync(grantorUser.Id).Returns(grantorUser); userService.CanAccessPremium(grantorUser).Returns(true); await sutProvider.Sut.SaveAsync(emergencyAccess, grantorUser); await sutProvider.GetDependency<IEmergencyAccessRepository>() .Received(1) .ReplaceAsync(emergencyAccess); } [Theory, BitAutoData] public async Task SaveAsync_ValidRequest_SavesEmergencyAccess( SutProvider<EmergencyAccessService> sutProvider, User grantorUser) { grantorUser.UsesKeyConnector = false; var emergencyAccess = new EmergencyAccess { Type = EmergencyAccessType.Takeover, GrantorId = grantorUser.Id, }; var userService = sutProvider.GetDependency<IUserService>(); userService.GetUserByIdAsync(grantorUser.Id).Returns(grantorUser); userService.CanAccessPremium(grantorUser).Returns(true); await sutProvider.Sut.SaveAsync(emergencyAccess, grantorUser); await sutProvider.GetDependency<IEmergencyAccessRepository>() .Received(1) .ReplaceAsync(emergencyAccess); } [Theory, BitAutoData] public async Task InitiateAsync_EmergencyAccessNull_ThrowBadRequest( SutProvider<EmergencyAccessService> sutProvider, User initiatingUser) { sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns((EmergencyAccess)null); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.InitiateAsync(new Guid(), initiatingUser)); Assert.Contains("Emergency Access not valid.", exception.Message); await sutProvider.GetDependency<IEmergencyAccessRepository>() .DidNotReceiveWithAnyArgs() .ReplaceAsync(default); } [Theory, BitAutoData] public async Task InitiateAsync_EmergencyAccessGranteeIdNotEqual_ThrowBadRequest( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User initiatingUser) { emergencyAccess.GranteeId = new Guid(); sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(emergencyAccess.Id) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.InitiateAsync(new Guid(), initiatingUser)); Assert.Contains("Emergency Access not valid.", exception.Message); await sutProvider.GetDependency<IEmergencyAccessRepository>() .DidNotReceiveWithAnyArgs() .ReplaceAsync(default); } [Theory, BitAutoData] public async Task InitiateAsync_EmergencyAccessStatusIsNotConfirmed_ThrowBadRequest( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User initiatingUser) { emergencyAccess.GranteeId = initiatingUser.Id; emergencyAccess.Status = EmergencyAccessStatusType.Invited; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(emergencyAccess.Id) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.InitiateAsync(new Guid(), initiatingUser)); Assert.Contains("Emergency Access not valid.", exception.Message); await sutProvider.GetDependency<IEmergencyAccessRepository>() .DidNotReceiveWithAnyArgs() .ReplaceAsync(default); } [Theory, BitAutoData] public async Task InitiateAsync_UserWithKeyConnectorCannotUseTakeover_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User initiatingUser, User grantor) { grantor.UsesKeyConnector = true; var emergencyAccess = new EmergencyAccess { Status = EmergencyAccessStatusType.Confirmed, GranteeId = initiatingUser.Id, GrantorId = grantor.Id, Type = EmergencyAccessType.Takeover, }; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IUserRepository>() .GetByIdAsync(grantor.Id) .Returns(grantor); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.InitiateAsync(new Guid(), initiatingUser)); Assert.Contains("You cannot takeover an account that is using Key Connector", exception.Message); await sutProvider.GetDependency<IEmergencyAccessRepository>() .DidNotReceiveWithAnyArgs() .ReplaceAsync(default); } [Theory, BitAutoData] public async Task InitiateAsync_UserWithKeyConnectorCanView_Success( SutProvider<EmergencyAccessService> sutProvider, User initiatingUser, User grantor) { grantor.UsesKeyConnector = true; var emergencyAccess = new EmergencyAccess { Status = EmergencyAccessStatusType.Confirmed, GranteeId = initiatingUser.Id, GrantorId = grantor.Id, Type = EmergencyAccessType.View, }; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IUserRepository>() .GetByIdAsync(grantor.Id) .Returns(grantor); await sutProvider.Sut.InitiateAsync(new Guid(), initiatingUser); await sutProvider.GetDependency<IEmergencyAccessRepository>() .Received(1) .ReplaceAsync(Arg.Is<EmergencyAccess>(x => x.Status == EmergencyAccessStatusType.RecoveryInitiated)); } [Theory, BitAutoData] public async Task InitiateAsync_RequestIsCorrect_Success( SutProvider<EmergencyAccessService> sutProvider, User initiatingUser, User grantor) { var emergencyAccess = new EmergencyAccess { Status = EmergencyAccessStatusType.Confirmed, GranteeId = initiatingUser.Id, GrantorId = grantor.Id, Type = EmergencyAccessType.Takeover, }; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IUserRepository>() .GetByIdAsync(grantor.Id) .Returns(grantor); await sutProvider.Sut.InitiateAsync(new Guid(), initiatingUser); await sutProvider.GetDependency<IEmergencyAccessRepository>() .Received(1) .ReplaceAsync(Arg.Is<EmergencyAccess>(x => x.Status == EmergencyAccessStatusType.RecoveryInitiated)); } [Theory, BitAutoData] public async Task ApproveAsync_EmergencyAccessNull_ThrowsBadrequest( SutProvider<EmergencyAccessService> sutProvider) { sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns((EmergencyAccess)null); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.ApproveAsync(new Guid(), null)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory, BitAutoData] public async Task ApproveAsync_EmergencyAccessGrantorIdNotEquatToApproving_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User grantorUser) { emergencyAccess.Status = EmergencyAccessStatusType.RecoveryInitiated; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.ApproveAsync(emergencyAccess.Id, grantorUser)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory] [BitAutoData(EmergencyAccessStatusType.Invited)] [BitAutoData(EmergencyAccessStatusType.Accepted)] [BitAutoData(EmergencyAccessStatusType.Confirmed)] [BitAutoData(EmergencyAccessStatusType.RecoveryApproved)] public async Task ApproveAsync_EmergencyAccessStatusNotRecoveryInitiated_ThrowsBadRequest( EmergencyAccessStatusType statusType, SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User grantorUser) { emergencyAccess.GrantorId = grantorUser.Id; emergencyAccess.Status = statusType; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.ApproveAsync(emergencyAccess.Id, grantorUser)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory, BitAutoData] public async Task ApproveAsync_Success( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User grantorUser, User granteeUser) { emergencyAccess.GrantorId = grantorUser.Id; emergencyAccess.Status = EmergencyAccessStatusType.RecoveryInitiated; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IUserRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(granteeUser); await sutProvider.Sut.ApproveAsync(emergencyAccess.Id, grantorUser); await sutProvider.GetDependency<IEmergencyAccessRepository>() .Received(1) .ReplaceAsync(Arg.Is<EmergencyAccess>(x => x.Status == EmergencyAccessStatusType.RecoveryApproved)); } [Theory, BitAutoData] public async Task RejectAsync_EmergencyAccessIdNull_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User GrantorUser) { emergencyAccess.GrantorId = GrantorUser.Id; emergencyAccess.Status = EmergencyAccessStatusType.Accepted; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns((EmergencyAccess)null); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.RejectAsync(emergencyAccess.Id, GrantorUser)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory, BitAutoData] public async Task RejectAsync_EmergencyAccessGrantorIdNotEqualToRequestUser_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User GrantorUser) { emergencyAccess.Status = EmergencyAccessStatusType.Accepted; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.RejectAsync(emergencyAccess.Id, GrantorUser)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory] [BitAutoData(EmergencyAccessStatusType.Invited)] [BitAutoData(EmergencyAccessStatusType.Accepted)] [BitAutoData(EmergencyAccessStatusType.Confirmed)] public async Task RejectAsync_EmergencyAccessStatusNotValid_ThrowsBadRequest( EmergencyAccessStatusType statusType, SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User GrantorUser) { emergencyAccess.GrantorId = GrantorUser.Id; emergencyAccess.Status = statusType; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.RejectAsync(emergencyAccess.Id, GrantorUser)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory] [BitAutoData(EmergencyAccessStatusType.RecoveryInitiated)] [BitAutoData(EmergencyAccessStatusType.RecoveryApproved)] public async Task RejectAsync_Success( EmergencyAccessStatusType statusType, SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User GrantorUser, User GranteeUser) { emergencyAccess.GrantorId = GrantorUser.Id; emergencyAccess.Status = statusType; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IUserRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(GranteeUser); await sutProvider.Sut.RejectAsync(emergencyAccess.Id, GrantorUser); await sutProvider.GetDependency<IEmergencyAccessRepository>() .Received(1) .ReplaceAsync(Arg.Is<EmergencyAccess>(x => x.Status == EmergencyAccessStatusType.Confirmed)); } [Theory, BitAutoData] public async Task GetPoliciesAsync_RequestNotValidEmergencyAccessNull_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider) { sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns((EmergencyAccess)null); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.GetPoliciesAsync(default, default)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory] [BitAutoData(EmergencyAccessStatusType.Invited)] [BitAutoData(EmergencyAccessStatusType.Accepted)] [BitAutoData(EmergencyAccessStatusType.Confirmed)] [BitAutoData(EmergencyAccessStatusType.RecoveryInitiated)] public async Task GetPoliciesAsync_RequestNotValidStatusType_ThrowsBadRequest( EmergencyAccessStatusType statusType, SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User granteeUser) { emergencyAccess.GranteeId = granteeUser.Id; emergencyAccess.Status = statusType; emergencyAccess.Type = EmergencyAccessType.Takeover; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.GetPoliciesAsync(emergencyAccess.Id, granteeUser)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory, BitAutoData] public async Task GetPoliciesAsync_RequestNotValidType_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User granteeUser) { emergencyAccess.GranteeId = granteeUser.Id; emergencyAccess.Status = EmergencyAccessStatusType.RecoveryApproved; emergencyAccess.Type = EmergencyAccessType.View; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.GetPoliciesAsync(emergencyAccess.Id, granteeUser)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory] [BitAutoData(OrganizationUserType.Admin)] [BitAutoData(OrganizationUserType.User)] [BitAutoData(OrganizationUserType.Custom)] public async Task GetPoliciesAsync_OrganizationUserTypeNotOwner_ReturnsNull( OrganizationUserType userType, SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User granteeUser, User grantorUser, OrganizationUser grantorOrganizationUser) { emergencyAccess.GrantorId = grantorUser.Id; emergencyAccess.GranteeId = granteeUser.Id; emergencyAccess.Status = EmergencyAccessStatusType.RecoveryApproved; emergencyAccess.Type = EmergencyAccessType.Takeover; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IUserRepository>() .GetByIdAsync(emergencyAccess.GrantorId) .Returns(grantorUser); grantorOrganizationUser.UserId = grantorUser.Id; grantorOrganizationUser.Type = userType; sutProvider.GetDependency<IOrganizationUserRepository>() .GetManyByUserAsync(grantorUser.Id) .Returns([grantorOrganizationUser]); var result = await sutProvider.Sut.GetPoliciesAsync(emergencyAccess.Id, granteeUser); Assert.Null(result); } [Theory, BitAutoData] public async Task GetPoliciesAsync_OrganizationUserEmpty_ReturnsNull( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User granteeUser, User grantorUser) { emergencyAccess.GrantorId = grantorUser.Id; emergencyAccess.GranteeId = granteeUser.Id; emergencyAccess.Status = EmergencyAccessStatusType.RecoveryApproved; emergencyAccess.Type = EmergencyAccessType.Takeover; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IUserRepository>() .GetByIdAsync(emergencyAccess.GrantorId) .Returns(grantorUser); sutProvider.GetDependency<IOrganizationUserRepository>() .GetManyByUserAsync(grantorUser.Id) .Returns([]); var result = await sutProvider.Sut.GetPoliciesAsync(emergencyAccess.Id, granteeUser); Assert.Null(result); } [Theory, BitAutoData] public async Task GetPoliciesAsync_ReturnsNotNull( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User granteeUser, User grantorUser, OrganizationUser grantorOrganizationUser) { emergencyAccess.GrantorId = grantorUser.Id; emergencyAccess.GranteeId = granteeUser.Id; emergencyAccess.Status = EmergencyAccessStatusType.RecoveryApproved; emergencyAccess.Type = EmergencyAccessType.Takeover; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IUserRepository>() .GetByIdAsync(emergencyAccess.GrantorId) .Returns(grantorUser); grantorOrganizationUser.UserId = grantorUser.Id; grantorOrganizationUser.Type = OrganizationUserType.Owner; sutProvider.GetDependency<IOrganizationUserRepository>() .GetManyByUserAsync(grantorUser.Id) .Returns([grantorOrganizationUser]); sutProvider.GetDependency<IPolicyRepository>() .GetManyByUserIdAsync(grantorUser.Id) .Returns([]); var result = await sutProvider.Sut.GetPoliciesAsync(emergencyAccess.Id, granteeUser); Assert.NotNull(result); } [Theory, BitAutoData] public async Task TakeoverAsync_RequestNotValid_EmergencyAccessIsNull_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider) { sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns((EmergencyAccess)null); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.TakeoverAsync(default, default)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory, BitAutoData] public async Task TakeoverAsync_RequestNotValid_GranteeNotEqualToRequestingUser_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User granteeUser) { emergencyAccess.Status = EmergencyAccessStatusType.RecoveryApproved; emergencyAccess.Type = EmergencyAccessType.Takeover; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.TakeoverAsync(new Guid(), granteeUser)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory] [BitAutoData(EmergencyAccessStatusType.Invited)] [BitAutoData(EmergencyAccessStatusType.Accepted)] [BitAutoData(EmergencyAccessStatusType.Confirmed)] [BitAutoData(EmergencyAccessStatusType.RecoveryInitiated)] public async Task TakeoverAsync_RequestNotValid_StatusType_ThrowsBadRequest( EmergencyAccessStatusType statusType, SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User granteeUser) { emergencyAccess.GranteeId = granteeUser.Id; emergencyAccess.Status = statusType; emergencyAccess.Type = EmergencyAccessType.Takeover; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.TakeoverAsync(new Guid(), granteeUser)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory, BitAutoData] public async Task TakeoverAsync_RequestNotValid_TypeIsView_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User granteeUser) { emergencyAccess.GranteeId = granteeUser.Id; emergencyAccess.Status = EmergencyAccessStatusType.RecoveryApproved; emergencyAccess.Type = EmergencyAccessType.View; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.TakeoverAsync(new Guid(), granteeUser)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory, BitAutoData] public async Task TakeoverAsync_UserWithKeyConnectorCannotUseTakeover_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, User granteeUser, User grantor) { grantor.UsesKeyConnector = true; var emergencyAccess = new EmergencyAccess { GrantorId = grantor.Id, GranteeId = granteeUser.Id, Status = EmergencyAccessStatusType.RecoveryApproved, Type = EmergencyAccessType.Takeover, }; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IUserRepository>() .GetByIdAsync(grantor.Id) .Returns(grantor); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.TakeoverAsync(new Guid(), granteeUser)); Assert.Contains("You cannot takeover an account that is using Key Connector", exception.Message); } [Theory, BitAutoData] public async Task TakeoverAsync_Success_ReturnsEmergencyAccessAndGrantorUser( SutProvider<EmergencyAccessService> sutProvider, User granteeUser, User grantor) { grantor.UsesKeyConnector = false; var emergencyAccess = new EmergencyAccess { GrantorId = grantor.Id, GranteeId = granteeUser.Id, Status = EmergencyAccessStatusType.RecoveryApproved, Type = EmergencyAccessType.Takeover, }; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IUserRepository>() .GetByIdAsync(grantor.Id) .Returns(grantor); var result = await sutProvider.Sut.TakeoverAsync(new Guid(), granteeUser); Assert.Equal(result.Item1, emergencyAccess); Assert.Equal(result.Item2, grantor); } [Theory, BitAutoData] public async Task PasswordAsync_RequestNotValid_EmergencyAccessIsNull_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider) { sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns((EmergencyAccess)null); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.PasswordAsync(default, default, default, default)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory, BitAutoData] public async Task PasswordAsync_RequestNotValid_GranteeNotEqualToRequestingUser_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User granteeUser) { emergencyAccess.Status = EmergencyAccessStatusType.RecoveryApproved; emergencyAccess.Type = EmergencyAccessType.Takeover; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.PasswordAsync(emergencyAccess.Id, granteeUser, default, default)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory] [BitAutoData(EmergencyAccessStatusType.Invited)] [BitAutoData(EmergencyAccessStatusType.Accepted)] [BitAutoData(EmergencyAccessStatusType.Confirmed)] [BitAutoData(EmergencyAccessStatusType.RecoveryInitiated)] public async Task PasswordAsync_RequestNotValid_StatusType_ThrowsBadRequest( EmergencyAccessStatusType statusType, SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User granteeUser) { emergencyAccess.GranteeId = granteeUser.Id; emergencyAccess.Status = statusType; emergencyAccess.Type = EmergencyAccessType.Takeover; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.PasswordAsync(emergencyAccess.Id, granteeUser, default, default)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory, BitAutoData] public async Task PasswordAsync_RequestNotValid_TypeIsView_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User granteeUser) { emergencyAccess.GranteeId = granteeUser.Id; emergencyAccess.Status = EmergencyAccessStatusType.RecoveryApproved; emergencyAccess.Type = EmergencyAccessType.View; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.PasswordAsync(emergencyAccess.Id, granteeUser, default, default)); Assert.Contains("Emergency Access not valid.", exception.Message); } [Theory, BitAutoData] public async Task PasswordAsync_NonOrgUser_Success( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User granteeUser, User grantorUser, string key, string passwordHash) { emergencyAccess.GranteeId = granteeUser.Id; emergencyAccess.GrantorId = grantorUser.Id; emergencyAccess.Status = EmergencyAccessStatusType.RecoveryApproved; emergencyAccess.Type = EmergencyAccessType.Takeover; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IUserRepository>() .GetByIdAsync(emergencyAccess.GrantorId) .Returns(grantorUser); await sutProvider.Sut.PasswordAsync(emergencyAccess.Id, granteeUser, passwordHash, key); await sutProvider.GetDependency<IUserService>() .Received(1) .UpdatePasswordHash(grantorUser, passwordHash); await sutProvider.GetDependency<IUserRepository>() .Received(1) .ReplaceAsync(Arg.Is<User>(u => u.VerifyDevices == false && u.Key == key)); } [Theory] [BitAutoData(OrganizationUserType.User)] [BitAutoData(OrganizationUserType.Admin)] [BitAutoData(OrganizationUserType.Custom)] public async Task PasswordAsync_OrgUser_NotOrganizationOwner_RemovedFromOrganization_Success( OrganizationUserType userType, SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User granteeUser, User grantorUser, OrganizationUser organizationUser, string key, string passwordHash) { emergencyAccess.GranteeId = granteeUser.Id; emergencyAccess.GrantorId = grantorUser.Id; emergencyAccess.Status = EmergencyAccessStatusType.RecoveryApproved; emergencyAccess.Type = EmergencyAccessType.Takeover; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IUserRepository>() .GetByIdAsync(emergencyAccess.GrantorId) .Returns(grantorUser); organizationUser.UserId = grantorUser.Id; organizationUser.Type = userType; sutProvider.GetDependency<IOrganizationUserRepository>() .GetManyByUserAsync(grantorUser.Id) .Returns([organizationUser]); await sutProvider.Sut.PasswordAsync(emergencyAccess.Id, granteeUser, passwordHash, key); await sutProvider.GetDependency<IUserService>() .Received(1) .UpdatePasswordHash(grantorUser, passwordHash); await sutProvider.GetDependency<IUserRepository>() .Received(1) .ReplaceAsync(Arg.Is<User>(u => u.VerifyDevices == false && u.Key == key)); await sutProvider.GetDependency<IRemoveOrganizationUserCommand>() .Received(1) .RemoveUserAsync(organizationUser.OrganizationId, organizationUser.UserId.Value); } [Theory, BitAutoData] public async Task PasswordAsync_OrgUser_IsOrganizationOwner_NotRemovedFromOrganization_Success( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User granteeUser, User grantorUser, OrganizationUser organizationUser, string key, string passwordHash) { emergencyAccess.GranteeId = granteeUser.Id; emergencyAccess.GrantorId = grantorUser.Id; emergencyAccess.Status = EmergencyAccessStatusType.RecoveryApproved; emergencyAccess.Type = EmergencyAccessType.Takeover; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IUserRepository>() .GetByIdAsync(emergencyAccess.GrantorId) .Returns(grantorUser); organizationUser.UserId = grantorUser.Id; organizationUser.Type = OrganizationUserType.Owner; sutProvider.GetDependency<IOrganizationUserRepository>() .GetManyByUserAsync(grantorUser.Id) .Returns([organizationUser]); await sutProvider.Sut.PasswordAsync(emergencyAccess.Id, granteeUser, passwordHash, key); await sutProvider.GetDependency<IUserService>() .Received(1) .UpdatePasswordHash(grantorUser, passwordHash); await sutProvider.GetDependency<IUserRepository>() .Received(1) .ReplaceAsync(Arg.Is<User>(u => u.VerifyDevices == false && u.Key == key)); await sutProvider.GetDependency<IRemoveOrganizationUserCommand>() .Received(0) .RemoveUserAsync(organizationUser.OrganizationId, organizationUser.UserId.Value); } [Theory, BitAutoData] public async Task PasswordAsync_Disables_NewDeviceVerification_And_TwoFactorProviders_On_The_Grantor( SutProvider<EmergencyAccessService> sutProvider, User requestingUser, User grantor) { grantor.UsesKeyConnector = true; grantor.SetTwoFactorProviders(new Dictionary<TwoFactorProviderType, TwoFactorProvider> { [TwoFactorProviderType.Email] = new TwoFactorProvider { MetaData = new Dictionary<string, object> { ["Email"] = "asdfasf" }, Enabled = true } }); var emergencyAccess = new EmergencyAccess { GrantorId = grantor.Id, GranteeId = requestingUser.Id, Status = EmergencyAccessStatusType.RecoveryApproved, Type = EmergencyAccessType.Takeover, }; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); sutProvider.GetDependency<IUserRepository>() .GetByIdAsync(grantor.Id) .Returns(grantor); await sutProvider.Sut.PasswordAsync(Guid.NewGuid(), requestingUser, "blablahash", "blablakey"); Assert.Empty(grantor.GetTwoFactorProviders()); Assert.False(grantor.VerifyDevices); await sutProvider.GetDependency<IUserRepository>().Received().ReplaceAsync(grantor); } [Theory, BitAutoData] public async Task ViewAsync_EmergencyAccessTypeNotView_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User granteeUser) { emergencyAccess.GranteeId = granteeUser.Id; emergencyAccess.Type = EmergencyAccessType.Takeover; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.ViewAsync(emergencyAccess.Id, granteeUser)); } [Theory, BitAutoData] public async Task GetAttachmentDownloadAsync_EmergencyAccessTypeNotView_ThrowsBadRequest( SutProvider<EmergencyAccessService> sutProvider, EmergencyAccess emergencyAccess, User granteeUser) { emergencyAccess.GranteeId = granteeUser.Id; emergencyAccess.Type = EmergencyAccessType.Takeover; sutProvider.GetDependency<IEmergencyAccessRepository>() .GetByIdAsync(Arg.Any<Guid>()) .Returns(emergencyAccess); var exception = await Assert.ThrowsAsync<BadRequestException>( () => sutProvider.Sut.GetAttachmentDownloadAsync(emergencyAccess.Id, default, default, granteeUser)); } }
EmergencyAccessServiceTests
csharp
dotnet__maui
src/Compatibility/Core/src/WPF/Extensions/ScrollBarVisibilityExtensions.cs
{ "start": 152, "end": 639 }
static class ____ { internal static WpfScrollBarVisibility ToWpfScrollBarVisibility(this ScrollBarVisibility visibility) { switch (visibility) { case ScrollBarVisibility.Always: return WpfScrollBarVisibility.Visible; case ScrollBarVisibility.Default: return WpfScrollBarVisibility.Auto; case ScrollBarVisibility.Never: return WpfScrollBarVisibility.Hidden; default: return WpfScrollBarVisibility.Auto; } } } }
ScrollBarVisibilityExtensions
csharp
cake-build__cake
src/Cake.Common.Tests/Unit/Tools/MSBuild/MSBuildSettingsTests.cs
{ "start": 7538, "end": 7884 }
public sealed class ____ { [Fact] public void Should_Be_Empty_By_Default() { // Given var settings = new MSBuildSettings(); // Then Assert.Empty(settings.WarningsAsErrorCodes); } }
TheWarningsAsErrorCodesProperty
csharp
nopSolutions__nopCommerce
src/Presentation/Nop.Web/Models/Catalog/CatalogProductsModel.cs
{ "start": 183, "end": 3104 }
public partial record ____ : BasePageableModel { #region Properties /// <summary> /// Get or set a value indicating whether to use standard or AJAX products loading (applicable to 'paging', 'filtering', 'view modes') in catalog /// </summary> public bool UseAjaxLoading { get; set; } /// <summary> /// Gets or sets the warning message /// </summary> public string WarningMessage { get; set; } /// <summary> /// Gets or sets the message if there are no products to return /// </summary> public string NoResultMessage { get; set; } /// <summary> /// Gets or sets the price range filter model /// </summary> public PriceRangeFilterModel PriceRangeFilter { get; set; } /// <summary> /// Gets or sets the specification filter model /// </summary> public SpecificationFilterModel SpecificationFilter { get; set; } /// <summary> /// Gets or sets the manufacturer filter model /// </summary> public ManufacturerFilterModel ManufacturerFilter { get; set; } /// <summary> /// Gets or sets a value indicating whether product sorting is allowed /// </summary> public bool AllowProductSorting { get; set; } /// <summary> /// Gets or sets available sort options /// </summary> public IList<SelectListItem> AvailableSortOptions { get; set; } /// <summary> /// Gets or sets a value indicating whether customers are allowed to change view mode /// </summary> public bool AllowProductViewModeChanging { get; set; } /// <summary> /// Gets or sets available view mode options /// </summary> public IList<SelectListItem> AvailableViewModes { get; set; } /// <summary> /// Gets or sets a value indicating whether customers are allowed to select page size /// </summary> public bool AllowCustomersToSelectPageSize { get; set; } /// <summary> /// Gets or sets available page size options /// </summary> public IList<SelectListItem> PageSizeOptions { get; set; } /// <summary> /// Gets or sets a order by /// </summary> public int? OrderBy { get; set; } /// <summary> /// Gets or sets a product sorting /// </summary> public string ViewMode { get; set; } /// <summary> /// Gets or sets the products /// </summary> public IList<ProductOverviewModel> Products { get; set; } #endregion #region Ctor public CatalogProductsModel() { PriceRangeFilter = new PriceRangeFilterModel(); SpecificationFilter = new SpecificationFilterModel(); ManufacturerFilter = new ManufacturerFilterModel(); AvailableSortOptions = new List<SelectListItem>(); AvailableViewModes = new List<SelectListItem>(); PageSizeOptions = new List<SelectListItem>(); Products = new List<ProductOverviewModel>(); } #endregion }
CatalogProductsModel
csharp
aspnetboilerplate__aspnetboilerplate
src/Abp.Web.Common/Web/Models/DefaultErrorInfoConverter.cs
{ "start": 420, "end": 7895 }
internal class ____ : IExceptionToErrorInfoConverter { private readonly IAbpWebCommonModuleConfiguration _configuration; private readonly ILocalizationManager _localizationManager; public IExceptionToErrorInfoConverter Next { set; private get; } private bool SendAllExceptionsToClients { get { return _configuration.SendAllExceptionsToClients; } } public DefaultErrorInfoConverter( IAbpWebCommonModuleConfiguration configuration, ILocalizationManager localizationManager) { _configuration = configuration; _localizationManager = localizationManager; } public ErrorInfo Convert(Exception exception) { var errorInfo = CreateErrorInfoWithoutCode(exception); if (exception is IHasErrorCode) { errorInfo.Code = (exception as IHasErrorCode).Code; } return errorInfo; } private ErrorInfo CreateErrorInfoWithoutCode(Exception exception) { if (SendAllExceptionsToClients) { return CreateDetailedErrorInfoFromException(exception); } if (exception is AggregateException && exception.InnerException != null) { var aggException = exception as AggregateException; if (aggException.InnerException is UserFriendlyException || aggException.InnerException is AbpValidationException) { exception = aggException.InnerException; } } if (exception is UserFriendlyException) { var userFriendlyException = exception as UserFriendlyException; return new ErrorInfo(userFriendlyException.Message, userFriendlyException.Details); } if (exception is AbpValidationException) { return new ErrorInfo(L("ValidationError")) { ValidationErrors = GetValidationErrorInfos(exception as AbpValidationException), Details = GetValidationErrorNarrative(exception as AbpValidationException) }; } if (exception is EntityNotFoundException) { var entityNotFoundException = exception as EntityNotFoundException; if (entityNotFoundException.EntityType != null) { return new ErrorInfo( string.Format( L("EntityNotFound"), entityNotFoundException.EntityType.Name, entityNotFoundException.Id ) ); } return new ErrorInfo( entityNotFoundException.Message ); } if (exception is Abp.Authorization.AbpAuthorizationException) { var authorizationException = exception as Abp.Authorization.AbpAuthorizationException; return new ErrorInfo(authorizationException.Message); } return new ErrorInfo(L("InternalServerError")); } private ErrorInfo CreateDetailedErrorInfoFromException(Exception exception) { var detailBuilder = new StringBuilder(); AddExceptionToDetails(exception, detailBuilder); var errorInfo = new ErrorInfo(exception.Message, detailBuilder.ToString()); if (exception is AbpValidationException) { errorInfo.ValidationErrors = GetValidationErrorInfos(exception as AbpValidationException); } return errorInfo; } private void AddExceptionToDetails(Exception exception, StringBuilder detailBuilder) { //Exception Message detailBuilder.AppendLine(exception.GetType().Name + ": " + exception.Message); //Additional info for UserFriendlyException if (exception is UserFriendlyException) { var userFriendlyException = exception as UserFriendlyException; if (!string.IsNullOrEmpty(userFriendlyException.Details)) { detailBuilder.AppendLine(userFriendlyException.Details); } } //Additional info for AbpValidationException if (exception is AbpValidationException) { var validationException = exception as AbpValidationException; if (validationException.ValidationErrors.Count > 0) { detailBuilder.AppendLine(GetValidationErrorNarrative(validationException)); } } //Exception StackTrace if (!string.IsNullOrEmpty(exception.StackTrace)) { detailBuilder.AppendLine("STACK TRACE: " + exception.StackTrace); } //Inner exception if (exception.InnerException != null) { AddExceptionToDetails(exception.InnerException, detailBuilder); } //Inner exceptions for AggregateException if (exception is AggregateException) { var aggException = exception as AggregateException; if (aggException.InnerExceptions.IsNullOrEmpty()) { return; } foreach (var innerException in aggException.InnerExceptions) { AddExceptionToDetails(innerException, detailBuilder); } } } private ValidationErrorInfo[] GetValidationErrorInfos(AbpValidationException validationException) { var validationErrorInfos = new List<ValidationErrorInfo>(); foreach (var validationResult in validationException.ValidationErrors) { var validationError = new ValidationErrorInfo(validationResult.ErrorMessage); if (validationResult.MemberNames != null && validationResult.MemberNames.Any()) { validationError.Members = validationResult.MemberNames.Select(m => m.ToCamelCase()).ToArray(); } validationErrorInfos.Add(validationError); } return validationErrorInfos.ToArray(); } private string GetValidationErrorNarrative(AbpValidationException validationException) { var detailBuilder = new StringBuilder(); detailBuilder.AppendLine(L("ValidationNarrativeTitle")); foreach (var validationResult in validationException.ValidationErrors) { detailBuilder.AppendFormat(" - {0}", validationResult.ErrorMessage); detailBuilder.AppendLine(); } return detailBuilder.ToString(); } private string L(string name) { try { return _localizationManager.GetString(AbpWebConsts.LocalizationSourceName, name); } catch (Exception) { return name; } } } }
DefaultErrorInfoConverter
csharp
CommunityToolkit__WindowsCommunityToolkit
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/StaggeredPanel/StaggeredPanelPage.xaml.cs
{ "start": 503, "end": 1180 }
partial class ____ : Page, IXamlRenderListener { public StaggeredPanelPage() { this.InitializeComponent(); } public async void OnXamlRendered(FrameworkElement control) { var gridView = control.FindChild("GridView") as ItemsControl; if (gridView == null) { return; } var items = await new Data.PhotosDataSource().GetItemsAsync(); gridView.ItemsSource = items .Select((p, i) => new { Item = p, Index = i + 1 }); } } }
StaggeredPanelPage
csharp
EventStore__EventStore
src/KurrentDB.Core.Tests/TransactionLog/when_reading_logical_bytes_bulk_from_a_chunk.cs
{ "start": 524, "end": 5479 }
public class ____<TLogFormat, TStreamId> : SpecificationWithDirectory { [Test] public async Task the_file_will_not_be_deleted_until_reader_released() { var chunk = await TFChunkHelper.CreateNewChunk(GetFilePathFor("file1"), 2000); using (var reader = await chunk.AcquireDataReader(CancellationToken.None)) { chunk.MarkForDeletion(); var buffer = new byte[1024]; var result = await reader.ReadNextBytes(buffer, CancellationToken.None); Assert.IsFalse(result.IsEOF); Assert.AreEqual(0, result.BytesRead); // no data yet } chunk.WaitForDestroy(5000); } [Test] public async Task a_read_on_new_file_can_be_performed_but_returns_nothing() { var chunk = await TFChunkHelper.CreateNewChunk(GetFilePathFor("file1"), 2000); using (var reader = await chunk.AcquireDataReader(CancellationToken.None)) { var buffer = new byte[1024]; var result = await reader.ReadNextBytes(buffer, CancellationToken.None); Assert.IsFalse(result.IsEOF); Assert.AreEqual(0, result.BytesRead); } chunk.MarkForDeletion(); chunk.WaitForDestroy(5000); } [Test] public async Task a_read_past_end_of_completed_chunk_does_not_include_footer() { var chunk = await TFChunkHelper.CreateNewChunk(GetFilePathFor("file1"), 300); await chunk.Complete(CancellationToken.None); // chunk has 0 bytes of actual data using (var reader = await chunk.AcquireDataReader(CancellationToken.None)) { var buffer = new byte[1024]; var result = await reader.ReadNextBytes(buffer, CancellationToken.None); Assert.IsTrue(result.IsEOF); Assert.AreEqual(0, result.BytesRead); } chunk.MarkForDeletion(); chunk.WaitForDestroy(5000); } [Test] public async Task a_read_on_scavenged_chunk_does_not_include_map() { var chunk = await TFChunkHelper.CreateNewChunk(GetFilePathFor("afile"), 200, isScavenged: true); await chunk.CompleteScavenge([new PosMap(0, 0), new PosMap(1, 1)], CancellationToken.None); using (var reader = await chunk.AcquireDataReader(CancellationToken.None)) { var buffer = new byte[1024]; var result = await reader.ReadNextBytes(buffer, CancellationToken.None); Assert.IsTrue(result.IsEOF); Assert.AreEqual(0, result.BytesRead); //header 128 + footer 128 + map 16 } chunk.MarkForDeletion(); chunk.WaitForDestroy(5000); } [Test] public async Task if_asked_for_more_than_buffer_size_will_only_read_buffer_size() { var chunk = await TFChunkHelper.CreateNewChunk(GetFilePathFor("file1"), 3000); var recordFactory = LogFormatHelper<TLogFormat, TStreamId>.RecordFactory; var streamId = LogFormatHelper<TLogFormat, TStreamId>.StreamId; var eventTypeId = LogFormatHelper<TLogFormat, TStreamId>.EventTypeId; var rec = LogRecord.Prepare(recordFactory, 0, Guid.NewGuid(), Guid.NewGuid(), 0, 0, streamId, -1, PrepareFlags.None, eventTypeId, new byte[2000], null); Assert.IsTrue((await chunk.TryAppend(rec, CancellationToken.None)).Success, "Record was not appended"); using (var reader = await chunk.AcquireDataReader(CancellationToken.None)) { var buffer = new byte[1024]; var result = await reader.ReadNextBytes(buffer, CancellationToken.None); Assert.IsFalse(result.IsEOF); Assert.AreEqual(1024, result.BytesRead); } chunk.MarkForDeletion(); chunk.WaitForDestroy(5000); } [Test] public async Task a_read_past_eof_doesnt_return_eof_if_chunk_is_not_yet_completed() { var chunk = await TFChunkHelper.CreateNewChunk(GetFilePathFor("file1"), 300); var rec = LogRecord.Commit(0, Guid.NewGuid(), 0, 0); Assert.IsTrue((await chunk.TryAppend(rec, CancellationToken.None)).Success, "Record was not appended"); using (var reader = await chunk.AcquireDataReader(CancellationToken.None)) { var buffer = new byte[1024]; var result = await reader.ReadNextBytes(buffer, CancellationToken.None); Assert.IsFalse(result.IsEOF, "EOF was returned."); //does not include header and footer space Assert.AreEqual(rec.GetSizeWithLengthPrefixAndSuffix(), result.BytesRead, "Read wrong number of bytes."); } chunk.MarkForDeletion(); chunk.WaitForDestroy(5000); } [Test] public async Task a_read_past_eof_returns_eof_if_chunk_is_completed() { var chunk = await TFChunkHelper.CreateNewChunk(GetFilePathFor("file1"), 300); var rec = LogRecord.Commit(0, Guid.NewGuid(), 0, 0); Assert.IsTrue((await chunk.TryAppend(rec, CancellationToken.None)).Success, "Record was not appended"); await chunk.Complete(CancellationToken.None); using (var reader = await chunk.AcquireDataReader(CancellationToken.None)) { var buffer = new byte[1024]; var result = await reader.ReadNextBytes(buffer, CancellationToken.None); Assert.IsTrue(result.IsEOF, "EOF was not returned."); //does not include header and footer space Assert.AreEqual(rec.GetSizeWithLengthPrefixAndSuffix(), result.BytesRead, "Read wrong number of bytes."); } chunk.MarkForDeletion(); chunk.WaitForDestroy(5000); } }
when_reading_logical_bytes_bulk_from_a_chunk
csharp
dotnet__aspnetcore
src/Framework/AspNetCoreAnalyzers/test/RouteHandlers/DisallowNonParsableComplexTypesOnParametersTest.cs
{ "start": 12054, "end": 13276 }
public class ____ : IBindableFromHttpContext<Customer> { static async ValueTask<Customer?> IBindableFromHttpContext<Customer>.BindAsync(HttpContext context, ParameterInfo parameter) { return new Customer(); } } """; var expectedDiagnostic = new DiagnosticResult(DiagnosticDescriptors.RouteParameterComplexTypeIsNotParsable) .WithArguments("customer", "Customer") .WithLocation(0); // Act await VerifyCS.VerifyAnalyzerAsync(source, expectedDiagnostic); } [Fact] public async Task Route_Parameter_withNullableType_Works() { // Arrange var source = $$""" using System; using Microsoft.AspNetCore.Builder; var webApp = WebApplication.Create(); webApp.MapGet("/customers/{customer}/contacts", (int? customer) => {}); """; // Act await VerifyCS.VerifyAnalyzerAsync(source); } [Fact] public async Task Handler_Parameter_withFromBodyAttribute_Works() { // Arrange var source = $$""" using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Builder; var webApp = WebApplication.Create(); webApp.MapPost( "/customers", ([FromBody]Customer customer) => { });
Customer
csharp
fluentassertions__fluentassertions
Src/FluentAssertions/Specialized/GenericAsyncFunctionAssertions.cs
{ "start": 1135, "end": 8730 }
class ____ custom <see cref="IClock"/>. /// </summary> public GenericAsyncFunctionAssertions(Func<Task<TResult>> subject, IExtractExceptions extractor, AssertionChain assertionChain, IClock clock) : base(subject, extractor, assertionChain, clock) { this.assertionChain = assertionChain; } /// <summary> /// Asserts that the current <see cref="Task{T}"/> will complete within the specified time. /// </summary> /// <param name="timeSpan">The allowed time span for the operation.</param> /// <param name="because"> /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically. /// </param> /// <param name="becauseArgs"> /// Zero or more objects to format using the placeholders in <paramref name="because" />. /// </param> public async Task<AndWhichConstraint<GenericAsyncFunctionAssertions<TResult>, TResult>> CompleteWithinAsync( TimeSpan timeSpan, [StringSyntax("CompositeFormat")] string because = "", params object[] becauseArgs) { assertionChain .ForCondition(Subject is not null) .BecauseOf(because, becauseArgs) .FailWith("Expected {context} to complete within {0}{reason}, but found <null>.", timeSpan); if (assertionChain.Succeeded) { (Task<TResult> task, TimeSpan remainingTime) = InvokeWithTimer(timeSpan); assertionChain .ForCondition(remainingTime >= TimeSpan.Zero) .BecauseOf(because, becauseArgs) .FailWith("Expected {context:task} to complete within {0}{reason}.", timeSpan); if (assertionChain.Succeeded) { bool completesWithinTimeout = await CompletesWithinTimeoutAsync(task, remainingTime, _ => Task.CompletedTask); assertionChain .ForCondition(completesWithinTimeout) .BecauseOf(because, becauseArgs) .FailWith("Expected {context:task} to complete within {0}{reason}.", timeSpan); } #pragma warning disable CA1849 // Call async methods when in an async method TResult result = assertionChain.Succeeded ? task.Result : default; #pragma warning restore CA1849 // Call async methods when in an async method return new AndWhichConstraint<GenericAsyncFunctionAssertions<TResult>, TResult>(this, result, assertionChain, ".Result"); } return new AndWhichConstraint<GenericAsyncFunctionAssertions<TResult>, TResult>(this, default(TResult)); } /// <summary> /// Asserts that the current <see cref="Task{T}"/> does not throw any exception. /// </summary> /// <param name="because"> /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically. /// </param> /// <param name="becauseArgs"> /// Zero or more objects to format using the placeholders in <paramref name="because" />. /// </param> public async Task<AndWhichConstraint<GenericAsyncFunctionAssertions<TResult>, TResult>> NotThrowAsync( [StringSyntax("CompositeFormat")] string because = "", params object[] becauseArgs) { assertionChain .ForCondition(Subject is not null) .BecauseOf(because, becauseArgs) .FailWith("Expected {context} not to throw{reason}, but found <null>."); if (assertionChain.Succeeded) { try { TResult result = await Subject!.Invoke(); return new AndWhichConstraint<GenericAsyncFunctionAssertions<TResult>, TResult>(this, result, assertionChain, ".Result"); } catch (Exception exception) { _ = NotThrowInternal(exception, because, becauseArgs); } } return new AndWhichConstraint<GenericAsyncFunctionAssertions<TResult>, TResult>(this, default(TResult)); } /// <summary> /// Asserts that the current <see cref="Task{T}"/> stops throwing any exception /// after a specified amount of time. /// </summary> /// <remarks> /// The <see cref="Task{T}"/> is invoked. If it raises an exception, /// the invocation is repeated until it either stops raising any exceptions /// or the specified wait time is exceeded. /// </remarks> /// <param name="waitTime"> /// The time after which the <see cref="Task{T}"/> should have stopped throwing any exception. /// </param> /// <param name="pollInterval"> /// The time between subsequent invocations of the <see cref="Task{T}"/>. /// </param> /// <param name="because"> /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically. /// </param> /// <param name="becauseArgs"> /// Zero or more objects to format using the placeholders in <paramref name="because" />. /// </param> /// <exception cref="ArgumentOutOfRangeException"><paramref name="waitTime"/> or <paramref name="pollInterval"/> are negative.</exception> public Task<AndWhichConstraint<GenericAsyncFunctionAssertions<TResult>, TResult>> NotThrowAfterAsync( TimeSpan waitTime, TimeSpan pollInterval, [StringSyntax("CompositeFormat")] string because = "", params object[] becauseArgs) { Guard.ThrowIfArgumentIsNegative(waitTime); Guard.ThrowIfArgumentIsNegative(pollInterval); assertionChain .ForCondition(Subject is not null) .BecauseOf(because, becauseArgs) .FailWith("Expected {context} not to throw any exceptions after {0}{reason}, but found <null>.", waitTime); if (assertionChain.Succeeded) { return AssertionTaskAsync(); async Task<AndWhichConstraint<GenericAsyncFunctionAssertions<TResult>, TResult>> AssertionTaskAsync() { TimeSpan? invocationEndTime = null; Exception exception = null; ITimer timer = Clock.StartTimer(); while (invocationEndTime is null || invocationEndTime < waitTime) { try { TResult result = await Subject.Invoke(); return new AndWhichConstraint<GenericAsyncFunctionAssertions<TResult>, TResult>(this, result, assertionChain, ".Result"); } catch (Exception ex) { exception = ex; await Clock.DelayAsync(pollInterval, CancellationToken.None); invocationEndTime = timer.Elapsed; } } assertionChain .BecauseOf(because, becauseArgs) .FailWith("Did not expect any exceptions after {0}{reason}, but found {1}.", waitTime, exception); return new AndWhichConstraint<GenericAsyncFunctionAssertions<TResult>, TResult>(this, default(TResult)); } } return Task.FromResult(new AndWhichConstraint<GenericAsyncFunctionAssertions<TResult>, TResult>(this, default(TResult))); } }
with
csharp
dotnet__efcore
src/EFCore.Relational/Metadata/Conventions/Infrastructure/RelationalConventionSetBuilderDependencies.cs
{ "start": 287, "end": 625 }
class ____ <see cref="RelationalConventionSetBuilder" /> /// </para> /// <para> /// This type is typically used by database providers (and other extensions). It is generally /// not used in application code. /// </para> /// </summary> /// <remarks> /// <para> /// Do not construct instances of this
for