emipa606 / GradualRomance

A relationship mod for Rimworld
MIT License
1 stars 1 forks source link

C# Style guide to reference? #9

Closed thailyn closed 9 months ago

thailyn commented 9 months ago

I noticed you tweaked some of the aspects of the code style (indenting, line length, etc.) after accepting some of my pull requests. [For this repo and for your other repos,] do you have an established code style that could be referenced? (I'm just using I think the Visual Studio defaults, and 120-character line width.)

I haven't really done anything with it myself, but I know you could create an EditorConfig that could be exported to a file and checked into source control, and -- if I understand correctly how it works -- would override Visual Studio's default code style settings. I don't now if it would be a lot of work to tailor one to your preferences, but maybe it would save time in the long run. 🤷

emipa606 commented 9 months ago

I dont really have a specific style defined, I use ReSharper with most of its formatting options turned on. https://www.jetbrains.com/resharper/features/code_formatting.html Not sure how well that translates into your settings.

thailyn commented 9 months ago

Ah, I used ReSharper a long, long time ago at a previous job. If it were free, I'd still be using it. I've been considering subscribing to the JetBrains dotUltimate package, which includes ReSharper, but... haven't bitten the bullet yet.

It looks like you can create an EditorConfig from ReSharper based on its settings. (Honestly, I didn't read that whole page, but it looks pretty comprehensive.) If you wanted to either add an EditorConfig created that way to the repo, or share it here or something so I could test it before officially adding it (or never adding it and keeping it informal), I'd be down.

emipa606 commented 9 months ago

They have a good free setup for Open Source devs, that is how I got a license for it: https://www.jetbrains.com/community/opensource

Generated a config (excluding the ReSharper specific options), see if it works for you:

[*.{appxmanifest,axml,build,c,c++,cc,cginc,compute,config,cp,cpp,cppm,cshtml,csproj,cu,cuh,cxx,dbml,discomap,dtd,fx,fxh,h,hh,hlsl,hlsli,hlslinc,hpp,htm,html,hxx,inc,inl,ino,ipp,ixx,jsproj,lsproj,mpp,mq4,mq5,mqh,njsproj,nuspec,proj,props,razor,resw,resx,StyleCop,targets,tasks,tpp,usf,ush,vbproj,xml,xsd}]
indent_style = tab
indent_size = tab
tab_width = 4

[*.{asax,ascx,aspx,axaml,cs,master,paml,skin,vb,xaml,xamlx,xoml}]
indent_style = space
indent_size = 4
tab_width = 4

[*]

# Microsoft .NET properties
csharp_new_line_before_members_in_object_initializers = false
csharp_preferred_modifier_order = public, private, protected, internal, file, new, static, abstract, virtual, sealed, readonly, override, extern, unsafe, volatile, async, required:suggestion
csharp_style_prefer_utf8_string_literals = true:suggestion
csharp_style_var_elsewhere = true:suggestion
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
dotnet_naming_rule.private_constants_rule.import_to_resharper = as_predefined
dotnet_naming_rule.private_constants_rule.severity = suggestion
dotnet_naming_rule.private_constants_rule.style = upper_camel_case_style
dotnet_naming_rule.private_constants_rule.symbols = private_constants_symbols
dotnet_naming_rule.private_instance_fields_rule.import_to_resharper = as_predefined
dotnet_naming_rule.private_instance_fields_rule.severity = suggestion
dotnet_naming_rule.private_instance_fields_rule.style = lower_camel_case_style
dotnet_naming_rule.private_instance_fields_rule.symbols = private_instance_fields_symbols
dotnet_naming_rule.private_static_fields_rule.import_to_resharper = as_predefined
dotnet_naming_rule.private_static_fields_rule.severity = suggestion
dotnet_naming_rule.private_static_fields_rule.style = lower_camel_case_style
dotnet_naming_rule.private_static_fields_rule.symbols = private_static_fields_symbols
dotnet_naming_rule.private_static_readonly_rule.import_to_resharper = as_predefined
dotnet_naming_rule.private_static_readonly_rule.severity = suggestion
dotnet_naming_rule.private_static_readonly_rule.style = upper_camel_case_style
dotnet_naming_rule.private_static_readonly_rule.symbols = private_static_readonly_symbols
dotnet_naming_style.lower_camel_case_style.capitalization = camel_case
dotnet_naming_style.upper_camel_case_style.capitalization = pascal_case
dotnet_naming_symbols.private_constants_symbols.applicable_accessibilities = private
dotnet_naming_symbols.private_constants_symbols.applicable_kinds = field
dotnet_naming_symbols.private_constants_symbols.required_modifiers = const
dotnet_naming_symbols.private_instance_fields_symbols.applicable_accessibilities = private
dotnet_naming_symbols.private_instance_fields_symbols.applicable_kinds = field
dotnet_naming_symbols.private_static_fields_symbols.applicable_accessibilities = private
dotnet_naming_symbols.private_static_fields_symbols.applicable_kinds = field
dotnet_naming_symbols.private_static_fields_symbols.required_modifiers = static
dotnet_naming_symbols.private_static_readonly_symbols.applicable_accessibilities = private
dotnet_naming_symbols.private_static_readonly_symbols.applicable_kinds = field
dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers = static,readonly
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:none
dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:none
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion
dotnet_style_qualification_for_event = false:warning
dotnet_style_qualification_for_field = false:warning
dotnet_style_qualification_for_method = false:warning
dotnet_style_qualification_for_property = false:warning
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion