Skip to content

Commit

Permalink
Require opt-in attribute to reset combinator
Browse files Browse the repository at this point in the history
  • Loading branch information
glopesdev committed Oct 15, 2022
1 parent c745be3 commit 1dc51f5
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Bonsai.Core/Expressions/CombinatorBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ void UpdateArgumentRange()

static Delegate BuildResetCombinator(Type combinatorType)
{
if (!combinatorType.IsDefined(typeof(ResetCombinatorAttribute)))
{
return null;
}

List<PropertyInfo> resetProperties = null;
var combinatorProperties = combinatorType.GetProperties();
for (int i = 0; i < combinatorProperties.Length; i++)
Expand Down
13 changes: 13 additions & 0 deletions Bonsai.Core/ResetCombinatorAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;

namespace Bonsai
{
/// <summary>
/// Instructs the build process to reset non-serializable public properties
/// marked with <see cref="System.Xml.Serialization.XmlIgnoreAttribute"/>.
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public sealed class ResetCombinatorAttribute : Attribute
{
}
}
1 change: 1 addition & 0 deletions Bonsai.Vision/Drawing/AddImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Bonsai.Vision.Drawing
/// <summary>
/// Represents an operator that specifies drawing the specified image to the canvas.
/// </summary>
[ResetCombinator]
[Description("Draws the specified image to the canvas.")]
public class AddImage : CanvasElement
{
Expand Down
1 change: 1 addition & 0 deletions Bonsai.Vision/Drawing/DrawContours.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Bonsai.Vision.Drawing
/// Represents an operator that specifies drawing contour outlines or filled
/// interiors in an image.
/// </summary>
[ResetCombinator]
[Description("Draws contour outlines or filled interiors in an image.")]
public class DrawContours : CanvasElement
{
Expand Down
1 change: 1 addition & 0 deletions Bonsai.Vision/Drawing/FillPolygon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Bonsai.Vision.Drawing
/// Represents an operator that specifies filling an area bounded by several
/// polygonal contours.
/// </summary>
[ResetCombinator]
[Description("Fills an area bounded by several polygonal contours.")]
public class FillPolygon : CanvasElement
{
Expand Down
1 change: 1 addition & 0 deletions Bonsai.Vision/Drawing/LineChart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Bonsai.Vision.Drawing
/// Represents an operator that specifies drawing a line chart by plotting
/// each row of a matrix as a polyline element.
/// </summary>
[ResetCombinator]
[Description("Draws a line chart by plotting each row of a matrix as a polyline element.")]
public class LineChart : CanvasElement
{
Expand Down
1 change: 1 addition & 0 deletions Bonsai.Vision/Drawing/Path.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Bonsai.Vision.Drawing
/// <summary>
/// Represents an operator that specifies drawing a path from an array of vertices.
/// </summary>
[ResetCombinator]
[Description("Draws a path from an array of vertices.")]
public class Path : CanvasElement
{
Expand Down
1 change: 1 addition & 0 deletions Bonsai.Vision/Drawing/PolyLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Bonsai.Vision.Drawing
/// <summary>
/// Represents an operator that specifies drawing one or more polygonal curves.
/// </summary>
[ResetCombinator]
[Description("Draws one or more polygonal curves.")]
public class PolyLine : CanvasElement
{
Expand Down

0 comments on commit 1dc51f5

Please sign in to comment.