Fix build warnings related to non-nullable types
authorGleb Balykov <g.balykov@samsung.com>
Thu, 13 Oct 2022 11:19:14 +0000 (14:19 +0300)
committerGleb Balykov/Platform Lab /SRR/Staff Engineer/Samsung Electronics <g.balykov@samsung.com>
Tue, 29 Nov 2022 16:50:13 +0000 (19:50 +0300)
tools/generrmsg/GenErrMsg.cs

index ec63ceb3510e00d810f6a8d938e907853ce3b357..f32958830bb220ba7fbde0e551c6761d74b5d824 100644 (file)
@@ -8,8 +8,15 @@ namespace generrmsg
 {\r
     public class ErrMsg\r
     {\r
+// nullable reference types are avaiable only since c# 8 (.net core 3.0), by default nullability is enabled only since .net 6\r
+// for builds with .NET 6+ sdks NET6_0_OR_GREATER is set, this "if" condition doesn't need any futher updates for new sdks in future\r
+#if NET6_0_OR_GREATER\r
+        public string? SymName { get; set; }\r
+        public string? Message { get; set; }\r
+#else\r
         public string SymName { get; set; }\r
         public string Message { get; set; }\r
+#endif\r
         public int Code { get; set;}\r
     }\r
 \r
@@ -26,6 +33,18 @@ namespace generrmsg
                 return;\r
             }\r
             Dictionary<string, ErrMsg> errmsgs = new Dictionary<string, ErrMsg>();\r
+\r
+// nullable reference types are avaiable only since c# 8 (.net core 3.0), by default nullability is enabled only since .net 6\r
+// for builds with .NET 6+ sdks NET6_0_OR_GREATER is set, this "if" condition doesn't need any futher updates for new sdks in future\r
+#if NET6_0_OR_GREATER\r
+            string? hresult = null;\r
+            string? msg=null;\r
+            string? symname = null;\r
+            string? comment = null;\r
+            string? sourcefilename = args[0];\r
+            string? outputfilename = null;\r
+            string? hfilename = null;\r
+#else\r
             string hresult = null;\r
             string msg=null;\r
             string symname = null;\r
@@ -33,6 +52,7 @@ namespace generrmsg
             string sourcefilename = args[0];\r
             string outputfilename = null;\r
             string hfilename = null;\r
+#endif\r
             int FaciltyUrt=0x13; // The source of the error code is .NET CLR.\r
             int SeveritySuccess=0;\r
             int SeverityError=1;\r
@@ -98,7 +118,7 @@ namespace generrmsg
                              } else {\r
                                    errmsg.Message = "\"" + symname + "\"";\r
                              }\r
-                             if (!errmsgs.ContainsKey(hresult)) {\r
+                             if (hresult != null && !errmsgs.ContainsKey(hresult)) {\r
                                  errmsgs.Add(key: hresult, value: errmsg);\r
                              }\r
                          }\r