diff --git a/src/ReactiveUI.Fody.Tests/Issues/Issue47Tests.cs b/src/ReactiveUI.Fody.Tests/Issues/Issue47Tests.cs new file mode 100644 index 0000000000..b575ba95d6 --- /dev/null +++ b/src/ReactiveUI.Fody.Tests/Issues/Issue47Tests.cs @@ -0,0 +1,33 @@ +// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for full license information. + +using System.Diagnostics.CodeAnalysis; +using ReactiveUI.Fody.Helpers; + +namespace ReactiveUI.Fody.Tests.Issues +{ + public static class Issue47Tests + { + /// + /// The "test" here is simply for these to compile + /// Tests ObservableAsPropertyWeaver.EmitDefaultValue. + /// + [SuppressMessage("Microsoft.Performance", "CA1812: Avoid uninstantiated internal classes", Justification = "Purpose is just to be compiled.")] + private class TestModel : ReactiveObject + { + [ObservableAsProperty] + public int IntProperty { get; } + + [ObservableAsProperty] + public double DoubleProperty { get; } + + [ObservableAsProperty] + public float FloatProperty { get; } + + [ObservableAsProperty] + public long LongProperty { get; } + } + } +} diff --git a/src/ReactiveUI.Fody/ObservableAsPropertyWeaver.cs b/src/ReactiveUI.Fody/ObservableAsPropertyWeaver.cs index cb17f2b310..926440c094 100644 --- a/src/ReactiveUI.Fody/ObservableAsPropertyWeaver.cs +++ b/src/ReactiveUI.Fody/ObservableAsPropertyWeaver.cs @@ -155,7 +155,7 @@ public void EmitDefaultValue(MethodBody methodBody, ILProcessor il, TypeReferenc } else if (type.CompareTo(ModuleDefinition.TypeSystem.Int64)) { - il.Emit(OpCodes.Ldc_I8); + il.Emit(OpCodes.Ldc_I8, 0L); } else if (type.CompareTo(ModuleDefinition.TypeSystem.Double)) {