IXLLEGACYIXL 2 yıl önce
ebeveyn
işleme
50b5092491

+ 3 - 3
en/diagnostics/STRDIAG002.md

@@ -6,18 +6,18 @@ Only mutable reference types are supported for 'DataMemberMode.Content' Mode mem
 ## Explanation
 
 The Content Mode mutates the object which is currently in the member.
-As this is not possible with the current Serializers used in yaml, only mutable Types are supported for Content Mode.
+As this is not possible with the current Serializers, only mutable Types are supported for Content Mode.
 Immutable types in this context are primitive types and string.
 
 ## Example
 
-The following example generates STRDIAG003 on each property:
+The following example generates STRDIAG002 on each property:
 
 ```csharp
 // STRDIAG000.cs
 using Stride.Core;
 
-public class STRDIAG000
+public class STRDIAG002
 {
     [DataMember(DataMemberMode.Content)]
     public int Value { get; set;}

+ 22 - 44
en/diagnostics/STRDIAG003.md

@@ -1,56 +1,34 @@
-# Diagnostics Warning STRD003
+# Diagnostics Warning STRDIAG003
 
-- A property must have a public/internal getter.
-- A property must be set during instantiation, then no public setter would be valid.
-- Or it must have a public setter else.
+The member '{0}' with \[DataMember] is not accesssible to the serializer. Only public/internal/internal protected visibility is supported, when the \[DataMember] attribute is applied.
 
-## Example
-
-The following example generates STRD001:
+## Explanation
 
-```csharp
-// STRD001.cs
-// compile with: /W:2
-public class Program
-{
-    public static void Main()
-    {
-        goto lab1;
-        {
-            // The following statements cannot be reached:
-            int i = 9;   // STRD001
-            i++;
-        }
-    lab1:
-        {
-        }
-    }
-}
+The Serialization concept in Stride expects public/internal/internal protected visibility of properties.
+Other Accessibility won't be considered for Serialization.
+To count internal/internal protected as visible to the Editor the \[DataMember] Attribute has to be applied, else it's considered as not visible.
 
-```
+## Example
 
-Another common example where this error is generated is as follows:
+The following example generates STRDIAG003 on each property:
 
 ```csharp
-public static class Class1
+// STRDIAG000.cs
+using Stride.Core;
+
+public class STRDIAG003
 {
-    public static string Method1()
-    {
-        string x = "a";
-        switch (x)
-        {
-            case "a":
-                return "a";
-                break;          // CS0162
-        }
-        return "";
-    }
+    [DataMember]
+    private int Value { get; set;}
+
+    [DataMember]
+    protected string Value;
+    
+    [DataMember]
+    private protected string Value;
 }
 ```
 
-The `break` statement cannot be reached because it occurs after the `return` statement. The `return` statement ends the enclosing `case` branch.
-
-## See also
+## Solution
 
-- [C# Compiler Options](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/)
-- [C# Compiler Errors](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/)
+To resolve the warning, increase the Accessibility to public/internal/internal protected of the member or remove the \[DataMember] Attribute.

+ 48 - 36
en/diagnostics/STRDIAG004.md

@@ -1,54 +1,66 @@
-# Diagnostics Warning STRD007
+# Diagnostics Warning STRDIAG004
 
-It's invalid to DataMember a private property. Also its invalid to DataMember a property which has DataMemberIgnore.
+1. The property '{0}' with \[DataMember] does not have a getter which is required for serialization.
+2. The property '{0}' with \[DataMember] does not have an accessible getter which is required for serialization. A public/internal/internal protected getter is expected.
+
+## Explanation
+
+All Serializers need a getter on a property to be able to get the content of the property.
+This is required for all Serializers in Stride.
+Non existent getters will result in error message 1.
+Non visible getters will result in error message 2.
 
 ## Example
 
-The following example generates STRD001:
+The following example generates STRDIAG004 on each property:
 
 ```csharp
-// STRD001.cs
-// compile with: /W:2
-public class Program
+// STRDIAG000.cs
+using Stride.Core;
+
+public class STRDIAG004
 {
-    public static void Main()
-    {
-        goto lab1;
-        {
-            // The following statements cannot be reached:
-            int i = 9;   // STRD001
-            i++;
-        }
-    lab1:
-        {
-        }
-    }
-}
+    // throws Diagnostics message 1
+    [DataMember]
+    public int Value { set;}
+
+    // throws Diagnostics message 2
+    [DataMember]
+    public string Value { private get; set; }
 
+    // throws Diagnostics message 2 
+    [DataMember]
+    public string Value { protected get; set; }
+}
 ```
 
-Another common example where this error is generated is as follows:
+There is an edge case with internal/internal protected, it will count as non visible when the [DataMember] Attribute isn't applied.
+But when the Attribute is applied then the getter counts as visible and therfore is correct.
 
 ```csharp
