{"id":324302,"date":"2021-06-03T15:01:01","date_gmt":"2021-06-03T15:01:01","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=324302"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=324302","title":{"rendered":"\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 &#8216;?.&#8217; \u0432 foreach: \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 NullReferenceException, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/9e3\/12d\/f63\/9e312df6325df01e5a3b313cc3b9f349.png\" alt=\"0832_foreach_ConditionalAccess_ru\/image1.png\"><br \/>  \u041b\u044e\u0431\u0438\u0442\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &#8216;?.&#8217;? \u0410 \u043a\u0442\u043e \u0436\u0435 \u043d\u0435 \u043b\u044e\u0431\u0438\u0442? \u042d\u0442\u0438 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 null \u043d\u0440\u0430\u0432\u044f\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u0438\u043c. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &#8216;?.&#8217; \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0438\u043b\u043b\u044e\u0437\u0438\u044e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u0420\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0451\u0442 \u043e \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 \u0446\u0438\u043a\u043b\u0435 foreach.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u041d\u0430\u0447\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u043a\u0438 \u0434\u043b\u044f \u0441\u0430\u043c\u043e\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438. \u0412\u0437\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">void ForeachTest(IEnumerable&lt;String&gt; collection) {   \/\/ #1   foreach (var item in collection.NotNullItems())     Console.WriteLine(item);    \/\/ #2   foreach (var item in collection?.NotNullItems())     Console.WriteLine(item); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u044b \u0434\u0443\u043c\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u0446\u0438\u043a\u043b\u043e\u0432, \u0435\u0441\u043b\u0438 <em>collection<\/em> \u2014 <em>null<\/em>? \u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <em>?.<\/em> \u0431\u043e\u043b\u0435\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439. \u041d\u043e \u0442\u0430\u043a \u043b\u0438 \u044d\u0442\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435? \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0443\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0437\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u0432 \u0432\u0430\u0448\u0443 \u0434\u0443\u0448\u0443 \u0441\u043e\u043c\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0441\u043e \u0432\u0441\u0435\u043c \u044d\u0442\u0438\u043c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u043d\u0438\u0436\u0435. \u0410 \u043a \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0439 \u0432\u044b\u0448\u0435 \u0437\u0430\u0434\u0430\u0447\u043a\u0435 \u043c\u044b \u0435\u0449\u0451 \u0432\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u043d\u0430\u0447\u043d\u0451\u043c \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u0435, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c\u0441\u044f \u0441 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u0435\u0439. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/language-reference\/language-specification\/statements#the-foreach-statement\">\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e C#<\/a>, \u0440\u0430\u0437\u0434\u0435\u043b &quot;The foreach statement&quot;.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5e4\/945\/87e\/5e494587e88c2320e765131b419e26c0.png\" alt=\"0832_foreach_ConditionalAccess_ru\/image2.png\"><\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u0438\u0434\u0442\u0438 \u0446\u0438\u043a\u043b, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0430\u043a &quot;expression&quot;. \u041e\u0434\u043d\u0430\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u043b\u043e\u0432\u0430 \u2014 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u2014 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0435 \u043b\u0443\u0447\u0448\u0435\u0439 \u0438\u0434\u0435\u0435\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u043f\u0443\u0442\u0430\u043d\u0438\u0446\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u043b\u0435\u0435 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u0440\u043c\u0438\u043d &quot;\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u043c\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435&quot;, \u0438\u043c\u0435\u044f \u0432 \u0432\u0438\u0434\u0443 &quot;expression&quot; \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u044b\u0448\u0435. \u041f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c.<\/p>\n<p>  <\/p>\n<h2 id=\"pochemu-opasno-ispolzovat-operator--v-perechislimom-vyrazhenii-cikla-foreach\">\u041f\u043e\u0447\u0435\u043c\u0443 \u043e\u043f\u0430\u0441\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &#8216;?.&#8217; \u0432 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u043c\u043e\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0446\u0438\u043a\u043b\u0430 foreach<\/h2>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u0441\u0442\u043e\u0438\u0442 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <em>?.<\/em><\/p>\n<p>  <\/p>\n<p>\u0421 \u043d\u0438\u043c \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043c \u0431\u044b\u0441\u0442\u0440\u043e.<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">var b = a?.Foo();<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0435\u0441\u043b\u0438 <em>a == null<\/em>, <em>b == null<\/em>;<\/li>\n<li>\u0435\u0441\u043b\u0438 <em>a != null<\/em>, <em>b == a.Foo()<\/em>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0446\u0438\u043a\u043b <em>foreach<\/em>. \u041d\u0435 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0433\u043e\u0440\u043a\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0430\u0445\u0430\u0440\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">void Foo1(IEnumerable&lt;String&gt; collection) {   foreach (var item in collection)     Console.WriteLine(item); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c IL \u043a\u043e\u0434, \u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 C#, \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <em>foreach<\/em>. \u0412\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">void Foo2(IEnumerable&lt;String&gt; collection) {   var enumerator = collection.GetEnumerator();   try   {     while (enumerator.MoveNext())     {       var item = enumerator.Current;       Console.WriteLine(item);     }   }   finally   {     if (enumerator != null)     {       enumerator.Dispose();     }   } }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong>. \u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 <em>foreach<\/em> \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u043a\u043e\u0434. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043a\u043e\u0434, \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b\u0439 \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0446\u0438\u043a\u043b\u0430 <em>for<\/em>. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u0441\u0451 \u0442\u0430\u043a\u0436\u0435 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439. \u042f \u0434\u0443\u043c\u0430\u044e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0446\u0438\u043a\u043b\u0430 <em>foreach<\/em> \u043c\u044b \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>  <\/p>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0434\u0435\u0441\u044c \u0434\u043b\u044f \u043d\u0430\u0441 \u2014 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <em>collection.GetEnumerator()<\/em>. \u0427\u0451\u0440\u043d\u044b\u043c \u043f\u043e \u0431\u0435\u043b\u043e\u043c\u0443 (\u0445\u043e\u0442\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0432\u0430\u0448\u0435\u0439 \u0446\u0432\u0435\u0442\u043e\u0432\u043e\u0439 \u0441\u0445\u0435\u043c\u044b) \u0432 \u043a\u043e\u0434\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <em>GetEnumerator<\/em>. \u0415\u0441\u043b\u0438 \u044d\u0442\u0430 \u0441\u0441\u044b\u043b\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u043b\u0435\u0432\u043e\u0439, \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 <em>NullReferenceException<\/em>.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0436\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <em>?.<\/em> \u0432 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u043c\u043e\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 <em>foreach<\/em>:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">static void Foo3(Wrapper wrapper) {   foreach (var item in wrapper?.Strings)     Console.WriteLine(item); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">static void Foo4(Wrapper wrapper) {   IEnumerable&lt;String&gt; strings;   if (wrapper == null)   {     strings = null;   }   else   {     strings = wrapper.Strings;   }    var enumerator = strings.GetEnumerator();   try   {     while (enumerator.MoveNext())     {       var item = enumerator.Current;       Console.WriteLine(item);     }   }   finally   {     if (enumerator != null)     {       enumerator.Dispose();     }   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c, \u043a\u0430\u043a \u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <em>GetEnumerator<\/em> (<em>strings.GetEnumerator<\/em>). \u041e\u0434\u043d\u0430\u043a\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>strings<\/em> \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>null<\/em>, \u0435\u0441\u043b\u0438 <em>wrapper<\/em> \u2014 <em>null<\/em>. \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u044d\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e, \u0435\u0441\u043b\u0438 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <em>?.<\/em> (\u043c\u044b \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u043b\u0438 \u044d\u0442\u043e \u0432\u044b\u0448\u0435). \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 <em>string.GetEnumerator()<\/em> \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 <em>NullReferenceException<\/em>.<\/p>\n<p>  <\/p>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <em>?.<\/em> \u0432 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u043c\u043e\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 <em>foreach<\/em> \u043d\u0435 \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u043e\u0442 \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, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0438\u043b\u043b\u044e\u0437\u0438\u044e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  <\/p>\n<h2 id=\"kak-prishla-ideya-dorabotki-analizatora\">\u041a\u0430\u043a \u043f\u0440\u0438\u0448\u043b\u0430 \u0438\u0434\u0435\u044f \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430?<\/h2>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043a\u043e \u043c\u043d\u0435 \u043a\u043e\u043b\u043b\u0435\u0433\u0430 \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u2014 \u0432\u043e\u0442 \u043a\u043e\u0434, \u043e\u0448\u0438\u0431\u043a\u0443 \u043d\u0435 \u043b\u043e\u0432\u0438\u043c. \u042f \u0432 \u0443\u0434\u0438\u0432\u043b\u0435\u043d\u0438\u0438. \u0422\u043e\u0447\u043d\u043e \u043f\u043e\u043c\u043d\u044e, \u043a\u0430\u043a \u044f \u0441\u0430\u043c \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u043b \u043d\u0430 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 \u0432 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u043c\u043e\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 <em>foreach<\/em> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>null<\/em>. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u044e. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u043c \u043d\u0438\u0436\u0435 \u043a\u043e\u0434\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043d\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442.<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">void Test1(IEnumerable&lt;String&gt; collection,            Func&lt;String, bool&gt; predicate) {   foreach (var item in collection?.Where(predicate))     Console.WriteLine(item); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u043d\u0430 \u0442\u0430\u043a\u043e\u043c \u2014 \u0442\u043e\u0436\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">void Test2(IEnumerable&lt;String&gt; collection,            Func&lt;String, bool&gt; predicate) {   var query = collection?.Where(predicate);   foreach (var item in query)     Console.WriteLine(item); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410 \u0432\u043e\u0442 \u043d\u0430 \u0442\u0430\u043a\u043e\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0435 \u043a\u043e\u0434\u0430 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c.<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">void Test3(IEnumerable&lt;String&gt; collection,            Func&lt;String, bool&gt; predicate,           bool flag) {   var query = collection != null ? collection.Where(predicate) : null;   foreach (var item in query)     Console.WriteLine(item); }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio<\/strong>: <a href=\"https:\/\/pvs-studio.com\/ru\/w\/v3080\/\">V3080<\/a> Possible null dereference. Consider inspecting &#8216;query&#8217;.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0434\u0430\u043d\u043e.<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">IEnumerable&lt;String&gt; GetPotentialNull(IEnumerable&lt;String&gt; collection,                                      Func&lt;String, bool&gt; predicate,                                      bool flag) {   return collection != null ? collection.Where(predicate) : null; }  void Test4(IEnumerable&lt;String&gt; collection,            Func&lt;String, bool&gt; predicate,           bool flag) {   foreach (var item in GetPotentialNull(collection, predicate, flag))     Console.WriteLine(item); }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio<\/strong>: <a href=\"https:\/\/pvs-studio.com\/ru\/w\/v3080\/\">V3080<\/a> Possible null dereference of method return value. Consider inspecting: GetPotentialNull(&#8230;).<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u0436\u0435 \u0432 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 <em>Test3<\/em> \u0438 <em>Test4<\/em> \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0432\u044b\u0434\u0430\u0451\u0442\u0441\u044f, \u0430 \u0432 <em>Test1<\/em> \u0438 <em>Test2<\/em> \u2014 \u043d\u0435\u0442? \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442 \u044d\u0442\u0438 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043d\u0435 \u0432\u044b\u0434\u0430\u0432\u0430\u043b \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <em>?.<\/em>;<\/li>\n<li>\u0435\u0441\u043b\u0438 \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0433\u0434\u0435-\u0442\u043e \u044f\u0432\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u043e\u0441\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>null<\/em>, \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0432\u044b\u0434\u0430\u0432\u0430\u043b\u043e\u0441\u044c.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0421\u0434\u0435\u043b\u0430\u043d\u043e \u044d\u0442\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0441\u043c\u043e\u0433 \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0432\u044b\u0434\u0430\u0451\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435;<\/li>\n<li>\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0441\u043b\u0443\u0447\u0430\u0438 (\u043f\u043e\u0432\u044b\u0448\u0430\u0442\u044c \/ \u043f\u043e\u043d\u0438\u0436\u0430\u0442\u044c \u0443\u0440\u043e\u0432\u0435\u043d\u044c, \u043f\u043e\u0434\u0430\u0432\u043b\u044f\u0442\u044c \/ \u043d\u0435 \u043f\u043e\u0434\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u0442.\u043f.);<\/li>\n<li>\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f, \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u044e\u0449\u0430\u044f \u0441\u0443\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"kakie-diagnostiki-byli-uluchsheny\">\u041a\u0430\u043a\u0438\u0435 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438 \u0431\u044b\u043b\u0438 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u044b?<\/h2>\n<p>  <\/p>\n<p>\u041f\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c \u0431\u044b\u043b\u0438 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u044b 2 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u0430: <a href=\"https:\/\/pvs-studio.com\/ru\/w\/v3105\/\">V3105<\/a> \u0438 <a href=\"https:\/\/pvs-studio.com\/ru\/w\/v3153\/\">V3153<\/a>.<\/p>\n<p>  <\/p>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong>. \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043f\u043e \u044d\u0442\u0438\u043c \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u043b\u0438\u0437\u0430 PVS-Studio 7.13, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0439\u0434\u0443\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u0440\u0430\u0432\u043a\u0438.<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/w\/v3105\/\">V3105<\/a> \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <em>?.<\/em>, \u0430 \u0434\u0430\u043b\u0435\u0435 \u044d\u0442\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u043c\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f <em>foreach<\/em>.<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">void Test(IEnumerable&lt;String&gt; collection,            Func&lt;String, bool&gt; predicate) {   var query = collection?.Where(predicate);   foreach (var item in query)     Console.WriteLine(item); }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio<\/strong>: <a href=\"https:\/\/pvs-studio.com\/ru\/w\/v3105\/\">V3105<\/a> The &#8216;query&#8217; variable was used after it was assigned through null-conditional operator. NullReferenceException is possible.<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/w\/v3153\/\">V3153<\/a> \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <em>?.<\/em> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u044f\u043c\u043e \u0432 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u043c\u043e\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 <em>foreach<\/em>.<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">void Test(IEnumerable&lt;String&gt; collection,            Func&lt;String, bool&gt; predicate) {   foreach (var item in collection?.Where(predicate))     Console.WriteLine(item); }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio<\/strong>: <a href=\"https:\/\/pvs-studio.com\/ru\/w\/v3153\/\">V3153<\/a> Enumerating the result of null-conditional access operator can lead to NullReferenceException. Consider inspecting: collection?.Where(predicate).<\/p>\n<p>  <\/p>\n<h2 id=\"primery-obnaruzhennyh-problem\">\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c<\/h2>\n<p>  <\/p>\n<p>\u0421\u0430\u043c\u043e\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0435 \u0432 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0430\u0445 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u2014 \u043a\u043e\u0433\u0434\u0430 \u0432\u0438\u0434\u0438\u0448\u044c \u043f\u0440\u043e\u0444\u0438\u0442 \u043e\u0442 \u043d\u0438\u0445. \u041a\u0430\u043a \u043c\u044b \u043d\u0435\u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438, \u043c\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u043d\u0430 \u0431\u0430\u0437\u0435 open source \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432. \u0418 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0430\u0432\u043e\u043a <a href=\"https:\/\/pvs-studio.com\/ru\/w\/v3105\/\">V3105<\/a> \u0438 <a href=\"https:\/\/pvs-studio.com\/ru\/w\/v3153\/\">V3153<\/a> \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u044b\u0445 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439!<\/p>\n<p>  <\/p>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong>. \u041f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0434\u0430 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u0435, \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0432 \u043d\u0430\u0448\u0438 \u0442\u0435\u0441\u0442\u044b. \u0422\u043e \u0435\u0441\u0442\u044c \u0432 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u0435 \u044d\u0442\u0438\u0445 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0431\u044b\u0442\u044c, \u0438\u043b\u0438 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445.<\/p>\n<p>  <\/p>\n<h3 id=\"ravendb\">RavenDB<\/h3>\n<p>  <\/p>\n<pre><code class=\"cs\">private void HandleInternalReplication(DatabaseRecord newRecord,                                         List&lt;IDisposable&gt; instancesToDispose) {   var newInternalDestinations =         newRecord.Topology?.GetDestinations(_server.NodeTag,                                             Database.Name,                                             newRecord.DeletionInProgress,                                             _clusterTopology,                                             _server.Engine.CurrentState);   var internalConnections          = DatabaseTopology.FindChanges(_internalDestinations,                                         newInternalDestinations);    if (internalConnections.RemovedDestiantions.Count &gt; 0)   {     var removed = internalConnections.RemovedDestiantions                                      .Select(r =&gt; new InternalReplication       {         NodeTag = _clusterTopology.TryGetNodeTagByUrl(r).NodeTag,         Url = r,         Database = Database.Name       });      DropOutgoingConnections(removed, instancesToDispose);   }   if (internalConnections.AddedDestinations.Count &gt; 0)   {     var added = internalConnections.AddedDestinations                                    .Select(r =&gt; new InternalReplication     {       NodeTag = _clusterTopology.TryGetNodeTagByUrl(r).NodeTag,       Url = r,       Database = Database.Name     });     StartOutgoingConnections(added.ToList());   }   _internalDestinations.Clear();   foreach (var item in newInternalDestinations)   {     _internalDestinations.Add(item);   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0432\u0451\u043b \u0432\u0435\u0441\u044c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0446\u0435\u043b\u0438\u043a\u043e\u043c. \u0421\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u0435\u0441\u044c, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435 \u0442\u043e \u0447\u0442\u043e\u0431\u044b \u043e\u0447\u0435\u043d\u044c \u0437\u0430\u043c\u0435\u0442\u043d\u0430. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0438\u0449\u0435\u0448\u044c, \u0442\u043e \u0434\u0435\u043b\u043e \u0438\u0434\u0451\u0442 \u043f\u0440\u043e\u0449\u0435. \ud83d\ude09 <\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043a\u043e\u0434 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0439.<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">private void HandleInternalReplication(DatabaseRecord newRecord,                                         List&lt;IDisposable&gt; instancesToDispose) {   var newInternalDestinations = newRecord.Topology?.GetDestinations(....);   ....   foreach (var item in newInternalDestinations)     .... }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <em>newInternalDestinations<\/em> \u0437\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <em>?.<\/em>. \u0415\u0441\u043b\u0438 <em>newRecord.Topology<\/em> \u2014 <em>null<\/em>, <em>newInternalDestinations<\/em> \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>null<\/em>. \u041f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <em>foreach<\/em> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 <em>NullReferenceException<\/em>.<\/p>\n<p>  <\/p>\n<p><strong>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio<\/strong>: <a href=\"https:\/\/pvs-studio.com\/ru\/w\/v3105\/\">V3105<\/a> The &#8216;newInternalDestinations&#8217; variable was used after it was assigned through null-conditional operator. NullReferenceException is possible. ReplicationLoader.cs 828<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u0435\u0449\u0451 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u044d\u0442\u0430 \u0436\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u2014 <em>newInternalDestinations<\/em> \u2014 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434 <em>DatabaseTopology.FindChanges<\/em>, \u0433\u0434\u0435 \u043e\u043d\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043d\u0430 <em>null<\/em> (\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <em>newDestinations<\/em>):<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">internal static  (HashSet&lt;string&gt; AddedDestinations, HashSet&lt;string&gt; RemovedDestiantions) FindChanges(IEnumerable&lt;ReplicationNode&gt; oldDestinations,              List&lt;ReplicationNode&gt; newDestinations) {   ....   if (newDestinations != null)   {     newList.AddRange(newDestinations.Select(s =&gt; s.Url));   }   .... }<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"msbuild\">MSBuild<\/h3>\n<p>  <\/p>\n<pre><code class=\"cs\">public void LogTelemetry(string eventName,                           IDictionary&lt;string, string&gt; properties) {   string message             = $&quot;Received telemetry event '{eventName}'{Environment.NewLine}&quot;;    foreach (string key in properties?.Keys)   {     message += $&quot;  Property '{key}' = '{properties[key]}'{Environment.NewLine}&quot;;   }   .... }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio<\/strong>: <a href=\"https:\/\/pvs-studio.com\/ru\/w\/v3153\/\">V3153<\/a> Enumerating the result of null-conditional access operator can lead to NullReferenceException. Consider inspecting: properties?.Keys. MockEngine.cs 159<\/p>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <em>?.<\/em> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u043c\u043e\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 <em>foreach<\/em>. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0435\u0435. \u041d\u043e \u043c\u044b-\u0442\u043e \u0441 \u0432\u0430\u043c\u0438 \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0435\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \ud83d\ude09<\/p>\n<p>  <\/p>\n<h3 id=\"nethermind\">Nethermind<\/h3>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439. <\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">public NLogLogger(....) {   ....    foreach (FileTarget target in global::NLog.LogManager                                             .Configuration                                            ?.AllTargets                                             .OfType&lt;FileTarget&gt;())   {     ....   }   .... }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio<\/strong>: <a href=\"https:\/\/pvs-studio.com\/ru\/w\/v3153\/\">V3153<\/a> Enumerating the result of null-conditional access operator can lead to NullReferenceException. NLogLogger.cs 50<\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u0448\u0438\u043b\u0438 &quot;\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u0438\u0442\u044c\u0441\u044f&quot; \u043e\u0442 <em>NullReferenceException<\/em> \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <em>?.<\/em> \u043f\u0440\u044f\u043c\u043e \u0432 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u043c\u043e\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 <em>foreach<\/em>. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0438\u043c \u043f\u043e\u0432\u0435\u0437\u0451\u0442 \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <em>Configuration<\/em> \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0432\u0435\u0440\u043d\u0451\u0442 <em>null<\/em>. \u0418\u043d\u0430\u0447\u0435 \u043d\u0430\u0441\u0442\u0430\u043d\u0435\u0442 \u0447\u0430\u0441, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 &quot;\u0432\u044b\u0441\u0442\u0440\u0435\u043b\u0438\u0442&quot;.<\/p>\n<p>  <\/p>\n<h3 id=\"roslyn\">Roslyn<\/h3>\n<p>  <\/p>\n<pre><code class=\"cs\">private ImmutableArray&lt;char&gt; GetExcludedCommitCharacters(ImmutableArray&lt;RoslynCompletionItem&gt; roslynItems) {   var hashSet = new HashSet&lt;char&gt;();   foreach (var roslynItem in roslynItems)   {     foreach (var rule in roslynItem.Rules?.FilterCharacterRules)     {       if (rule.Kind == CharacterSetModificationKind.Add)       {         foreach (var c in rule.Characters)         {           hashSet.Add(c);         }       }     }   }    return hashSet.ToImmutableArray(); }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio<\/strong>: <a href=\"https:\/\/pvs-studio.com\/ru\/w\/v3153\/\">V3153<\/a> Enumerating the result of null-conditional access operator can lead to NullReferenceException. CompletionSource.cs 482<\/p>\n<p>  <\/p>\n<p>\u041d\u0443 \u0437\u0434\u043e\u0440\u043e\u0432\u043e \u0436\u0435, \u0430? \u041b\u044e\u0431\u043b\u044e, \u043a\u043e\u0433\u0434\u0430 PVS-Studio \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 \u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430\u0445 \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430\u0445.<\/p>\n<p>  <\/p>\n<h3 id=\"pvs-studio\">PVS-Studio<\/h3>\n<p>  <\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435-\u0442\u043e \u043c\u044b \u0438 \u0441\u0430\u043c\u0438 \u043d\u0435 \u0431\u0435\u0437 \u0433\u0440\u0435\u0445\u0430, \u0438 \u0442\u043e\u0436\u0435 \u043f\u0440\u043e\u0448\u043b\u0438\u0441\u044c \u043f\u043e \u044d\u0442\u0438\u043c \u0436\u0435 \u0433\u0440\u0430\u0431\u043b\u044f\u043c. \ud83d\ude42 <\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/7bd\/2cb\/edd\/7bd2cbedd73555f081732ac1b510925f.png\" alt=\"0832_foreach_ConditionalAccess_ru\/image3.png\"><\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c PVS-Studio \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PVS-Studio. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043d\u043e\u0447\u044c\u044e \u043d\u0430 \u0441\u0431\u043e\u0440\u043e\u0447\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u0430 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430. \u0412 \u043d\u0435\u0451 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u043f\u0440\u0430\u0432\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0437\u0430\u043b\u043e\u0436\u0435\u043d\u044b \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0432\u0435\u0442\u043a\u0443 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0434\u043d\u044f;<\/li>\n<li>\u044d\u0442\u043e\u0439 \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u0434 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u2014 \u0441\u0430\u043c\u043e\u0433\u043e PVS-Studio;<\/li>\n<li>\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0432\u044b\u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f\u0445 \u0440\u0430\u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0438 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044f\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/pvs-studio.com\/ru\/m\/0050\/\">\u0443\u0442\u0438\u043b\u0438\u0442\u044b BlameNotifier<\/a>;<\/li>\n<li>\u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0418 \u0432\u043e\u0442, \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0431\u044b\u043b\u0438 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u044b <a href=\"https:\/\/pvs-studio.com\/ru\/w\/v3153\/\">V3153<\/a> \u0438 <a href=\"https:\/\/pvs-studio.com\/ru\/w\/v3105\/\">V3105<\/a>, \u043c\u044b \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u0438, \u0447\u0442\u043e \u0438 \u043d\u0430 \u043d\u0430\u0448\u0435\u043c \u043a\u043e\u0434\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u0430\u0448\u043b\u0438\u0441\u044c \u0438 \u043f\u0440\u044f\u043c\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <em>?.<\/em> \u0432 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u043c\u043e\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 <em>foreach<\/em>, \u0438 \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u044b\u0435 (\u0441 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e). \u041f\u043e\u0432\u0435\u0437\u043b\u043e \u043d\u0430\u043c, \u0447\u0442\u043e \u043a\u043e\u0434 \u0432 \u044d\u0442\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445 \u043d\u0435 \u043f\u0430\u0434\u0430\u043b. \u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f \u0443\u0436\u0435 \u0443\u0447\u0442\u0435\u043d\u044b, \u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0441\u0442\u0430 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b. \ud83d\ude09<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b\u043e \u0432\u044b\u0434\u0430\u043d\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">public override void VisitAnonymousObjectCreationExpression(   AnonymousObjectCreationExpressionSyntax node) {   foreach (var initializer in node?.Initializers)     initializer?.Expression?.Accept(this); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430, \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 <em>?.<\/em> \u0437\u0434\u0435\u0441\u044c \u043e\u0442 \u0434\u0443\u0448\u0438 \u2014 \u043d\u0430\u0439\u0434\u0438\u0442\u0435 \u0442\u043e\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u0440\u0435\u043b\u0438\u0442 \u043d\u043e\u0433\u0443. \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0433\u043e\u043b\u043e\u0441\u043e\u043c \u043e\u0437\u0432\u0443\u0447\u043a\u0438 \u043d\u0430\u043d\u043e\u043a\u043e\u0441\u0442\u044e\u043c\u0430 \u0438\u0437 Crysis), \u0430 \u043d\u0430 \u0434\u0435\u043b\u0435 \u2014 \u043d\u0435\u0442.<\/p>\n<p>  <\/p>\n<h2 id=\"mozhno-li-ispolzovat-operator--v-perechislimom-vyrazhenii-cikla-foreach-bezopasno\">\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &#8216;?.&#8217; \u0432 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u043c\u043e\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0446\u0438\u043a\u043b\u0430 foreach \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e?<\/h2>\n<p>  <\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e. \u0418 \u043c\u044b \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0438 \u0442\u0430\u043a\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0439\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <em>??<\/em>.<\/p>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043e\u043f\u0430\u0441\u0435\u043d \u0438 \u0433\u0440\u043e\u0437\u0438\u0442 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u0438\u043f\u0430 <em>NullReferenceException<\/em>:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">static void Test(IEnumerable&lt;String&gt; collection,                  Func&lt;String, bool&gt; predicate) {   foreach (var item in collection?.Where(predicate))     Console.WriteLine(item); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410 \u043d\u0430 \u0442\u0430\u043a\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u043a\u043e\u0434\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0443\u0436\u0435 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">static void Test(IEnumerable&lt;String&gt; collection,                  Func&lt;String, bool&gt; predicate) {   foreach (var item in    collection?.Where(predicate)                         ?? Enumerable.Empty&lt;String&gt;())   {     Console.WriteLine(item);   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <em>?.<\/em> \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u0435\u0440\u043d\u0451\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>null<\/em>, \u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <em>??<\/em> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <em>Enumerable.Empty&lt;String&gt;()<\/em> \u2014 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \u041d\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u043d\u0435 \u043f\u0440\u043e\u0449\u0435 \u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044f\u0432\u043d\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430 <em>null<\/em>.<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">static void Test(IEnumerable&lt;String&gt; collection,                  Func&lt;String, bool&gt; predicate) {   if (collection != null)   {     foreach (var item in collection.Where(predicate))       Console.WriteLine(item);   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435 \u0442\u0430\u043a \u043c\u043e\u0434\u043d\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u043e, \u043c\u043e\u0436\u0435\u0442, \u0434\u0430\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u043e.<\/p>\n<p>  <\/p>\n<h2 id=\"razbiraem-zadachku-iz-nachala-stati\">\u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u043a\u0443 \u0438\u0437 \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0442\u0430\u0442\u044c\u0438<\/h2>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e, \u0447\u0442\u043e \u043c\u044b \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434.<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">void ForeachTest(IEnumerable&lt;String&gt; collection) {   \/\/ #1   foreach (var item in collection.NotNullItems())     Console.WriteLine(item);    \/\/ #2   foreach (var item in collection?.NotNullItems())     Console.WriteLine(item); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442 #2 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0438 \u043d\u0435 \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u043e\u0442 <em>NullReferenceException<\/em>. \u0410 \u0447\u0442\u043e \u0436\u0435 \u0441 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c #1? \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <em>NullReferenceException<\/em> \u2014 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 <em>collection.NotNullItems()<\/em>. \u0410 \u0432\u043e\u0442 \u0438 \u043d\u0435 \u0444\u0430\u043a\u0442! \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e <em>NotNullItems<\/em> \u2014 \u043c\u0435\u0442\u043e\u0434 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u0438\u043c\u0435\u044e\u0449\u0438\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0442\u0435\u043b\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">public static IEnumerable&lt;T&gt; NotNullItems&lt;T&gt;(this IEnumerable&lt;T&gt; collection) where T : class {   if (collection == null)     return Enumerable.Empty&lt;T&gt;();    return collection.Where(item =&gt; item != null); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0432 \u043c\u0435\u0442\u043e\u0434 \u0437\u0430\u0448\u0438\u0442\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 <em>collection<\/em> \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>null<\/em>. \u0422\u0430\u043a \u043a\u0430\u043a \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>Enumerable.Empty&lt;T&gt;()<\/em>, \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0435\u0433\u043e \u043e\u0431\u0445\u043e\u0434\u0430 \u0432 \u0446\u0438\u043a\u043b\u0435 <em>foreach<\/em> \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \u0422\u043e \u0435\u0441\u0442\u044c \u0446\u0438\u043a\u043b #1 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 <em>collection<\/em> \u2014 <em>null<\/em>.<\/p>\n<p>  <\/p>\n<p>\u0410 \u0432\u043e\u0442 \u0432\u0442\u043e\u0440\u043e\u0439 \u0446\u0438\u043a\u043b \u043a\u0430\u043a \u0431\u044b\u043b \u043e\u043f\u0430\u0441\u043d\u044b\u043c, \u0442\u0430\u043a \u0438 \u043e\u0441\u0442\u0430\u043b\u0441\u044f. \u0415\u0441\u043b\u0438 <em>collection<\/em> \u2014 <em>null<\/em>, \u043c\u0435\u0442\u043e\u0434 <em>NotNullItems<\/em> \u0432\u044b\u0437\u0432\u0430\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0437\u0430\u043b\u043e\u0436\u0435\u043d\u043d\u0430\u044f \u0432 \u043d\u0435\u0433\u043e \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u044f, \u043a\u043e\u0433\u0434\u0430 <em>collection<\/em> \u2014 <em>null<\/em>. \u0412 \u0438\u0442\u043e\u0433\u0435, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u0441\u0451 \u0442\u0443 \u0436\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043d\u0435\u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0438: \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 <em>GetEnumerator()<\/em> \u0447\u0435\u0440\u0435\u0437 \u043d\u0443\u043b\u0435\u0432\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443.<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u043e\u0439 \u0432\u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u044b\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u044f\u0432\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 <em>collection.NotNullItems()<\/em> \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u043e\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f <em>NullReferenceException<\/em>, \u0430 &#8216;\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432&#8217; \u2014 <em>collection?.NotNullItems()<\/em> \u2014 \u043d\u0435 \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442. <\/p>\n<p>  <\/p>\n<h2 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u0412\u044b\u0432\u043e\u0434\u043e\u0432 \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <em>?.<\/em> \u0432 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u043c\u043e\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 <em>foreach<\/em> \u043f\u0440\u044f\u043c\u043e \u0438\u043b\u0438 \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u043e \u2014 \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043b\u043b\u044e\u0437\u0438\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438;<\/li>\n<li>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0441\u0435\u0431\u044f \u0436\u0435 \u043c\u044b \u0435\u0449\u0451 \u0440\u0430\u0437 \u043e\u0442\u043c\u0435\u0442\u0438\u043b\u0438, \u0447\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438, \u043d\u043e \u0438 \u0434\u043e\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0438\u0435.<\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u0441\u0443\u0436\u0434\u0430\u0435\u043c\u044b\u0435 \u043f\u0440\u0430\u0432\u043a\u0438 \u0432\u043e\u0448\u043b\u0438 \u0432 \u0440\u0435\u043b\u0438\u0437 PVS-Studio 7.13. \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043b\u0438 \u043a\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <em>?.<\/em> \u0432 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u043c\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445 \u043d\u0430 \u0432\u0430\u0448\u0435\u0439 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u0435? \u0422\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u044e <a href=\"https:\/\/pvs-studio.com\/ru\/pvs-studio-download\/\">\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u0441 \u0441\u0430\u0439\u0442\u0430<\/a> \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434.<\/p>\n<p>  <\/p>\n<p>\u0418, \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u044e \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043c\u043e\u0439 <a href=\"https:\/\/twitter.com\/_SergVasiliev_\">Twitter-\u0430\u043a\u043a\u0430\u0443\u043d\u0442<\/a>.<\/p>\n<p>  <\/p>\n<p>\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: Sergey Vasiliev. <a href=\"https:\/\/habr.com\/en\/company\/pvs-studio\/blog\/560822\/\">The &#8216;?.&#8217; Operator in foreach Will Not Protect From NullReferenceException<\/a>.<\/p>\n<\/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\/560824\/\"> https:\/\/habr.com\/ru\/company\/pvs-studio\/blog\/560824\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/9e3\/12d\/f63\/9e312df6325df01e5a3b313cc3b9f349.png\" alt=\"0832_foreach_ConditionalAccess_ru\/image1.png\"><br \/>  \u041b\u044e\u0431\u0438\u0442\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &#8216;?.&#8217;? \u0410 \u043a\u0442\u043e \u0436\u0435 \u043d\u0435 \u043b\u044e\u0431\u0438\u0442? \u042d\u0442\u0438 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 null \u043d\u0440\u0430\u0432\u044f\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u0438\u043c. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &#8216;?.&#8217; \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0438\u043b\u043b\u044e\u0437\u0438\u044e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u0420\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0451\u0442 \u043e \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 \u0446\u0438\u043a\u043b\u0435 foreach.<\/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-324302","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/324302","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=324302"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/324302\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=324302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=324302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=324302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}