From 0a930dcab16c990c5a25cd9df95430ff5c347a7f Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Wed, 20 Mar 2024 21:08:59 +0500 Subject: [PATCH] Allow using expression-bodied properties (#280) This change significantly reduces the code space used by properties while maintaining clarity on types. Since only properties are allowed to use expression bodies, it is clear to developers that what they are looking at is a property or not Signed-off-by: Octol1ttle --- .editorconfig | 2 +- src/BuildInfo.cs | 48 ++++++------------------------------------------ 2 files changed, 7 insertions(+), 43 deletions(-) diff --git a/.editorconfig b/.editorconfig index ff9c068..adbec5a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -42,7 +42,7 @@ csharp_space_between_square_brackets = false csharp_style_expression_bodied_accessors = false:warning csharp_style_expression_bodied_constructors = false:warning csharp_style_expression_bodied_methods = false:warning -csharp_style_expression_bodied_properties = false:warning +csharp_style_expression_bodied_properties = true:warning csharp_style_namespace_declarations = file_scoped:warning csharp_style_prefer_utf8_string_literals = true:warning csharp_style_var_elsewhere = true:warning diff --git a/src/BuildInfo.cs b/src/BuildInfo.cs index c704328..369feff 100644 --- a/src/BuildInfo.cs +++ b/src/BuildInfo.cs @@ -2,51 +2,15 @@ public static class BuildInfo { - public static string RepositoryUrl - { - get - { - return ThisAssembly.Git.RepositoryUrl; - } - } + public static string RepositoryUrl => ThisAssembly.Git.RepositoryUrl; - public static string IssuesUrl - { - get - { - return $"{RepositoryUrl}/issues"; - } - } + public static string IssuesUrl => $"{RepositoryUrl}/issues"; - private static string Commit - { - get - { - return ThisAssembly.Git.Commit; - } - } + private static string Commit => ThisAssembly.Git.Commit; - private static string Branch - { - get - { - return ThisAssembly.Git.Branch; - } - } + private static string Branch => ThisAssembly.Git.Branch; - public static bool IsDirty - { - get - { - return ThisAssembly.Git.IsDirty; - } - } + public static bool IsDirty => ThisAssembly.Git.IsDirty; - public static string Version - { - get - { - return IsDirty ? $"{Branch}-{Commit}-dirty" : $"{Branch}-{Commit}"; - } - } + public static string Version => IsDirty ? $"{Branch}-{Commit}-dirty" : $"{Branch}-{Commit}"; }