Skip to content

Conversation

yileicn
Copy link
Collaborator

@yileicn yileicn commented Oct 10, 2025

PR Type

Enhancement


Description

  • Add alignment support for button template messages

  • Create alignment enumeration with positioning constants


Diagram Walkthrough

flowchart LR
  A["AlignmentEnum"] --> B["ButtonTemplateMessage"]
  A --> C["Alignment Constants"]
  B --> D["JSON Serialization"]
Loading

File Walkthrough

Relevant files
Enhancement
AlignmentEnum.cs
Create alignment enumeration constants                                     

src/Infrastructure/BotSharp.Abstraction/Messaging/Enums/AlignmentEnum.cs

  • Create new static class with alignment constants
  • Define six positioning options (top/bottom + left/center/right)
+20/-0   
ButtonTemplateMessage.cs
Add alignment property to button template                               

src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ButtonTemplateMessage.cs

  • Add Alignment property with JSON serialization
  • Set default alignment to TopLeft
+3/-0     

Copy link

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Use a proper enum for type safety

Replace the AlignmentEnum static class with a proper enum to enforce type
safety. Then, update the Alignment property in ButtonTemplateMessage to use this
new enum and add a JsonStringEnumConverter for correct serialization.

src/Infrastructure/BotSharp.Abstraction/Messaging/Enums/AlignmentEnum.cs [9-19]

-public static class  AlignmentEnum
+public enum AlignmentEnum
 {
-    public const string TopLeft = "topLeft";
-    public const string BottomLeft = "bottomLeft";
-
-    public const string TopRight = "topRight";        
-    public const string BottomRight = "bottomRight";
-
-    public const string TopCenter = "topCenter";
-    public const string BottomCenter = "bottomCenter";
+    TopLeft,
+    BottomLeft,
+    TopRight,
+    BottomRight,
+    TopCenter,
+    BottomCenter
 }
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies a code quality issue by recommending the use of a proper enum instead of a static class with string constants, which enhances type safety and maintainability.

Medium
  • More

@JackJiang1234
Copy link
Contributor

reviewed

@yileicn yileicn merged commit 669639d into SciSharp:master Oct 10, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants