{"id":311073,"date":"2020-10-06T15:01:44","date_gmt":"2020-10-06T15:01:44","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=311073"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=311073","title":{"rendered":"Nullable Reference \u043d\u0435 \u0437\u0430\u0449\u0438\u0449\u0430\u044e\u0442, \u0438 \u0432\u043e\u0442 \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/pvs-studio\/blog\/522228\/\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/30d\/8bd\/3c1\/30d8bd3c1040f014485bc84ba2d169c6.png\" alt=\"image1.png\"><\/div>\n<p>  \u0425\u043e\u0442\u0435\u043b\u0438 \u043b\u0438 \u0432\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0443\u043b\u0435\u0432\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a? \u0415\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Nullable Reference \u0442\u0438\u043f\u043e\u0432 \u2014 \u044d\u0442\u043e \u043d\u0435 \u0432\u0430\u0448 \u0432\u044b\u0431\u043e\u0440. \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u0447\u0435\u043c\u0443? \u041e\u0431 \u044d\u0442\u043e\u043c \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0438 \u043f\u043e\u0439\u0434\u0451\u0442 \u0440\u0435\u0447\u044c.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041c\u044b \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u043b\u0438, \u0438 \u044d\u0442\u043e \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c. \u041e\u043a\u043e\u043b\u043e \u0433\u043e\u0434\u0430 \u043d\u0430\u0437\u0430\u0434 \u043c\u043e\u0438 \u043a\u043e\u043b\u043b\u0435\u0433\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 <a href=\"https:\/\/viva64.com\/ru\/b\/0631\/\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u043b\u0438 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 Nullable Reference \u0442\u0438\u043f\u043e\u0432 \u043d\u0435 \u0437\u0430\u0449\u0438\u0442\u0438\u0442 \u043e\u0442 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0439 \u043d\u0443\u043b\u0435\u0432\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a. \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 \u043d\u0430\u0448\u0438\u0445 \u0441\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u044b\u043b\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0430\u0445 Roslyn.<\/p>\n<h2>Nullable Reference \u0442\u0438\u043f\u044b<\/h2>\n<p>  \u0421\u0430\u043c\u0430 \u0437\u0430\u0434\u0443\u043c\u043a\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <i>Nullable Reference<\/i> (\u0434\u0430\u043b\u0435\u0435 \u2014 NR) \u0442\u0438\u043f\u044b \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0443\u043b\u0435\u0432\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a, \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430 \u0438 \u043f\u043e \u0441\u0435\u0439 \u0434\u0435\u043d\u044c. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0436\u0435 \u0437\u0430\u0449\u0438\u0442\u044b \u043e\u0442 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0439 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u043a\u0440\u0430\u0439\u043d\u0435 \u043d\u0435\u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0439. \u041f\u043e \u0437\u0430\u0434\u0443\u043c\u043a\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <i>null<\/i> \u043c\u043e\u0433\u0443\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0442\u0438\u043f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043c\u0435\u0447\u0435\u043d \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c &quot;?&quot;. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0442\u0438\u043f\u0430 <i>string?<\/i> \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u043d\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f <i>null<\/i>, \u0442\u0438\u043f\u0430 <i>string<\/i> \u2014 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442. <\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0430\u043c \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c <i>null<\/i> \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 <i>non-nullable reference <\/i>(\u0434\u0430\u043b\u0435\u0435 \u2014 NNR) \u0442\u0438\u043f\u043e\u0432, \u0432\u0435\u0434\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043e\u043d\u0438 \u043d\u0435 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 IL \u043a\u043e\u0434\u0430. \u0417\u0430 \u0434\u0430\u043d\u043d\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u043d\u043d\u043e\u0435 \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u0440\u0435\u0435 \u043d\u043e\u0441\u0438\u0442 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440. \u0412\u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<pre><code class=\"cpp\">#nullable enable object? nullable = null; object nonNullable = nullable; var deref = nonNullable.ToString();<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0442\u0438\u043f \u0443 <i>nonNullable<\/i> \u0443\u043a\u0430\u0437\u0430\u043d \u043a\u0430\u043a NNR, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u044b \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0442\u0443\u0434\u0430 <i>null<\/i>. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 &quot;Converting null literal or possible null value to non-nullable type.&quot;. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0430\u0433\u0440\u0435\u0441\u0441\u0438\u0438:<\/p>\n<pre><code class=\"cpp\">#nullable enable object? nullable = null; object nonNullable = nullable!; \/\/ &lt;= var deref = nonNullable.ToString();<\/code><\/pre>\n<p>  \u041e\u0434\u0438\u043d \u0432\u043e\u0441\u043a\u043b\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u043d\u0430\u043a, \u0438 \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439. \u0415\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0438\u0437 \u0432\u0430\u0441 \u0433\u0443\u0440\u043c\u0430\u043d, \u0442\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0435\u0449\u0435 \u0442\u0430\u043a\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442:<\/p>\n<pre><code class=\"cpp\">#nullable enable object nonNullable = null!; var deref = nonNullable.ToString();<\/code><\/pre>\n<p>  \u041d\u0443 \u0438 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043c\u0435\u0440. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0432\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0438\u0448\u0435\u043c:<\/p>\n<pre><code class=\"cpp\">namespace NullableTests {     public static class Tester     {         public static string RetNull() =&gt; null;     } }<\/code><\/pre>\n<p>  \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u043f\u0438\u0448\u0435\u043c:<\/p>\n<pre><code class=\"cpp\">#nullable enable   namespace ConsoleApp1 {     class Program     {         static void Main(string[] args)         {             string? nullOrNotNull = NullableTests.Tester.RetNull();             System.Console.WriteLine(nullOrNotNull.Length);         }     } }<\/code><\/pre>\n<p>  \u041d\u0430\u0432\u043e\u0434\u0438\u043c \u043d\u0430 <i>nullOrNotNull<\/i> \u0438 \u0432\u0438\u0434\u0438\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e65\/240\/f59\/e65240f5971a4a68c98c1bacf0ba79a1.png\" alt=\"image2.png\"><\/div>\n<p>  \u041d\u0430\u043c \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442, \u0447\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0430 \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c <i>null<\/i>. \u041e\u0434\u043d\u0430\u043a\u043e \u043c\u044b-\u0442\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e \u043e\u043d\u0430 \u0437\u0434\u0435\u0441\u044c \u043a\u0430\u043a \u0440\u0430\u0437 \u0431\u0443\u0434\u0435\u0442 <i>null<\/i>. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/150\/484\/882\/1504848827b6d5a243562d910da2f201.png\" alt=\"image3.png\"><\/div>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0441\u0438\u043d\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u0446\u0435\u043b\u044c \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u043e\u0435 \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0432\u0430\u043c \u0437\u0430\u0449\u0438\u0442\u0443 \u043e\u0442 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438. \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043b\u0438, \u0447\u0442\u043e \u0441\u0438\u043d\u0442\u0435\u0442\u0438\u043a\u0430 \u2014 \u044d\u0442\u043e \u0441\u043a\u0443\u0447\u043d\u043e, \u0438 \u0433\u0434\u0435 \u0432\u043e\u043e\u0431\u0449\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u0442\u043e \u043f\u043e\u043f\u0440\u043e\u0448\u0443 \u043d\u0435 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442\u044c\u0441\u044f, \u0434\u0430\u043b\u0435\u0435 \u0432\u0441\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442.<\/p>\n<p>  \u0423 NR \u0442\u0438\u043f\u043e\u0432 \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u2013 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u043e\u043d\u0438 \u0438\u043b\u0438 \u043d\u0435\u0442. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041e\u0434\u0438\u043d \u0440\u0430\u0437\u043c\u0435\u0447\u0435\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430, \u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u2014 \u043d\u0435\u0442. \u0417\u0430\u0439\u0434\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 NR \u0442\u0438\u043f\u0430\u043c\u0438, \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c, \u0447\u0442\u043e \u0440\u0430\u0437 \u0440\u0430\u0437\u043c\u0435\u0447\u0435\u043d \u043e\u0434\u0438\u043d, \u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0447\u0435\u043d\u044b \u0432\u0441\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0442\u0430\u043a. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0430 \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u043b\u0438 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u043b\u0438 \u0444\u0430\u0439\u043b\u0435 nullable context. \u0418\u043d\u0430\u0447\u0435 \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e \u043e\u0448\u0438\u0431\u043a\u0435 \u0440\u0435\u0448\u0438\u0442\u044c, \u0447\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 reference \u0442\u0438\u043f \u2013 \u044d\u0442\u043e NNR.<\/p>\n<h2>\u041a\u0430\u043a \u0431\u044b\u043b\u0438 \u043d\u0430\u0439\u0434\u0435\u043d\u044b \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 <\/h2>\n<p>  \u041f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043d\u043e\u0432\u044b\u0445 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a \u0432 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0435 PVS-Studio \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0438\u0445 \u043d\u0430 \u043d\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432. \u042d\u0442\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0430\u0441\u043f\u0435\u043a\u0442\u0430\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: <\/p>\n<ul>\n<li>\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c &quot;\u0432\u0436\u0438\u0432\u0443\u044e&quot; \u043d\u0430 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439;<\/li>\n<li>\u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0447\u0430\u0441\u0442\u0438 \u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439;<\/li>\n<li>\u043d\u0430\u0439\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0432 \u043a\u043e\u0434\u0435, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c;<\/li>\n<li>\u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/li>\n<\/ul>\n<p>  \u041e\u0434\u043d\u0430 \u0438\u0437 \u043d\u043e\u0432\u044b\u0445 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a V3156 \u2014 \u043d\u0430\u0448\u043b\u0430 \u043c\u0435\u0441\u0442\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u0437-\u0437\u0430 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e <i>null<\/i> \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u0424\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0430 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0437\u0432\u0443\u0447\u0438\u0442 \u0442\u0430\u043a: &quot;The argument of the method is not expected to be null&quot;. \u0421\u0443\u0442\u044c \u0435\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u043c\u0435\u0442\u043e\u0434, \u043d\u0435 \u043e\u0436\u0438\u0434\u0430\u044e\u0449\u0438\u0439 <i>null<\/i>, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <i>null<\/i>. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0434\u0430\u043d\u043d\u043e\u043c \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/www.viva64.com\/ru\/w\/v3156\/\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<h2>\u041f\u0440\u0443\u0444\u044b \u0442\u0443\u0442<\/h2>\n<p>  \u0412\u043e\u0442 \u043c\u044b \u0438 \u0434\u043e\u0448\u043b\u0438 \u0434\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u0422\u0443\u0442 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0434\u0430 \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 Roslyn, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0430 \u0432\u044b\u0434\u0430\u043b\u0430 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0438\u0445 \u0441\u043c\u044b\u0441\u043b \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043b\u0438\u0431\u043e \u0432 NNR \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f <i>null<\/i>, \u043b\u0438\u0431\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f NR \u0442\u0438\u043f\u0430. \u0412\u0441\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0440 1<\/b><\/p>\n<pre><code class=\"cpp\">private static Dictionary&lt;object, SourceLabelSymbol&gt; BuildLabelsByValue(ImmutableArray&lt;LabelSymbol&gt; labels) {   ....   object key;   var constantValue = label.SwitchCaseLabelConstant;   if ((object)constantValue != null &amp;&amp; !constantValue.IsBad)   {     key = KeyForConstant(constantValue);   }   else if (labelKind == SyntaxKind.DefaultSwitchLabel)   {     key = s_defaultKey;   }   else   {     key = label.IdentifierNodeOrToken.AsNode();   }    if (!map.ContainsKey(key))                \/\/ &lt;=   {     map.Add(key, label);   }    .... }<\/code><\/pre>\n<p>  V3156 The first argument of the &#39;ContainsKey&#39; method is not expected to be null. Potential null value: key. SwitchBinder.cs 121<\/p>\n<p>  \u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0433\u043b\u0430\u0441\u0438\u0442, \u0447\u0442\u043e <i>key<\/i> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c <i>null<\/i>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0433\u0434\u0435 \u044d\u0442\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u0435\u0442\u043e\u0434 <i>KeyForConstant<\/i>:<\/p>\n<pre><code class=\"cpp\">protected static object KeyForConstant(ConstantValue constantValue) {   Debug.Assert((object)constantValue != null);   return constantValue.IsNull ? s_nullKey : constantValue.Value; } private static readonly object s_nullKey = new object();<\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a <i>s_nullKey <\/i>\u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442c\u044f <i>null<\/i>, \u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <i>constantValue.Value<\/i>:<\/p>\n<pre><code class=\"cpp\">public object? Value {   get   {     switch (this.Discriminator)     {       case ConstantValueTypeDiscriminator.Bad: return null;  \/\/ &lt;=       case ConstantValueTypeDiscriminator.Null: return null; \/\/ &lt;=       case ConstantValueTypeDiscriminator.SByte: return Boxes.Box(SByteValue);       case ConstantValueTypeDiscriminator.Byte: return Boxes.Box(ByteValue);       case ConstantValueTypeDiscriminator.Int16: return Boxes.Box(Int16Value);       ....       default: throw ExceptionUtilities.UnexpectedValue(this.Discriminator);     }   } }<\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043d\u0443\u043b\u0435\u0432\u044b\u0445 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u0430, \u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043d\u0435 \u0437\u0430\u0439\u0434\u0435\u043c \u043d\u0438 \u0432 \u043e\u0434\u0438\u043d <i>case<\/i> \u0441 \u043d\u0438\u043c\u0438. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0437-\u0437\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a <i>IsBad <\/i>\u0438<i> IsNull<\/i>. \u041e\u0434\u043d\u0430\u043a\u043e \u044f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0430\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430. \u041e\u043d \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f NR \u0442\u0438\u043f\u043e\u043c, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u0435\u0442\u043e\u0434 <i>KeyForConstant<\/i> \u0443\u0436\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 NNR \u0442\u0438\u043f. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0435\u0440\u043d\u0443\u0442\u044c <i>null<\/i> \u043c\u0435\u0442\u043e\u0434 <i>KeyForConstant<\/i> \u043c\u043e\u0436\u0435\u0442.<\/p>\n<p>  \u0414\u0440\u0443\u0433\u043e\u0439 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c <i>null,<\/i> \u2014 \u043c\u0435\u0442\u043e\u0434 <i>AsNode<\/i>:<\/p>\n<pre><code class=\"cpp\">public SyntaxNode? AsNode() {   if (_token != null)   {     return null;   }    return _nodeOrParent; }<\/code><\/pre>\n<p>  \u0421\u043d\u043e\u0432\u0430 \u043f\u0440\u043e\u0448\u0443 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f \u043c\u0435\u0442\u043e\u0434\u0430 \u2014 \u044d\u0442\u043e NR \u0442\u0438\u043f. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c, \u0447\u0442\u043e \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f <i>null<\/i>, \u0442\u043e \u044d\u0442\u043e \u043d\u0438 \u043d\u0430 \u0447\u0442\u043e \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442. \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0440\u0443\u0433\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437 NR \u0432 NNR:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/cb7\/7fc\/3a9\/cb77fc3a9b527b6a3ccbb3d9e923e1e5.png\" alt=\"image4.png\"><\/div>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0440 2<\/b><\/p>\n<pre><code class=\"cpp\">private SyntaxNode CopyAnnotationsTo(SyntaxNode sourceTreeRoot,                                       SyntaxNode destTreeRoot) {     var nodeOrTokenMap = new Dictionary&lt;SyntaxNodeOrToken,                                        SyntaxNodeOrToken&gt;();   ....   if (sourceTreeNodeOrTokenEnumerator.Current.IsNode)   {     var oldNode = destTreeNodeOrTokenEnumerator.Current.AsNode();     var newNode = sourceTreeNodeOrTokenEnumerator.Current.AsNode()                                        .CopyAnnotationsTo(oldNode);              nodeOrTokenMap.Add(oldNode, newNode); \/\/ &lt;=   }   .... }<\/code><\/pre>\n<p>  V3156 The first argument of the &#39;Add&#39; method is not expected to be null. Potential null value: oldNode. SyntaxAnnotationTests.cs 439<\/p>\n<p>  \u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <i>AsNode<\/i>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u044b\u043b\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432\u044b\u0448\u0435. \u0422\u043e\u043b\u044c\u043a\u043e \u0432 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 <i>oldNode <\/i>\u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c NR \u0442\u0438\u043f. \u0412 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u0432\u044b\u0448\u0435 <i>key <\/i>\u0438\u043c\u0435\u043b\u0430 NNR \u0442\u0438\u043f.<\/p>\n<p>  \u041a\u0441\u0442\u0430\u0442\u0438, \u043d\u0435 \u043c\u043e\u0433\u0443 \u043d\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435\u043c. \u041a\u0430\u043a \u044f \u0443\u0436\u0435 \u043e\u043f\u0438\u0441\u0430\u043b \u0432\u044b\u0448\u0435, \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u0435 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445. \u041f\u0440\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0431\u044b\u043b \u0437\u0430\u043c\u0435\u0447\u0435\u043d \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442. \u041e\u043a\u043e\u043b\u043e 70% \u0432\u0441\u0435\u0445 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439 \u0431\u044b\u043b\u043e \u0432\u044b\u0434\u0430\u043d\u043e \u043d\u0430 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430 <i>Dictionary<\/i>. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0438\u0445 \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u0448\u043b\u0430\u0441\u044c \u043d\u0430 \u043c\u0435\u0442\u043e\u0434 <i>TryGetValue<\/i>. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u043e\u0434\u0441\u043e\u0437\u043d\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u044b \u043d\u0435 \u043e\u0436\u0438\u0434\u0430\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043e\u0442 \u043c\u0435\u0442\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043b\u043e\u0432\u043e <i>try<\/i>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0441\u0432\u043e\u0439 \u043a\u043e\u0434 \u043d\u0430 \u044d\u0442\u043e\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u0432\u0434\u0440\u0443\u0433 \u0443 \u0432\u0430\u0441 \u043d\u0430\u0439\u0434\u0435\u0442\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0440 3<\/b><\/p>\n<pre><code class=\"cpp\">private static SymbolTreeInfo TryReadSymbolTreeInfo(     ObjectReader reader,     Checksum checksum,     Func&lt;string, ImmutableArray&lt;Node&gt;,      Task&lt;SpellChecker&gt;&gt; createSpellCheckerTask) {   ....   var typeName = reader.ReadString();   var valueCount = reader.ReadInt32();    for (var j = 0; j &lt; valueCount; j++)   {     var containerName = reader.ReadString();     var name = reader.ReadString();      simpleTypeNameToExtensionMethodMap.Add(typeName, \/\/ &lt;=                             new ExtensionMethodInfo(containerName, name));    }   .... }<\/code><\/pre>\n<p>  V3156 The first argument of the &#39;Add&#39; method is passed as an argument to the &#39;TryGetValue&#39; method and is not expected to be null. Potential null value: typeName. SymbolTreeInfo_Serialization.cs 255<\/p>\n<p>  \u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 <i>typeName<\/i>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0431\u0435\u0434\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c <i>null<\/i>. \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 <i>ReadString<\/i>:<\/p>\n<pre><code class=\"cpp\">public string ReadString() =&gt; ReadStringValue();<\/code><\/pre>\n<p>  \u0422\u0430\u043a, \u0441\u043c\u043e\u0442\u0440\u0438\u043c <i>ReadStringValue<\/i>:<\/p>\n<pre><code class=\"cpp\"> private string ReadStringValue() {   var kind = (EncodingKind)_reader.ReadByte();   return kind == EncodingKind.Null ? null : ReadStringValue(kind); }<\/code><\/pre>\n<p>  \u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0432\u0435\u0436\u0438\u043c \u043f\u0430\u043c\u044f\u0442\u044c, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0432, \u043a\u0443\u0434\u0430 \u0436\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u043b\u0430\u0441\u044c \u043d\u0430\u0448\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f:<\/p>\n<pre><code class=\"cpp\">simpleTypeNameToExtensionMethodMap.Add(typeName, \/\/ &lt;=                               new ExtensionMethodInfo(containerName,                                                       name));<\/code><\/pre>\n<p>  \u0414\u0443\u043c\u0430\u044e, \u0441\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u0439\u0442\u0438 \u0432\u043d\u0443\u0442\u0440\u044c \u043c\u0435\u0442\u043e\u0434\u0430 <i>Add<\/i>:<\/p>\n<pre><code class=\"cpp\">public bool Add(K k, V v) {   ValueSet updated;    if (_dictionary.TryGetValue(k, out ValueSet set)) \/\/ &lt;=   {     ....   }   .... }<\/code><\/pre>\n<p>  \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432 \u043c\u0435\u0442\u043e\u0434 <i>Add<\/i> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c <i>null<\/i>, \u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <i>ArgumentNullException<\/i>. <\/p>\n<p>  \u041a\u0441\u0442\u0430\u0442\u0438, \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432 <i>Visual Studio<\/i> \u043d\u0430\u0432\u0435\u0441\u0442\u0438 \u043a\u0443\u0440\u0441\u043e\u0440 \u043d\u0430 <i>typeName<\/i>, \u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0442\u0438\u043f \u0443 \u043d\u0435\u0433\u043e <i>string?<\/i>:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/32a\/99b\/3d3\/32a99b3d3637912932c4618ffdac614f.png\" alt=\"image5.png\"><\/div>\n<p>  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f \u043c\u0435\u0442\u043e\u0434\u0430 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e <i>string<\/i>:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/310\/495\/2b8\/3104952b85859f80edc50aa929d1dd7b.png\" alt=\"image6.png\"><\/div>\n<p>  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0435\u0441\u043b\u0438 \u0434\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e NNR \u0442\u0438\u043f\u0430 \u0438 \u0435\u0439 \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c <i>typeName<\/i>, \u0442\u043e \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u043e.<\/p>\n<h2>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0443\u0440\u043e\u043d\u0438\u0442\u044c Roslyn<\/h2>\n<p>  \u041d\u0435 \u0437\u043b\u043e\u0431\u044b \u0434\u043b\u044f, \u0430 \u0437\u0430\u0431\u0430\u0432\u044b \u0440\u0430\u0434\u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/588\/bf2\/b67\/588bf2b675f69b9e7146cf5f3f6c57d8.png\" alt=\"image7.png\"><\/div>\n<p>  <b>\u0422\u0435\u0441\u0442 1<\/b><\/p>\n<p>  \u0412\u043e\u0437\u044c\u043c\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434 \u043d\u043e\u043c\u0435\u0440\u043e\u043c 3:<\/p>\n<pre><code class=\"cpp\">private static SymbolTreeInfo TryReadSymbolTreeInfo(     ObjectReader reader,     Checksum checksum,     Func&lt;string, ImmutableArray&lt;Node&gt;,      Task&lt;SpellChecker&gt;&gt; createSpellCheckerTask) {   ....   var typeName = reader.ReadString();   var valueCount = reader.ReadInt32();    for (var j = 0; j &lt; valueCount; j++)   {     var containerName = reader.ReadString();     var name = reader.ReadString();      simpleTypeNameToExtensionMethodMap.Add(typeName, \/\/ &lt;=                             new ExtensionMethodInfo(containerName, name));    }   .... }<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0435\u0433\u043e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438, \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <i>TryReadSymbolTreeInfo<\/i>, \u043d\u043e \u043e\u043d \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <i>private<\/i>. \u0425\u043e\u0440\u043e\u0448\u043e, \u0447\u0442\u043e \u0432 <a href=\"https:\/\/github.com\/dotnet\/roslyn\/blob\/18ede13943b0bfae1b44ef078b2f3923159bcd32\/src\/Workspaces\/Core\/Portable\/FindSymbols\/SymbolTree\/SymbolTreeInfo_Serialization.cs\">\u043a\u043b\u0430\u0441\u0441\u0435<\/a> \u0441 \u043d\u0438\u043c \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <i>ReadSymbolTreeInfo_ForTestingPurposesOnly<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <i>internal<\/i>:<\/p>\n<pre><code class=\"cpp\">internal static SymbolTreeInfo ReadSymbolTreeInfo_ForTestingPurposesOnly(     ObjectReader reader,      Checksum checksum) {   return TryReadSymbolTreeInfo(reader, checksum,           (names, nodes) =&gt; Task.FromResult(             new SpellChecker(checksum,                               nodes.Select(n =&gt; new StringSlice(names,                                                                 n.NameSpan))))); }<\/code><\/pre>\n<p>  \u041e\u0447\u0435\u043d\u044c \u043f\u0440\u0438\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043d\u0430\u043c \u043f\u0440\u044f\u043c \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <i>TryReadSymbolTreeInfo<\/i>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u044f\u0434\u044b\u0448\u043a\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0432\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">public class CheckNNR {   public static void Start()   {     using var stream = new MemoryStream();     using var writer = new BinaryWriter(stream);     writer.Write((byte)170);     writer.Write((byte)9);     writer.Write((byte)0);     writer.Write(0);     writer.Write(0);     writer.Write(1);     writer.Write((byte)0);     writer.Write(1);     writer.Write((byte)0);     writer.Write((byte)0);     stream.Position = 0;      using var reader = ObjectReader.TryGetReader(stream);     var checksum = Checksum.Create(&quot;val&quot;);      SymbolTreeInfo.ReadSymbolTreeInfo_ForTestingPurposesOnly(reader, checksum);   } }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c <i>Roslyn<\/i>, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 dll-\u0444\u0430\u0439\u043b\u044b \u0438 \u043f\u0438\u0448\u0435\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">static void Main(string[] args) {   CheckNNR.Start(); }<\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c, \u0434\u043e\u0445\u043e\u0434\u0438\u043c \u0434\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u0438 \u0432\u0438\u0434\u0438\u043c:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/885\/057\/962\/8850579624fcc5b0c3605f39b72d8192.png\" alt=\"image8.png\"><\/div>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0437\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u043c\u0435\u0442\u043e\u0434 <i>Add<\/i> \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/833\/b27\/774\/833b2777413cd75a1f650ad62d542f75.png\" alt=\"image9.png\"><\/div>\n<p>  \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 <i>ReadString<\/i> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 NNR \u0442\u0438\u043f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u0437\u0430\u0434\u0443\u043c\u043a\u0435 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c <i>null<\/i>. \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043b\u0438\u0448\u043d\u0438\u0439 \u0440\u0430\u0437 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b PVS-Studio \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0443\u043b\u0435\u0432\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a.<\/p>\n<p>  <b>\u0422\u0435\u0441\u0442 2<\/b><\/p>\n<p>  \u041d\u0443 \u0438 \u0440\u0430\u0437 \u043c\u044b \u0443\u0436\u0435 \u043d\u0430\u0447\u0430\u043b\u0438 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u0442\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d. \u042d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u044f\u0437\u0430\u043d \u0441 NR \u0442\u0438\u043f\u0430\u043c\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0433\u043e \u043d\u0430\u0448\u043b\u0430 \u0432\u0441\u0435 \u0442\u0430 \u0436\u0435 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0430 V3156, \u0438 \u043c\u043d\u0435 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043e \u043d\u0435\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c. \u0412\u043e\u0442 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">public SyntaxToken GenerateUniqueName(SemanticModel semanticModel,                                        SyntaxNode location,                                        SyntaxNode containerOpt,                                        string baseName,                                        CancellationToken cancellationToken) {   return GenerateUniqueName(semanticModel,                              location,                              containerOpt,                              baseName,                              filter: null,                              usedNames: null,    \/\/ &lt;=                             cancellationToken); }<\/code><\/pre>\n<p>  V3156 The sixth argument of the &#39;GenerateUniqueName&#39; method is passed as an argument to the &#39;Concat&#39; method and is not expected to be null. Potential null value: null. AbstractSemanticFactsService.cs 24<\/p>\n<p>  \u0421\u043a\u0430\u0436\u0443 \u0447\u0435\u0441\u0442\u043d\u043e: \u0434\u0435\u043b\u0430\u044f \u0434\u0430\u043d\u043d\u0443\u044e \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0443, \u044f \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u043e\u0436\u0438\u0434\u0430\u043b \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439 \u043d\u0430 \u043f\u0440\u044f\u043c\u043e\u0439 <i>null<\/i>. \u0412\u0435\u0434\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c <i>null<\/i> \u0432 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435. \u0425\u043e\u0442\u044f \u044f \u0432\u0438\u0434\u0435\u043b \u043c\u0435\u0441\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u043e\u0431\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441 \u043a\u043b\u0430\u0441\u0441\u043e\u043c <i>Expression<\/i>), \u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c. <\/p>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0431\u044b\u043b \u043e\u0447\u0435\u043d\u044c \u0437\u0430\u0438\u043d\u0442\u0440\u0438\u0433\u043e\u0432\u0430\u043d, \u043a\u043e\u0433\u0434\u0430 \u0443\u0432\u0438\u0434\u0435\u043b \u0434\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0436\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <i>GenerateUniqueName<\/i>.<\/p>\n<pre><code class=\"cpp\">public SyntaxToken GenerateUniqueName(SemanticModel semanticModel,                                       SyntaxNode location,                                        SyntaxNode containerOpt,                                       string baseName,                                        Func&lt;ISymbol, bool&gt; filter,                                       IEnumerable&lt;string&gt; usedNames,                                        CancellationToken cancellationToken) {   var container = containerOpt ?? location                        .AncestorsAndSelf()                        .FirstOrDefault(a =&gt; SyntaxFacts.IsExecutableBlock(a)                                           || SyntaxFacts.IsMethodBody(a));    var candidates = GetCollidableSymbols(semanticModel,                                          location,                                          container,                                          cancellationToken);    var filteredCandidates = filter != null ? candidates.Where(filter)                                            : candidates;    return GenerateUniqueName(baseName,                              filteredCandidates.Select(s =&gt; s.Name)                                               .Concat(usedNames));     \/\/ &lt;= }<\/code><\/pre>\n<p>  \u041c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0432\u044b\u0445\u043e\u0434, \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f, \u0434\u0430 \u0438 <i>goto<\/i> \u043d\u0435\u0442. \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c <i>usedNames<\/i> \u0432 \u043c\u0435\u0442\u043e\u0434 <i>Concat<\/i> \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <i>ArgumentNullException<\/i>. <\/p>\n<p>  \u041d\u043e \u044d\u0442\u043e \u0432\u0441\u0435 \u0441\u043b\u043e\u0432\u0430, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043e\u0442\u043a\u0443\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434. \u0421\u0430\u043c \u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <i><a href=\"https:\/\/github.com\/dotnet\/roslyn\/blob\/18ede13943b0bfae1b44ef078b2f3923159bcd32\/src\/Workspaces\/SharedUtilitiesAndExtensions\/Workspace\/Core\/LanguageServices\/SemanticsFactsService\/AbstractSemanticFactsService.cs\">AbstractSemanticFactsService<\/a><\/i>. \u041a\u043b\u0430\u0441\u0441 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u043a\u043b\u0430\u0441\u0441 <i><a href=\"https:\/\/github.com\/dotnet\/roslyn\/blob\/18ede13943b0bfae1b44ef078b2f3923159bcd32\/src\/Workspaces\/SharedUtilitiesAndExtensions\/Workspace\/CSharp\/LanguageServices\/CSharpSemanticFactsService.cs\">CSharpSemanticFactsService<\/a><\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442 \u043d\u0435\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f. \u0412 \u0444\u0430\u0439\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0432\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <i>GenerateUniqueName<\/i>. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">public class DropRoslyn {   private const string ProgramText =      @&quot;using System;     using System.Collections.Generic;     using System.Text     namespace HelloWorld     {       class Program       {         static void Main(string[] args)         {           Console.WriteLine(&quot;&quot;Hello, World!&quot;&quot;);         }       }     }&quot;;      public void Drop()   {     var tree = CSharpSyntaxTree.ParseText(ProgramText);     var instance = CSharpSemanticFactsService.Instance;     var compilation = CSharpCompilation                       .Create(&quot;Hello World&quot;)                       .AddReferences(MetadataReference                                      .CreateFromFile(typeof(string)                                                      .Assembly                                                      .Location))                       .AddSyntaxTrees(tree);          var semanticModel = compilation.GetSemanticModel(tree);     var syntaxNode1 = tree.GetRoot();     var syntaxNode2 = tree.GetRoot();          var baseName = &quot;baseName&quot;;     var cancellationToken = new CancellationToken();          instance.GenerateUniqueName(semanticModel,                                  syntaxNode1,                                  syntaxNode2,                                  baseName,                                  cancellationToken);   } }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c Roslyn, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 dll-\u0444\u0430\u0439\u043b\u044b \u0438 \u043f\u0438\u0448\u0435\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">class Program {   static void Main(string[] args)   {     DropRoslyn dropRoslyn = new DropRoslyn();     dropRoslyn.Drop();   } }<\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/83a\/e19\/741\/83ae1974191c1732dcbd2ed44c7f2cc8.png\" alt=\"image10.png\"><\/div>\n<p>  <\/p>\n<h2>\u042d\u0442\u043e \u0432\u0432\u043e\u0434\u0438\u0442 \u0432 \u0437\u0430\u0431\u043b\u0443\u0436\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u043c\u044b \u0441\u043e\u0433\u043b\u0430\u0448\u0430\u0435\u043c\u0441\u044f \u0441 nullable \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0435\u0439. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u0438\u0434\u0438\u043c NR \u0442\u0438\u043f, \u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u0432 \u043d\u0435\u043c \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 <i>null<\/i>. \u041e\u0434\u043d\u0430\u043a\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0430\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c.<\/p>\n<p>  <b>\u0421\u043b\u0443\u0447\u0430\u0439 1<\/b><\/p>\n<pre><code class=\"cpp\">internal override IEnumerable&lt;SyntaxToken&gt;? TryGetActiveTokens(SyntaxNode node) {   ....   var bodyTokens = SyntaxUtilities                    .TryGetMethodDeclarationBody(node)                    ?.DescendantTokens();    if (node.IsKind(SyntaxKind.ConstructorDeclaration,                    out ConstructorDeclarationSyntax? ctor))   {     if (ctor.Initializer != null)     {       bodyTokens = ctor.Initializer                        .DescendantTokens()                        .Concat(bodyTokens); \/\/ &lt;=     }   }   return bodyTokens; }<\/code><\/pre>\n<p>  V3156 The first argument of the &#39;Concat&#39; method is not expected to be null. Potential null value: bodyTokens. CSharpEditAndContinueAnalyzer.cs 219<\/p>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043f\u043e\u0447\u0435\u043c\u0443 <i>bodyTokens<\/i> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c <i>null<\/i> \u0438 \u0432\u0438\u0434\u0438\u043c <i>null-\u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439<\/i> \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440:<\/p>\n<pre><code class=\"cpp\">var bodyTokens = SyntaxUtilities                  .TryGetMethodDeclarationBody(node)                  ?.DescendantTokens();              \/\/ &lt;=<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0437\u0430\u0439\u0442\u0438 \u0432 \u043c\u0435\u0442\u043e\u0434 <i>TryGetMethodDeclarationBody<\/i>, \u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c <i>null<\/i>. \u041e\u0434\u043d\u0430\u043a\u043e \u043e\u043d \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e <a href=\"https:\/\/github.com\/dotnet\/roslyn\/blob\/18ede13943b0bfae1b44ef078b2f3923159bcd32\/src\/Features\/CSharp\/Portable\/EditAndContinue\/SyntaxUtilities.cs\">\u0441\u0441\u044b\u043b\u043a\u0443<\/a> \u043d\u0430 \u043d\u0435\u0433\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u043b\u0438\u0447\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u043e\u043c. \u0421 <i>bodyTokens<\/i> \u0432\u0441\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043d\u043e \u044f \u0445\u043e\u0447\u0443 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <i>ctor<\/i>:<\/p>\n<pre><code class=\"cpp\">if (node.IsKind(SyntaxKind.ConstructorDeclaration,                  out ConstructorDeclarationSyntax? ctor))<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0435\u0433\u043e \u0442\u0438\u043f \u0437\u0430\u0434\u0430\u043d \u043a\u0430\u043a NR. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0442\u0440\u043e\u0447\u043a\u043e\u0439 \u043d\u0438\u0436\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435:<\/p>\n<pre><code class=\"cpp\">if (ctor.Initializer != null)<\/code><\/pre>\n<p>  \u0422\u0430\u043a\u043e\u0435 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0430\u0441\u0442\u043e\u0440\u0430\u0436\u0438\u0432\u0430\u0435\u0442. \u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u0432\u044b \u0441\u043a\u0430\u0436\u0435\u0442\u0435, \u0447\u0442\u043e, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0435\u0441\u043b\u0438 <i>IsKind<\/i> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <i>true<\/i>, \u0442\u043e <i>ctor<\/i> \u0442\u043e\u0447\u043d\u043e \u043d\u0435 \u0440\u0430\u0432\u0435\u043d <i>null<\/i>. \u0422\u0430\u043a \u043e\u043d\u043e \u0438 \u0435\u0441\u0442\u044c:<\/p>\n<pre><code class=\"cpp\">public static bool IsKind&lt;TNode&gt;(     [NotNullWhen(returnValue: true)] this SyntaxNode? node, \/\/ &lt;=     SyntaxKind kind,     [NotNullWhen(returnValue: true)] out TNode? result)     \/\/ &lt;=     where TNode : SyntaxNode  {   if (node.IsKind(kind))   {     result = (TNode)node;     return true;   }    result = null;   return false; }<\/code><\/pre>\n<p>  \u0422\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442, \u043f\u0440\u0438 \u043a\u0430\u043a\u043e\u043c \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0432\u043d\u044b <i>null<\/i>. \u0412 \u044d\u0442\u043e\u043c \u0436\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u043d\u0430 \u043b\u043e\u0433\u0438\u043a\u0443 \u043c\u0435\u0442\u043e\u0434\u0430 <i>IsKind<\/i>. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0442\u0438\u043f \u0443 <i>ctor<\/i> \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c NNR. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u044d\u0442\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e <i>ctor <\/i>\u0432\u043d\u0443\u0442\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 <i>null<\/i>. \u041e\u0434\u043d\u0430\u043a\u043e, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u043d\u0430\u043c, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u0439\u0442\u0438 \u0432 \u043c\u0435\u0442\u043e\u0434 <i>IsKind<\/i> \u0438 \u0442\u0430\u043c \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442. \u0418\u043d\u0430\u0447\u0435 \u0436\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 NR \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0431\u0435\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 <i>null<\/i>. \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">if (node.IsKind(SyntaxKind.ConstructorDeclaration,                  out ConstructorDeclarationSyntax? ctor)) {     if (ctor!.Initializer != null) \/\/ &lt;=     {       ....     } }<\/code><\/pre>\n<p>  <b>\u0421\u043b\u0443\u0447\u0430\u0439 2<\/b><\/p>\n<pre><code class=\"cpp\">public TextSpan GetReferenceEditSpan(InlineRenameLocation location,                                       string triggerText,                                       CancellationToken cancellationToken) {   var searchName = this.RenameSymbol.Name;   if (_isRenamingAttributePrefix)   {     searchName = GetWithoutAttributeSuffix(this.RenameSymbol.Name);   }    var index = triggerText.LastIndexOf(searchName,            \/\/ &lt;=                                       StringComparison.Ordinal);   .... }<\/code><\/pre>\n<p>  V3156 The first argument of the &#39;LastIndexOf&#39; method is not expected to be null. Potential null value: searchName. AbstractEditorInlineRenameService.SymbolRenameInfo.cs 126<\/p>\n<p>  \u041d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <i>searchName<\/i>. <i>null<\/i> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0430\u043d \u0432 \u043d\u0435\u0451 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 <i>GetWithoutAttributeSuffix<\/i>, \u043d\u043e \u043d\u0435 \u0432\u0441\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0436\u0435 \u0432 \u043d\u0435\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442:<\/p>\n<pre><code class=\"cpp\">private string GetWithoutAttributeSuffix(string value)     =&gt; value.GetWithoutAttributeSuffix(isCaseSensitive:                 _document.GetRequiredLanguageService&lt;ISyntaxFactsService&gt;()                          .IsCaseSensitive)!;<\/code><\/pre>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u0439\u0434\u0435\u043c \u0433\u043b\u0443\u0431\u0436\u0435:<\/p>\n<pre><code class=\"cpp\">internal static string? GetWithoutAttributeSuffix(             this string name,             bool isCaseSensitive) {   return TryGetWithoutAttributeSuffix(name, isCaseSensitive, out var result)           ? result : null; }<\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u043c\u0435\u0442\u043e\u0434 <i>TryGetWithoutAttributeSuffix<\/i>, \u0432\u0435\u0440\u043d\u0435\u0442 \u043b\u0438\u0431\u043e <i>result<\/i>, \u043b\u0438\u0431\u043e <i>null<\/i>. \u0414\u0430 \u0438 \u043c\u0435\u0442\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 NR \u0442\u0438\u043f. \u041e\u0434\u043d\u0430\u043a\u043e, \u0432\u0435\u0440\u043d\u0443\u0432\u0448\u0438\u0441\u044c \u043d\u0430 \u0448\u0430\u0433 \u043d\u0430\u0437\u0430\u0434, \u043c\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u0442\u0438\u043f \u043c\u0435\u0442\u043e\u0434\u0430 \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u0441\u044f \u043d\u0430 NNR. \u041f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u044d\u0442\u043e \u0438\u0437-\u0437\u0430 \u043f\u0440\u0438\u0442\u0430\u0438\u0432\u0448\u0435\u0433\u043e\u0441\u044f \u0437\u043d\u0430\u043a\u0430 &quot;!&quot;:<\/p>\n<pre><code class=\"cpp\">_document.GetRequiredLanguageService&lt;ISyntaxFactsService&gt;()          .IsCaseSensitive)!; \/\/ &lt;=<\/code><\/pre>\n<p>  \u041a\u0441\u0442\u0430\u0442\u0438, \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u0432 Visual Studio \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5f2\/47a\/aad\/5f247aaad74e18a31497b6c54f898365.png\" alt=\"image11.png\"><\/div>\n<p>  \u041f\u043e\u0441\u0442\u0430\u0432\u0438\u0432 \u0435\u0433\u043e, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442 \u043d\u0430\u043c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0432\u0435\u0440\u043d\u0435\u0442 <i>null<\/i>. \u0425\u043e\u0442\u044f, \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438 \u0437\u0430\u0439\u0434\u044f \u0432 \u043c\u0435\u0442\u043e\u0434 <i>TryGetWithoutAttributeSuffix<\/i>, \u043b\u0438\u0447\u043d\u043e \u044f \u043d\u0435 \u043c\u043e\u0433\u0443 \u0431\u044b\u0442\u044c \u0432 \u044d\u0442\u043e\u043c \u0443\u0432\u0435\u0440\u0435\u043d:<\/p>\n<pre><code class=\"cpp\">internal static bool TryGetWithoutAttributeSuffix(             this string name,             bool isCaseSensitive,             [NotNullWhen(returnValue: true)] out string? result) {   if (name.HasAttributeSuffix(isCaseSensitive))   {     result = name.Substring(0, name.Length - AttributeSuffix.Length);     return true;   }    result = null;   return false; }<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0412\u044b\u0432\u043e\u0434<\/h2>\n<p>  \u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u044f \u0445\u043e\u0447\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0441 \u043e\u0442 \u043b\u0438\u0448\u043d\u0438\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u043d\u0430 <i>null,<\/i> \u2013 \u044d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u0430\u044f \u0438\u0434\u0435\u044f. \u041e\u0434\u043d\u0430\u043a\u043e NR \u0442\u0438\u043f\u044b \u043d\u043e\u0441\u044f\u0442 \u0441\u043a\u043e\u0440\u0435\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440, \u0432\u0435\u0434\u044c \u043d\u0430\u043c \u043d\u0438\u043a\u0442\u043e \u0441\u0442\u0440\u043e\u0433\u043e \u043d\u0435 \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c <i>null<\/i> \u0432 NNR \u0442\u0438\u043f. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 PVS-Studio. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <a href=\"https:\/\/www.viva64.com\/ru\/w\/v3080\/\">V3080<\/a> \u0438\u043b\u0438 <a href=\"https:\/\/www.viva64.com\/ru\/w\/v3156\/\">V3156<\/a>.<\/p>\n<p>  \u0412\u0441\u0435\u0433\u043e \u0432\u0430\u043c \u0434\u043e\u0431\u0440\u043e\u0433\u043e \u0438 \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p>\n<p>  <a href=\"https:\/\/habr.com\/en\/company\/pvs-studio\/blog\/522226\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/d5\/1k\/2e\/d51k2edrgxyrg5voswox_46pg3o.png\"><\/div>\n<p><\/a><br \/>  \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u0441 \u0430\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u0439 \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u0435\u0439, \u0442\u043e \u043f\u0440\u043e\u0448\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434: Nikolay Mironov. <a href=\"https:\/\/habr.com\/en\/company\/pvs-studio\/blog\/522226\/\">Nullable Reference will not protect you, and here is the proof<\/a>.<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/pvs-studio\/blog\/522228\/\"> https:\/\/habr.com\/ru\/company\/pvs-studio\/blog\/522228\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/pvs-studio\/blog\/522228\/\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/30d\/8bd\/3c1\/30d8bd3c1040f014485bc84ba2d169c6.png\" alt=\"image1.png\"><\/div>\n<p>  \u0425\u043e\u0442\u0435\u043b\u0438 \u043b\u0438 \u0432\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0443\u043b\u0435\u0432\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a? \u0415\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Nullable Reference \u0442\u0438\u043f\u043e\u0432 \u2014 \u044d\u0442\u043e \u043d\u0435 \u0432\u0430\u0448 \u0432\u044b\u0431\u043e\u0440. \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u0447\u0435\u043c\u0443? \u041e\u0431 \u044d\u0442\u043e\u043c \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0438 \u043f\u043e\u0439\u0434\u0451\u0442 \u0440\u0435\u0447\u044c.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-311073","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/311073","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=311073"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/311073\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=311073"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=311073"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=311073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}