public void SupportsValidCSharpDefaultParameters() { var source = typeof(ShimGeneratorTests).GetMethod(nameof(MethodWithAllPossibleCSharpDefaultParameters)); var shim = ShimGenerator.WithDefaultParametersPassed <Func <bool> >(source); Assert.True(shim()); }
public void SupportsProperlyEncodedSingleConstants() { var source = typeof(ILMethodsWithDefaultParameters).GetMethod(nameof(SinglesEncodedProperly)); var shim = ShimGenerator.WithDefaultParametersPassed <Func <bool> >(source); Assert.True(shim()); }
public void SupportsShimsForNoDefaultParameters() { var source = typeof(ShimGeneratorTests).GetMethod(nameof(MethodWithoutDefaultParameters)); var shim = ShimGenerator.WithDefaultParametersPassed <Func <double, string, int, object, bool> >(source); Assert.True(shim(Float64Constant, LiteralString, Int32Constant, null)); }
//Note that this support is not just a checkbox. There is a proposal on csharplang for this, and it has recently been looked at by the LDT public void SupportsNonTrailingDefaultParameters() { var source = typeof(ILMethodsWithDefaultParameters).GetMethod(nameof(MethodWithNonTrailingDefaultParameters)); var shim = ShimGenerator.WithDefaultParametersPassed <Func <float, sbyte, bool> >(source); Assert.True(shim(32f, 8)); }
public void SupportsDateTimeConstantAttribute() { var source = typeof(ILMethodsWithDefaultParameters).GetMethod(nameof(DateTimeEncodedAttribute)); var shim = ShimGenerator.WithDefaultParametersPassed <Func <bool> >(source); Assert.True(shim()); }
public void TargetParameterMustExactlyMatchRequiredSourceParameters() { var source = typeof(ShimGeneratorTests).GetMethod(nameof(MethodWithDefaultAndRequiredParameters)); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <string, double, bool> >(source))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <long, string, bool> >(source))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <decimal, double, bool> >(source))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <double, string, int, object, bool> >(source))); }
public void DoesNotSupportBadlyEncodedInt64Constants() { var type = typeof(ILMethodsWithDefaultParameters); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(Int64EncodedWithBoolean))))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(Int64EncodedWithChar))))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(Int64EncodedWithTooBigUInt64))))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(Int64EncodedWithSingle))))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(Int64EncodedWithDouble))))); }
public void DoesNotSupportBadlyEncodedNativeIntegerConstants() { var type = typeof(ILMethodsWithDefaultParameters); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeIntEncodedWithBoolean))))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeIntEncodedWithChar))))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeIntEncodedWithTooBigUInt32))))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeIntEncodedWithTooSmallInt64))))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeIntEncodedWithTooBigInt64))))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeIntEncodedWithTooBigUInt64))))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeUIntEncodedWithBoolean))))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeUIntEncodedWithChar))))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeUIntEncodedWithTooSmallInt8))))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeUIntEncodedWithTooSmallInt16))))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeUIntEncodedWithTooSmallInt32))))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeUIntEncodedWithTooSmallInt64))))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeUIntEncodedWithTooBigInt64))))); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeUIntEncodedWithTooBigUInt64))))); }
private void PerformRefreshDistroList(bool triggeredByUser) { var items = SharedRoutines.LoadDistroList().ToArray(); DistroListView.Items.Clear(); foreach (var eachItem in items) { var lvItem = new ListViewItem( eachItem.Properties.Select(x => x.Value).ToArray(), eachItem.ImageKey) { Tag = eachItem, }; DistroListView.Items.Add(lvItem); } TotalCountLabel.Text = $"{items.Length} item{(items.Length > 1 ? "s" : "")}"; if (DistroListView.Items.Count < 1) { DistroListView.Visible = false; emptyLabel.Visible = true; } else { DistroListView.Visible = true; emptyLabel.Visible = false; } if (!ShimGenerator.IsBusy) { ShimGenerator.RunWorkerAsync(new BackgroundWorkerArgument <DistroProperties[]>(triggeredByUser, items)); } if (!ShortcutGenerator.IsBusy) { ShortcutGenerator.RunWorkerAsync(new BackgroundWorkerArgument <DistroProperties[]>(triggeredByUser, items)); } }
public void DoesNotSupportInParameters() { var source = typeof(ShimGeneratorTests).GetMethod(nameof(MethodWithDefaultInParameters)); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <int> >(source))); }
public void DoesNotSupportReturnTypeMismatch() { var source = typeof(ShimGeneratorTests).GetMethod(nameof(MethodWithAllPossibleCSharpDefaultParameters)); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <int> >(source))); }