IXLLEGACYIXL 2 年之前
父节点
当前提交
8fac57bbd8

+ 51 - 0
en/diagnostics/STRDIAG000.md

@@ -0,0 +1,51 @@
+# Diagnostics Warning STRDIAG000
+
+There is an Attribute Contradiction on '{0}' Member. \[DataMemberIgnore] Attribute on a \[DataMember] is not supported.
+Except if it has also \[DataMemberUpdatable] Attribute.
+
+## Explanation
+
+Adding [DataMember] and [DataMemberIgnore] to the same member is not supported.
+This would be a contradiction.
+It would mean the Serializer should serialize the member and ignore it at the same time.
+The DataMemberUpdatable Attribute makes the combination valid again as it negates the DataMemberIgnore for the binary Serializer.
+
+## Example
+
+The following example generates STRDIAG000 on each property:
+
+```csharp
+// STRDIAG000.cs
+using Stride.Core;
+
+public class STRDIAG000
+{
+    [DataMember]
+    [DataMemberIgnore]
+    public int Value { get; set;}
+
+    [DataMember]
+    [DataMemberIgnore]
+    public int Value;
+}
+```
+
+There is a special case if the Stride.Updater.DataMemberUpdatableAttribute is applied.
+This Attribute negates the Stride.Core.DataMemberIgnoreAttribute for the binary Serializer, so it becomes valid again.
+
+```csharp
+using Stride.Core;
+
+public class STRDIAG000
+{
+    [DataMember]
+    [DataMemberIgnore]
+    [DataMemberUpdatable]
+    public int Value { get; set;}
+}
+```
+
+## Solution
+
+To resolve the warning, pick either the Stride.Core.DataMemberAttribute or the Stride.Core.DataMemberIgnoreAttribute.
+If the YamlSerializer and the Editor should ignore the member but the binary Serializer not, then add the Stride.Core.DataMemberIgnoreAttribute.

+ 37 - 0
en/diagnostics/STRDIAG001.md

@@ -0,0 +1,37 @@
+# Diagnostics Warning STRDIAG001
+
+The \[DataContract] is not valid for the type '{0}'. Expected is a public/internal Accessor.
+
+## Explanation
+
+The DataContract Attribute can only be applied to public/internal type.
+Any Access that is lower than that will cause STRDIAG001 on the target type.
+
+## Example: private inner class
+
+The following example generates STRDIAG001:
+
+```csharp
+// STRDIAG000.cs
+using Stride.Core;
+
+public class STRDIAG001
+{
+    [DataContract]
+    private class InnerClass{ }
+}
+```
+
+## Example: file scoped class
+
+```csharp
+using Stride.Core;
+[DataContract]
+file class STRDIAG001
+{
+}
+```
+
+## Solution
+
+To resolve the warning, increase the accessibility of the type to pulic/internal or remove the DataContractAttribute.

+ 32 - 0
en/diagnostics/STRDIAG002.md

@@ -0,0 +1,32 @@
+# Diagnostics Warning STRDIAG002
+
+The 'DataMemberMode.Content' is not valid for the member '{0}'.
+Only mutable reference types are supported for 'DataMemberMode.Content' Mode members.
+
+## 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.
+Immutable types in this context are primitive types and string.
+
+## Example
+
+The following example generates STRDIAG003 on each property:
+
+```csharp
+// STRDIAG000.cs
+using Stride.Core;
+
+public class STRDIAG000
+{
+    [DataMember(DataMemberMode.Content)]
+    public int Value { get; set;}
+
+    [DataMember(DataMemberMode.Content)]
+    public string Value;
+}
+```
+
+## Solution
+
+To resolve the warning, pick either a reference type for the member or use DataMemberMode.Assign for ImmutableTypes.

+ 0 - 0
en/diagnostics/strd003.md → en/diagnostics/STRDIAG003.md


+ 0 - 0
en/diagnostics/strd007.md → en/diagnostics/STRDIAG004.md


+ 1 - 1
en/diagnostics/strd004.md → en/diagnostics/STRDIAG005.md

@@ -1,6 +1,6 @@
 # Diagnostics Warning STRD004
 
-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.
+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.
 
 ## Example
 

+ 2 - 1
en/diagnostics/index.md

@@ -3,4 +3,5 @@
 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.
 
 > [!WARNING]
-> Note that diagnostic feature is experimental and may not work as expected.
+> Note that diagnostic feature is experimental and may not work as expected.
+> Warnings may contain solutions that don't work yet.

+ 0 - 54
en/diagnostics/strd001.md

@@ -1,54 +0,0 @@
-# Diagnostics Warning STRD001
-
-An Array must have a public/internal getter for Serialization.
-
-## Example
-
-The following example generates STRD001:
-
-```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:
-        {
-        }
-    }
-}
-
-```
-
-Another common example where this error is generated is as follows:
-
-```csharp
-public static class Class1
-{
-    public static string Method1()
-    {
-        string x = "a";
-        switch (x)
-        {
-            case "a":
-                return "a";
-                break;          // CS0162
-        }
-        return "";
-    }
-}
-```
-
-The `break` statement cannot be reached because it occurs after the `return` statement. The `return` statement ends the enclosing `case` branch.
-
-## See also
-
-- [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/)

+ 0 - 54
en/diagnostics/strd002.md

@@ -1,54 +0,0 @@
-# Diagnostics Warning STRD002
-
-A collection must have a public/internal getter for Serialization.
-
-## Example
-
-The following example generates STRD001:
-
-```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:
-        {
-        }
-    }
-}
-
-```
-
-Another common example where this error is generated is as follows:
-
-```csharp
-public static class Class1
-{
-    public static string Method1()
-    {
-        string x = "a";
-        switch (x)
-        {
-            case "a":
-                return "a";
-                break;          // CS0162
-        }
-        return "";
-    }
-}
-```
-
-The `break` statement cannot be reached because it occurs after the `return` statement. The `return` statement ends the enclosing `case` branch.
-
-## See also
-
-- [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/)

+ 10 - 5
en/diagnostics/toc.md

@@ -1,7 +1,12 @@
 # [Diagnostics](index.md)
 
-# [STRD001](strd001.md)
-# [STRD002](strd002.md)
-# [STRD003](strd003.md)
-# [STRD004](strd004.md)
-# [STRD007](strd007.md)
+# [STRD000](STRDIAG000.md)
+# [STRD001](STRDIAG001.md)
+# [STRD002](STRDIAG002.md)
+# [STRD003](STRDIAG003.md)
+# [STRD004](STRDIAG004.md)
+# [STRD005](STRDIAG005.md)
+# [STRD006](STRDIAG006.md)
+# [STRD007](STRDIAG007.md)
+# [STRD008](STRDIAG008.md)
+# [STRD009](STRDIAG009.md)