Skip to content

Month, ZeroableMonth, MonthRange, etc. must be structures instead of classes since they are should be considered ValueTypes #6

@jochenwezel

Description

@jochenwezel

Problem

Dim A as new Month(2020,1)
Dim B as new MonthRange(A, A)
Assert.AreEqual(2020, B.FirstMonth.Year) 'success
A.Year = 2021

Assert.AreEqual(2020, B.FirstMonth.Year) 'failed: B.FirstYear = 2021 instead of 2020
'expected by typical developer: 2020, but is now 2021 since Month is a class and 
'MonthRange was created using a pointer/reference instead of a copy from A

Attention

  • existing code might break down if it comes to Null-checks or comparisons with Null-values
  • existing compiled code breaks down after replacing dependency: binary compatibility is broken down since class objects are structures, now

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions