-
Notifications
You must be signed in to change notification settings - Fork 0
Add SmithyModelExtensions and KebabCase method #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| using System; | ||
| using System.Linq; | ||
|
|
||
| namespace Smithy.Model | ||
| { | ||
| /// <summary> | ||
| /// Extension methods for SmithyModel to simplify shape access | ||
| /// </summary> | ||
| public static class SmithyModelExtensions | ||
| { | ||
| /// <summary> | ||
| /// Get a shape by its ID from the model | ||
| /// </summary> | ||
| /// <typeparam name="T">The type of shape to retrieve</typeparam> | ||
| /// <param name="model">The Smithy model</param> | ||
| /// <param name="shapeId">The ID of the shape to retrieve</param> | ||
| /// <returns>The shape with the specified ID, or null if not found</returns> | ||
| public static T GetShape<T>(this SmithyModel model, string shapeId) where T : Shape | ||
| { | ||
| if (model == null || string.IsNullOrEmpty(shapeId)) | ||
| return null; | ||
|
Check warning on line 21 in Smithy.Model/SmithyModelExtensions.cs
|
||
|
|
||
| return model.Shapes.OfType<T>().FirstOrDefault(s => s.Id == shapeId); | ||
|
Check warning on line 23 in Smithy.Model/SmithyModelExtensions.cs
|
||
| } | ||
|
|
||
| /// <summary> | ||
| /// Get a shape by its ID from the model | ||
| /// </summary> | ||
| /// <param name="model">The Smithy model</param> | ||
| /// <param name="shapeId">The ID of the shape to retrieve</param> | ||
| /// <returns>The shape with the specified ID, or null if not found</returns> | ||
| public static Shape GetShape(this SmithyModel model, string shapeId) | ||
| { | ||
| if (model == null || string.IsNullOrEmpty(shapeId)) | ||
| return null; | ||
|
Check warning on line 35 in Smithy.Model/SmithyModelExtensions.cs
|
||
|
|
||
| return model.Shapes.FirstOrDefault(s => s.Id == shapeId); | ||
|
Check warning on line 37 in Smithy.Model/SmithyModelExtensions.cs
|
||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider enhancing the KebabCase method to better handle sequences of uppercase letters (e.g., abbreviations like 'XMLHttpRequest') to ensure consistent and expected output, or document the current behavior clearly.