Skip to content

StackOverflawException with default constructed value (Since 4.142.0) #1118

Closed
@ryoasai

Description

@ryoasai

Describe the bug
StackOverflawException when getting value from default constructed value object. See reproduction sample below.

To Reproduce
Steps to reproduce the behavior (just an example):

  1. Add nuget UnitsNet 4.142.0 or later to a .NET 6 project
  2. Build using Visual Studio 2022 Community v17.3.0
        [Fact]
        public void Init_DefaultConstruct()
        {
            Length x = default;
            Assert.Equal(0.0, x.Micrometers); // StackOverflowExeption when accessing X.Micrometers property.
        }

Expected behavior
A value object should not cause a StackOverflowExeption for default value and it should give 0 as was previous version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions