Conversation
WalkthroughThe pull request enables nullable reference types across ParamConverter implementations by removing Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
Activout.RestClient/ParamConverter/Implementation/DateTimeEpochParamConverter.cs (1)
22-25: Apply coding guidelines: file-scoped namespace and expression-bodied member.Per the coding guidelines, this file should use a file-scoped namespace and the simple ToString method could use an expression-bodied member for conciseness.
Apply this diff to align with coding guidelines:
-namespace Activout.RestClient.ParamConverter.Implementation -{ +namespace Activout.RestClient.ParamConverter.Implementation; + internal static class Extensions { // https://stackoverflow.com/questions/2576/how-do-you-convert-epoch-time-in-c public static long ToUnixTime(this DateTime date) { return (date.ToUniversalTime().Ticks - 621355968000000000) / 10000000; } } public class DateTimeEpochParamConverter : IParamConverter { public bool CanConvert(Type type, ParameterInfo parameterInfo) { return type == typeof(DateTime); } - public string ToString(object? value) - { - return value == null ? "" : ((DateTime)value).ToUnixTime().ToString(); - } + public string ToString(object? value) => + value == null ? "" : ((DateTime)value).ToUnixTime().ToString(); } -}As per coding guidelines.
Activout.RestClient/ParamConverter/Implementation/DateTimeIso8601ParamConverter.cs (1)
13-16: Apply coding guidelines: file-scoped namespace and expression-bodied member.Similar to DateTimeEpochParamConverter, this file should use a file-scoped namespace and the ToString method could use an expression-bodied member.
Apply this diff to align with coding guidelines:
-namespace Activout.RestClient.ParamConverter.Implementation -{ +namespace Activout.RestClient.ParamConverter.Implementation; + public class DateTimeIso8601ParamConverter : IParamConverter { public bool CanConvert(Type type, ParameterInfo parameterInfo) { return type == typeof(DateTime); } - public string ToString(object? value) - { - return value == null ? "" : ((DateTime)value).ToString("o"); - } + public string ToString(object? value) => + value == null ? "" : ((DateTime)value).ToString("o"); } -}As per coding guidelines.
Activout.RestClient/ParamConverter/IParamConverter.cs (1)
9-9: Interface signature update enables nullable reference types correctly.The change from
object valuetoobject? valueappropriately enables nullable reference types across all ParamConverter implementations.Consider using a file-scoped namespace for consistency with coding guidelines and ToStringParamConverter.cs:
-namespace Activout.RestClient.ParamConverter -{ +namespace Activout.RestClient.ParamConverter; + public interface IParamConverter { bool CanConvert(Type type, ParameterInfo parameterInfo); string ToString(object? value); } -}As per coding guidelines.
Activout.RestClient/ParamConverter/Implementation/ToStringParamConverter.cs (1)
8-16: Consider expression-bodied members for consistency.Both methods are simple one-liners that could use expression-bodied syntax per coding guidelines. Additionally, note that this file uses the null-coalescing operator (
??) while DateTimeEpochParamConverter and DateTimeIso8601ParamConverter use ternary operators for null checks—consider standardizing the approach across all converters.Apply this diff to use expression-bodied members:
- public bool CanConvert(Type type, ParameterInfo parameterInfo) - { - return true; - } + public bool CanConvert(Type type, ParameterInfo parameterInfo) => true; - public string ToString(object? value) - { - return value?.ToString() ?? ""; - } + public string ToString(object? value) => value?.ToString() ?? "";As per coding guidelines.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
Activout.RestClient/ParamConverter/IParamConverter.cs(1 hunks)Activout.RestClient/ParamConverter/Implementation/DateTimeEpochParamConverter.cs(1 hunks)Activout.RestClient/ParamConverter/Implementation/DateTimeIso8601ParamConverter.cs(1 hunks)Activout.RestClient/ParamConverter/Implementation/ToStringParamConverter.cs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.cs: Use [] list syntax for collections
Use file-scoped namespaces
Use primary constructors wherever possible
Use records for data transfer objects (DTOs) and immutable data structures
Use var for local variable declarations when possible
Use expression-bodied members for simple methods and properties
Use pattern matching for type checks and deconstruction
Use using statements for resource management
Use async and await for asynchronous programming
Never include "Async" in method names
Only include comments that explain why something is done, not what is done
Files:
Activout.RestClient/ParamConverter/IParamConverter.csActivout.RestClient/ParamConverter/Implementation/DateTimeIso8601ParamConverter.csActivout.RestClient/ParamConverter/Implementation/DateTimeEpochParamConverter.csActivout.RestClient/ParamConverter/Implementation/ToStringParamConverter.cs
🧬 Code graph analysis (4)
Activout.RestClient/ParamConverter/IParamConverter.cs (4)
Activout.RestClient/ParamConverter/Implementation/DateTimeEpochParamConverter.cs (1)
ToString(22-25)Activout.RestClient/ParamConverter/Implementation/DateTimeIso8601ParamConverter.cs (1)
ToString(13-16)Activout.RestClient/ParamConverter/Implementation/ToStringParamConverter.cs (1)
ToString(13-16)Activout.RestClient.Test/ParamConverterTests.cs (1)
ToString(132-135)
Activout.RestClient/ParamConverter/Implementation/DateTimeIso8601ParamConverter.cs (3)
Activout.RestClient/ParamConverter/IParamConverter.cs (1)
ToString(9-9)Activout.RestClient/ParamConverter/Implementation/DateTimeEpochParamConverter.cs (1)
ToString(22-25)Activout.RestClient/ParamConverter/Implementation/ToStringParamConverter.cs (1)
ToString(13-16)
Activout.RestClient/ParamConverter/Implementation/DateTimeEpochParamConverter.cs (4)
Activout.RestClient/ParamConverter/IParamConverter.cs (1)
ToString(9-9)Activout.RestClient/ParamConverter/Implementation/DateTimeIso8601ParamConverter.cs (1)
ToString(13-16)Activout.RestClient/ParamConverter/Implementation/ToStringParamConverter.cs (1)
ToString(13-16)Activout.RestClient.Test/ParamConverterTests.cs (1)
ToString(132-135)
Activout.RestClient/ParamConverter/Implementation/ToStringParamConverter.cs (5)
Activout.RestClient/Implementation/RequestHandler.cs (2)
IParamConverter(120-131)Type(160-167)Activout.RestClient/ParamConverter/Implementation/ParamConverterManager.cs (1)
IParamConverter(19-30)Activout.RestClient/ParamConverter/IParamConverter.cs (2)
CanConvert(8-8)ToString(9-9)Activout.RestClient/ParamConverter/Implementation/DateTimeEpochParamConverter.cs (2)
CanConvert(17-20)ToString(22-25)Activout.RestClient.Test/ParamConverterTests.cs (2)
CanConvert(122-130)ToString(132-135)
Summary by CodeRabbit