BoysheO.PropertyTable 0.0.15

dotnet add package BoysheO.PropertyTable --version 0.0.15
                    
NuGet\Install-Package BoysheO.PropertyTable -Version 0.0.15
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BoysheO.PropertyTable" Version="0.0.15" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BoysheO.PropertyTable" Version="0.0.15" />
                    
Directory.Packages.props
<PackageReference Include="BoysheO.PropertyTable" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BoysheO.PropertyTable --version 0.0.15
                    
#r "nuget: BoysheO.PropertyTable, 0.0.15"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BoysheO.PropertyTable@0.0.15
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BoysheO.PropertyTable&version=0.0.15
                    
Install as a Cake Addin
#tool nuget:?package=BoysheO.PropertyTable&version=0.0.15
                    
Install as a Cake Tool

BoysheO.PropertyTable 设计说明

本文记录 DynamicValue 数学运算符的设计原则。DynamicValue 是带运行时类型信息的属性值容器,数学运算必须保留类型语义,避免把非数学类型或有损转换静默吞掉。

支持的运算符

DynamicValue 支持以下数学运算符:

  • +
  • -
  • *
  • /
  • ++
  • --

所有运算结果的 Type 都跟随左操作数。比如 DynamicValue.Create(1L) + DynamicValue.Create(2) 的结果类型是 long,DynamicValue.Create(1) + DynamicValue.Create(2L) 的结果类型是 int。

类型边界

允许参与数学运算的类型只有明确的数学数值类型:

  • 整数:int、uint、long、ulong
  • 浮点:float、double
  • 可空数值:int?、uint?、float?

以下类型不允许参与数学运算:

  • char、char?
  • bool、bool?
  • string
  • enum、nullable enum
  • 引用类型
  • 未初始化或无类型的默认 DynamicValue

非数学类型参与运算时抛出 InvalidCastException。可空数值为 null 时参与运算抛出 InvalidOperationException。

加减法

加法和减法允许兼容的跨数值类型运算,例如 long 与 int。结果类型仍跟随左操作数。

如果右操作数或运算结果不能无损转换为左操作数类型,则抛出 OverflowException。这包括整数溢出,以及浮点值转回整数时会发生截断的情况。

自增自减

++ 和 -- 等价于当前值与同类型数值 1 执行 checked 加减。

自增自减支持整数、浮点和有值的可空数值。结果类型仍跟随原值类型;例如 int? 自增后仍是 int?。

乘法

乘法按整数族和浮点族分开处理:

  • 整数乘法只允许整数类型之间运算。
  • 浮点乘法只允许浮点类型之间运算。
  • 整数与浮点混合乘法被视为类型不兼容,抛出 InvalidCastException。

整数乘法使用 checked 语义,发生溢出时抛出 OverflowException。

除法

DynamicValue 禁用整数除法。整数类型使用 / 时抛出 InvalidOperationException,调用方需要先转换为真实整数类型后自行决定除法语义。

浮点除法只允许浮点类型之间运算。浮点除以 0 抛出 DivideByZeroException,不返回 Infinity 或 NaN。

整数与浮点混合除法被视为类型不兼容,抛出 InvalidCastException。

设计目标

这些规则优先保证:

  • 属性表中的值类型不会因为运算隐式改变。
  • 非数学类型不会因为底层存储形式被误当作数字。
  • 整数运算不会静默溢出。
  • 可能截断的转换必须显式失败。
  • 除法语义由调用方明确选择,避免在 DynamicValue 层隐藏整数除法策略。
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.15 125 7/1/2026
0.0.14 114 6/30/2026
0.0.13 115 6/25/2026
0.0.10 110 6/5/2026
0.0.9 117 6/4/2026
0.0.8 112 6/4/2026
0.0.7 111 6/4/2026
0.0.5 106 6/3/2026
0.0.4 96 6/2/2026
0.0.3 115 6/2/2026
0.0.2 112 6/2/2026
0.0.1 120 5/31/2026