-public static class Class1
+// STRDIAG000.cs
+using Stride.Core;
+
+public class STRDIAG004
 {
-    public static string Method1()
-    {
-        string x = "a";
-        switch (x)
-        {
-            case "a":
-                return "a";
-                break;          // CS0162
-        }
-        return "";
-    }
+    // will throw STRDIAG004
+    public int Value { internal get; set;}
+
+    // will throw STRDIAG004
+    public int Value { internal protected get; set;}
+
+    // won't throw STRDIAG004
+    [DataMember]
+    public string Value { internal get; set; }
+    
+    // won't throw STRDIAG004
+    [DataMember]
+    public string Value { internal protected get; set; }
 }
 ```
 
-The `break` statement cannot be reached because it occurs after the `return` statement. The `return` statement ends the enclosing `case` branch.
+## Solution
 
-## See also
+To resolve the warning 1, add a getter to the property with a public/internal/internal protected Accessibility or remove the \[DataMember] Attribute.
 
-- [C# Compiler Options](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/)
-- [C# Compiler Errors](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/)
+To resolve the warning 2, increase the Accessibility of the property getter to public/internal/internal protected Accessibility or remove the \[DataMember] Attribute.

+ 47 - 36
en/diagnostics/STRDIAG005.md

@@ -1,54 +1,65 @@
-# Diagnostics Warning STRD004
+# Diagnostics Warning STRDIAG005
 
-For \<see cref="System.Collections.Generic.Dictionary{TKey, TValue}"/> the only valid Keys are primitive Types. All complex types like custom structs, objects are not allowed.
+1. The property '{0}' with \[DataMember] does not have a getter which is required for serialization.
+2. The property '{0}' with \[DataMember] does not have an accessible getter which is required for serialization. A public/internal/internal protected getter is expected.
+
+## Explanation
+
+All Serializers need a getter on a property to be able to get the content of the property.
+This is required for all Serializers in Stride.
+Non existent getters will result in error message 1.
+Non visible getters will result in error message 2.
 
 ## Example
 
-The following example generates STRD001:
+The following example generates STRDIAG005 on each property:
 
 ```csharp
-// STRD001.cs
-// compile with: /W:2
-public class Program
+using Stride.Core;
+
+public class STRDIAG005
 {
-    public static void Main()
-    {
-        goto lab1;
-        {
-            // The following statements cannot be reached:
-            int i = 9;   // STRD001
-            i++;
-        }
-    lab1:
-        {
-        }
-    }
-}
+    // throws Diagnostics message 1
+    [DataMember]
+    public int Value { set;}
+
+    // throws Diagnostics message 2
+    [DataMember]
+    public string Value { private get; set; }
 
+    // throws Diagnostics message 2 
+    [DataMember]
+    public string Value { protected get; set; }
+}
 ```
 
-Another common example where this error is generated is as follows:
+There is an edge case with internal/internal protected, it will count as non visible when the [DataMember] Attribute isn't applied.
+But when the Attribute is applied then the getter counts as visible and therfore is correct.
 
 ```csharp
-public static class Class1
+// STRDIAG000.cs
+using Stride.Core;
+
+public class STRDIAG004
 {
-    public static string Method1()
-    {
-        string x = "a";
-        switch (x)
-        {
-            case "a":
-                return "a";
-                break;          // CS0162
-        }
-        return "";
-    }
+    // will throw STRDIAG004
+    public int Value { internal get; set;}
+
+    // will throw STRDIAG004
+    public int Value { internal protected get; set;}
+
+    // won't throw STRDIAG004
+    [DataMember]
+    public string Value { internal get; set; }
+    
+    // won't throw STRDIAG004
+    [DataMember]
+    public string Value { internal protected get; set; }
 }
 ```
 
-The `break` statement cannot be reached because it occurs after the `return` statement. The `return` statement ends the enclosing `case` branch.
+## Solution
 
-## See also
+To resolve the warning 1, add a getter to the property with a public/internal/internal protected Accessibility or remove the \[DataMember] Attribute.
 
-- [C# Compiler Options](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/)
-- [C# Compiler Errors](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/)
+To resolve the warning 2, increase the Accessibility of the property getter to public/internal/internal protected Accessibility or remove the \[DataMember] Attribute.

+ 2 - 0
en/diagnostics/index.md

@@ -2,6 +2,8 @@
 
 Some C# compiler errors have corresponding topics that explain why the error is generated, and, in some cases, how to fix the error. Use one of the following steps to see whether help is available for a particular error message.
 
+[Rule of Thumb Serialization](https://github.com/stride3d/stride-docs/blob/master/en/manual/scripts/serialization.md#rule-of-thumb)
+
 > [!WARNING]
 > Note that diagnostic feature is experimental and may not work as expected.
 > Warnings may contain solutions that don't work yet.