From 0e2982284b2a0b23e33550df28f09174e21a7ef3 Mon Sep 17 00:00:00 2001 From: Bullet Date: Sat, 11 Nov 2023 09:40:31 +0100 Subject: [PATCH 1/4] docs: add C# language identifier to fenced code blocks for readability --- README.md | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index cb43b1d..068b2f3 100644 --- a/README.md +++ b/README.md @@ -401,7 +401,7 @@ Within each of these groups order by access: * internal * protected * private -``` +```csharp namespace ProjectName { /// @@ -466,7 +466,7 @@ Use a namespace to ensure your scoping of classes/enum/interface/etc won't confl Simply, any function that has an access modifier of Public should have its summary filled out. -``` +```csharp /// /// Fire a gun /// @@ -486,7 +486,7 @@ To create Foldout Groups there are 2 options in Unity. * The first is to define a `[Serializable] public Class` inside the main class however this can have a performance impact. This allows the use of the same variable name to be shared. * The second option is to use the Foldout Group Attribute available with [Odin Inspector](https://odininspector.com/). -``` +```csharp [[Serializable](https://docs.unity3d.com/ScriptReference/Serializable.html)] public struct PlayerStats { @@ -513,14 +513,14 @@ End comment text with a period. Insert one space between the comment delimiter (//) and the comment text, as shown in the following example. The // (two slashes) style of comment tags should be used in most situations. Where ever possible, place comments above the code instead of beside it. Here are some examples: -``` +```csharp // Sample comment above a variable. private int _myInt = 5; ``` #### Regions The `#region` directive enables you to collapse and hide sections of code in C# files. The ability to hide code selectively makes your files more manageable and easier to read. -``` +```csharp #region "This is the code to be collapsed" Private components As System.ComponentModel.Container #endregion @@ -590,7 +590,7 @@ Local variables should use camelCase. ###### Implicitly Typed Local Variables Use implicit typing for local variables when the type of the variable is obvious from the right side of the assignment, or when the precise type is not important. -``` +```csharp var var1 = "This is clearly a string."; var var2 = 27; var var3 = Convert.ToInt32(Console.ReadLine()); @@ -600,7 +600,7 @@ for (var i = 0; i < bountyHunterFleets.Length; ++i) {}; Do not use var when the type is not apparent from the right side of the assignment. Example -``` +```csharp int var4 = ExampleClass.ResultSoFar(); ``` @@ -612,7 +612,7 @@ Unless it is known that a variable should only be accessed within the class it i ##### Do _Not_ use Hungarian notation Do _not_ use Hungarian notation or any other type identification in identifiers -``` +```csharp // Correct int counter; string name; @@ -659,7 +659,7 @@ Example: When defining a weapon, do **not** use `isReloading` and `isEquipping` Enums use PascalCase and use singular names for enums and their values. Exception: bit field enums should be plural. Enums can be placed outside the class space to provide global access. Example: -``` +```csharp public enum WeaponType { Knife, @@ -685,7 +685,10 @@ Example: Use `Targets`, `Hats`, and `EnemyPlayers`, not `TargetList`, `HatArray` ##### Interfaces Interfaces are led with a capital `I` then followed with PascalCase. -Example: ```public interface ICanEat { }``` +Example: +```csharp +public interface ICanEat { } +``` ### 3.4 Functions, Events, and Event Dispatchers From c73cabcc0a63007c10ed05c31ccbb14bc4266f89 Mon Sep 17 00:00:00 2001 From: Bullet Date: Sat, 11 Nov 2023 09:41:48 +0100 Subject: [PATCH 2/4] docs: replace regions example code with actual C# code Provided example was probably written in VB. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 068b2f3..f494b19 100644 --- a/README.md +++ b/README.md @@ -522,7 +522,7 @@ The // (two slashes) style of comment tags should be used in most situations. Wh The `#region` directive enables you to collapse and hide sections of code in C# files. The ability to hide code selectively makes your files more manageable and easier to read. ```csharp #region "This is the code to be collapsed" - Private components As System.ComponentModel.Container + private System.ComponentModel.IContainer components; #endregion ``` From 8c0cf6a1f4ea762b774778339fc93a48cd139882 Mon Sep 17 00:00:00 2001 From: Bullet Date: Sat, 11 Nov 2023 09:43:06 +0100 Subject: [PATCH 3/4] style: fix missing or excessive intendation in code examples --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f494b19..7439ffc 100644 --- a/README.md +++ b/README.md @@ -472,7 +472,7 @@ Simply, any function that has an access modifier of Public should have its summa /// public void Fire() { -// Fire the gun. + // Fire the gun. } ``` @@ -489,9 +489,9 @@ To create Foldout Groups there are 2 options in Unity. ```csharp [[Serializable](https://docs.unity3d.com/ScriptReference/Serializable.html)] public struct PlayerStats - { - public int MovementSpeed; - } +{ + public int MovementSpeed; +} [FoldoutGroup("Interactable")] public int MovementSpeed = 1; @@ -514,8 +514,8 @@ Insert one space between the comment delimiter (//) and the comment text, as sho The // (two slashes) style of comment tags should be used in most situations. Where ever possible, place comments above the code instead of beside it. Here are some examples: ```csharp - // Sample comment above a variable. - private int _myInt = 5; +// Sample comment above a variable. +private int _myInt = 5; ``` #### Regions From 16be627a77b33ce0652fdc0a43a27b631abca64a Mon Sep 17 00:00:00 2001 From: Bullet Date: Sat, 11 Nov 2023 09:51:32 +0100 Subject: [PATCH 4/4] fix: remove Serializable attribute unity docs url from Foldout Groups code example Moved it to #### Serializable section where it belongs as it wasn't a valid md nor C# code. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7439ffc..136247f 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Levels refer to what some people call maps or what Unity calls Scenes. A level c #### Serializable -Variables that are Serializable are shown in the Inspector window in Unity. For more information see Unity's documentation on [Serializable](https://docs.unity3d.com/Manual/script-Serialization.html). +Variables that are Serializable are shown in the Inspector window in Unity. For more information see Unity's documentation on [Serializable](https://docs.unity3d.com/ScriptReference/Serializable.html) and [script serialization](https://docs.unity3d.com/Manual/script-Serialization.html). #### Cases @@ -487,7 +487,7 @@ To create Foldout Groups there are 2 options in Unity. * The second option is to use the Foldout Group Attribute available with [Odin Inspector](https://odininspector.com/). ```csharp -[[Serializable](https://docs.unity3d.com/ScriptReference/Serializable.html)] +[Serializable] public struct PlayerStats { public int MovementSpeed;