fix: publish distinct EM observation semantics

This commit is contained in:
梁薄云
2026-08-07 09:28:55 +08:00
parent 5d1c875584
commit d33257cc46
8 changed files with 313 additions and 30 deletions
@@ -13,6 +13,7 @@ internal static class ContractChecks
CopiesCollectionsAndRejectsNonFiniteNumbers();
StoresOccupancyAsDefensiveCompactBits();
ExposesImmutableSnapshotContracts();
ExposesChartAnnotationContract();
DocumentsPublicSafetyAndLifecycleBoundary();
}
@@ -87,6 +88,36 @@ internal static class ContractChecks
}
}
private static void ExposesChartAnnotationContract()
{
Type chartType = typeof(VisualizationChart);
PropertyInfo annotationsProperty = chartType.GetProperty("Annotations");
Verification.True(annotationsProperty != null, "chart exposes immutable annotations");
Type annotationType = chartType.Assembly.GetType("TrajectoryPlanningVisualization.VisualizationChartAnnotation");
Verification.True(annotationType != null, "chart annotation contract type exists");
var chart = new VisualizationChart("annotation-legacy", "标题", "x (m)", "y (m)",
new[]
{
new VisualizationSeries("s", "轨迹", VisualizationLineStyle.Solid,
new[] { new VisualizationPoint(0d, 0d) })
});
if (annotationsProperty == null)
{
return;
}
object value = annotationsProperty.GetValue(chart);
Verification.True(value is System.Collections.IEnumerable, "chart annotations are enumerable");
int count = 0;
foreach (object annotation in (System.Collections.IEnumerable)value)
{
count++;
}
Verification.Equal(0, count, "legacy chart constructor keeps annotations empty");
AssertNoSetters(chartType);
}
private static void DocumentsPublicSafetyAndLifecycleBoundary()
{
string readmePath = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory,