{"id":393312,"date":"2024-06-29T10:56:00","date_gmt":"2024-06-29T10:56:00","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=393312"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=393312","title":{"rendered":"<span>\u0415\u0441\u0442\u044c \u043b\u0438 \u0432 \u0432\u0430\u0448\u0435\u0439 IDE \u0431\u0430\u0433\u0438? \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 AvalonStudio \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PVS-Studio<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u043c\u0438\u0440\u0443 \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0441\u0432\u043e\u0438 \u043b\u044e\u0431\u0438\u043c\u044b\u0435 IDE \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043e\u0434\u043d\u0443 \u0438\u0437 \u043d\u0438\u0445 \u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0430\u043c\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8e8\/483\/49a\/8e848349a4cc9dd729f8a0d82908c0b5.png\" width=\"780\" height=\"440\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8e8\/483\/49a\/8e848349a4cc9dd729f8a0d82908c0b5.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0416\u0438\u0437\u043d\u044c \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u0431\u0435\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041a \u0442\u0430\u043a\u043e\u0432\u044b\u043c \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f IDE (Integrated development environment). \u041e\u043d\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0446\u0435\u043b\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0443\u043f\u0440\u043e\u0449\u0430\u044e\u0449\u0438\u0445 \u0436\u0438\u0437\u043d\u044c. \u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0441\u0440\u0435\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440, \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044e \u043e\u0434\u043d\u0443 \u0438\u0437 IDE \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c. \u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043a\u043e\u0434\u0430 PVS-Studio. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043a\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043d\u0430 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f C, C++, C# \u0438 Java.<\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>AvalonStudio \u2013 \u044d\u0442\u043e \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u0430\u044f IDE, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u043d\u0430 C#. \u042d\u0442\u0430 \u0441\u0440\u0435\u0434\u0430 \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043f\u043e\u0434 Embedded C, C++, .NET Core, Avalonia \u0438 TypeScript. AvalonStudio \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 <a href=\"https:\/\/avaloniaui.net\/\">Avalonia UI<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b, \u043a\u0441\u0442\u0430\u0442\u0438, \u0442\u043e\u0436\u0435 <a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/csharp\/0701\/\">\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u0438<\/a>.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a8d\/6b3\/902\/a8d6b3902eb2badc8e57cddad242217d.png\" width=\"780\" height=\"423\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a8d\/6b3\/902\/a8d6b3902eb2badc8e57cddad242217d.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 AvalonStudio \u0431\u044b\u043b\u043e \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 <a href=\"https:\/\/github.com\/VitalElement\/AvalonStudio\/tree\/2ee2adbf1772c54531f0d5b0bc96a4789d6b826f\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043d\u0430 GitHub<\/a>. \u0421\u0440\u0435\u0434\u0438 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u044f \u043e\u0442\u043e\u0431\u0440\u0430\u043b \u0434\u043b\u044f \u0432\u0430\u0441 \u0441\u0430\u043c\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 :). \u041f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f!<\/p>\n<h3>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430<\/h3>\n<p>\u041a\u0430\u0436\u0434\u043e\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043e\u0434 \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043f\u0440\u0438\u043c\u0435\u0441\u044c\u044e \u043c\u043d\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0430. \u0415\u0441\u043b\u0438 \u0441 \u043a\u0430\u043a\u0438\u043c\u0438-\u043d\u0438\u0431\u0443\u0434\u044c \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u043d\u0435 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u044b, \u0442\u043e \u044f \u0441 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435\u043c \u043e\u0431\u0441\u0443\u0434\u0438\u043b \u0431\u044b \u044d\u0442\u043e \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<h4>Issue 1<\/h4>\n<pre><code class=\"cs\">private async void Timer_Tick(object sender, EventArgs e) {   ....     if (AssociatedObject.IsPointerOver)   {     var mouseDevice = (popup.GetVisualRoot() as IInputRoot)?.MouseDevice;     lastPoint = mouseDevice.GetPosition(AssociatedObject);     popup.Open();   } } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3105\/\">V3105<\/a> The &#8216;mouseDevice&#8217; variable was used after it was assigned through null-conditional operator. NullReferenceException is possible. TooltipBehavior.cs 173<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0437\u0430\u043c\u0435\u0442\u0438\u043b \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u0432 \u043a\u043e\u0434\u0435. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <em>as<\/em> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442 \u043d\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e <em>null<\/em> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e null-\u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u043b, \u0447\u0442\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 <em>as<\/em> \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c <em>null<\/em>. \u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c &#8216;?.&#8217; \u043e\u043d \u0437\u0430\u0449\u0438\u0442\u0438\u043b \u0441\u0435\u0431\u044f \u043e\u0442 <em>NullReferenceException<\/em> \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u043d\u043e \u0432\u043e\u0442 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e.<\/p>\n<h4>Issue 2<\/h4>\n<p>\u0410 \u0432\u043e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0441\u0442\u043e\u043b\u044c \u044f\u0432\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443, \u043d\u043e \u0432\u0441\u0451 \u0436\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e:<\/p>\n<pre><code class=\"cs\">private static Signature BuildSignature(IMethodSymbol symbol) {   ....   var returnTypeInfo = CheckForStaticExtension.GetReturnType(symbol);   if(returnTypeInfo.HasValue)   {     if(returnTypeInfo.Value.inbuilt)     {       signature.BuiltInReturnType = returnTypeInfo.Value.name;     }     else     {       signature.ReturnType = returnTypeInfo.Value.name;     }   }   signature.Parameters = symbol.Parameters.Select(parameter =>   {     var info = CheckForStaticExtension.GetReturnType(parameter);     ....     if(info.HasValue)     {       if(info.Value.inbuilt)       {         result.BuiltInType = info.Value.name;   \/\/ &lt;=       }       else       {         result.BuiltInType = info.Value.name;   \/\/ &lt;=       }     }     ....   }).ToList();   .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3004\/\">V3004<\/a> The &#8216;then&#8217; statement is equivalent to the &#8216;else&#8217; statement. InvocationContext.cs 400<\/p>\n<p>PVS-Studio \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b, \u0447\u0442\u043e then \u0438 else \u0432\u0435\u0442\u0432\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <em>if<\/em> \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u0434\u043d\u0438\u043c\u0435\u043c\u0441\u044f \u0447\u0443\u0442\u044c \u0432\u044b\u0448\u0435 \u043f\u043e \u043a\u043e\u0434\u0443, \u0442\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043f\u043e\u0445\u043e\u0436\u0438\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442, \u043d\u043e \u0432\u0435\u0442\u0432\u0438 \u0440\u0430\u0437\u043d\u044b\u0435. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0447\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u0432\u0435\u0442\u0432\u0435\u0439 \u043f\u0440\u043e\u0441\u0442\u043e \u043b\u0438\u0448\u043d\u044f\u044f. \u041d\u043e \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u0447\u0442\u043e \u043d\u0430 \u043c\u0435\u0441\u0442\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <em>BuiltInType<\/em> \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <em>Type<\/em>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u043e\u0433 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0430\u0432\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u0438 \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043e\u043d\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c. \u041a\u0441\u0442\u0430\u0442\u0438, \u043c\u043d\u0435 VS2022 \u0442\u043e\u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f: &#171;\u0414\u043e\u0432\u0435\u0440\u044f\u0439, \u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0439&#187;.<\/p>\n<h4>Issue 3<\/h4>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u044f \u043e\u0442\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043b, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u0431\u044b\u043b \u043d\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u0438 \u043f\u043b\u043e\u0445\u043e \u0447\u0438\u0442\u0430\u0435\u043c, \u043d\u043e \u0441\u0443\u0442\u044c \u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/462\/cac\/094\/462cac094fe7ac324897c87a987b046f.png\" width=\"780\" height=\"227\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/462\/cac\/094\/462cac094fe7ac324897c87a987b046f.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u0441\u0430\u043c\u043e\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043a\u043e\u0434 \u0447\u0443\u0442\u044c \u043b\u0443\u0447\u0448\u0435 \u043e\u0442\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0432\u0438\u0434\u043d\u0435\u0435.<\/p>\n<pre><code class=\"cs\">private bool CursorIsValidDeclaration(ClangCursor c) {   var result = false;    if (  (c.Kind == NClang.CursorKind.FunctionDeclaration)  \/\/ &lt;=       || c.Kind == NClang.CursorKind.CXXMethod        || c.Kind == NClang.CursorKind.Constructor        || c.Kind == NClang.CursorKind.Destructor        || c.Kind == NClang.CursorKind.FunctionDeclaration)  \/\/ &lt;=   {     result = true;   }   return result; } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3001\/\">V3001<\/a> There are identical sub-expressions &#8216;c.Kind == NClang.CursorKind.FunctionDeclaration&#8217; to the left and to the right of the &#8216;||&#8217; operator. CPlusPlusLanguageService.cs 1275<\/p>\n<p>\u041f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u043d\u0435\u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u0434\u043d\u043e \u0438\u0437 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u043f\u0440\u043e\u0441\u0442\u043e \u043b\u0438\u0448\u043d\u0435\u0435. \u0410 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438 \u0442\u0430\u043a, \u0447\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 <em>FunctionDeclaration<\/em> \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0435 :).<\/p>\n<h4>Issue 4<\/h4>\n<pre><code class=\"cs\">public override void Render(DrawingContext context) {   ....   foreach (var breakPoint in _manager?.OfType&lt;Breakpoint>().Where(....))   {     ....   }   .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3153\/\">V3153<\/a> Enumerating the result of null-conditional access operator can lead to NullReferenceException. BreakPointMargin.cs 46<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b, \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 &#8216;?.&#8217; \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 <em>null<\/em> \u0432\u043d\u0443\u0442\u0440\u0438 <em>foreach<\/em> \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430. <em>NullReferenceException<\/em> \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043d\u0430\u0441\u0442\u0438\u0433\u043d\u0435\u0442 \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043e\u0431\u0445\u043e\u0434\u0430 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438 :).<\/p>\n<p>\u0412\u043e\u043e\u0431\u0449\u0435, \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432. \u041c\u044b \u0434\u0430\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0446\u0435\u043b\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e: &#171;<a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/csharp\/0832\/\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 ?. \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<\/a>&#171;.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/142\/359\/54d\/14235954d1342422107f47dc13716f38.png\" width=\"580\" height=\"327\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/142\/359\/54d\/14235954d1342422107f47dc13716f38.png\"\/><figcaption><\/figcaption><\/figure>\n<h4>Issue 5<\/h4>\n<pre><code class=\"cs\">public async Task&lt;(....)> LoadProject(....) {   ....   return await Task.Run(() =>   {     ....     if (   loadData.CscCommandLine != null                            \/\/ &lt;=         &amp;&amp; loadData.CscCommandLine.Count > 0)     {       ....       return (projectInfo, projectReferences, loadData.TargetPath);     }     else     {       ....       return (projectInfo, projectReferences, loadData?.TargetPath);  \/\/ &lt;=     }   }); } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3095\/\">V3095<\/a> The &#8216;loadData&#8217; object was used before it was verified against null. Check lines: 233, 262. MSBuildHost.cs 233<\/p>\n<p>\u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0434\u043e\u043b\u0433\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u0442\u0443\u0442 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442. \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>loadData<\/em> \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0432\u043d\u0430 <em>null<\/em> \u0432 \u0432\u0435\u0442\u0432\u0438 else, \u0442\u043e \u0438 \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0436\u0435 <em>if<\/em> \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u043d\u0430 <em>null<\/em>. \u0412\u043e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u043d\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 <em>loadData<\/em> \u043d\u0430 <em>null<\/em>, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435. \u0418 \u0434\u0430, \u0432 else <em>loadData<\/em> \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f. \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &#8216;?.&#8217; \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 <em>if<\/em>. \u0425\u043e\u0442\u044f, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0432 <em>return<\/em> \u043b\u0438\u0448\u043d\u0438\u0439 \u0438 \u0435\u0433\u043e \u0441\u0442\u043e\u0438\u0442 \u0443\u0431\u0440\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0443\u0442\u0430\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432.<\/p>\n<h4>Issue 6<\/h4>\n<pre><code class=\"cs\">public override void Render(DrawingContext context) {   if (_lastFrame != null &amp;&amp; !(   _lastFrame.Width == 0                                || _lastFrame.Width == 0))   {     ....   }   base.Render(context); } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3001\/\">V3001<\/a> There are identical sub-expressions &#8216;_lastFrame.Width == 0&#8217; to the left and to the right of the &#8216;||&#8217; operator. RemoteWidget.cs 308<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0434\u0432\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u043f\u043e\u0434\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0432\u0430 \u0438 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 &#8216;||&#8217;. \u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u043e\u043f\u043b\u043e\u0448\u043d\u043e\u0441\u0442\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0451\u0433\u043a\u043e\u0435: \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u0434\u043d\u043e \u0438\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 <em>Width<\/em> \u043d\u0430 <em>Height<\/em>. \u042d\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u0430\u043b\u0435\u0435 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435.<\/p>\n<h4>Issue 7<\/h4>\n<pre><code class=\"cs\">public GlobalRunSpec(....) {   ....   if (specialEntry.Value != null)   {     ....   }   RunSpec spec = new(specialOps,                      specialVariables ?? variables,                      specialEntry.Value.VariableSetup.FallbackFormat);   .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3125\/\">V3125<\/a> The &#8216;specialEntry.Value&#8217; object was used after it was verified against null. Check lines: 92, 86. GlobalRunSpec.cs 92<\/p>\n<p>PVS-Studio \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e. <em>specialEntry.Value<\/em> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e <em>null<\/em>, \u0430 \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <em>specialEntry.Value<\/em> \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u0432\u043e\u0451 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<h4>Issue 8<\/h4>\n<pre><code class=\"cs\">private static StyledText InfoTextFromCursor(ClangCursor cursor) {   ....   if (cursor.ResultType != null)   {     result.Append(cursor.ResultType.Spelling + \" \",                   IsBuiltInType(cursor.ResultType) ? theme.Keyword                                                     : theme.Type);   }   else if (cursor.CursorType != null)   {     switch (kind)     {       ....     }     result.Append(cursor.CursorType.Spelling + \" \",                   IsBuiltInType(cursor.ResultType) ? theme.Keyword   \/\/ &lt;=                                                    : theme.Type);   }   .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3022\/\">V3022<\/a> Expression &#8216;IsBuiltInType(cursor.ResultType)&#8217; is always false. CPlusPlusLanguageService.cs 1105<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0441\u0447\u0438\u0442\u0430\u0435\u0442, \u0447\u0442\u043e <em>IsBuiltInType(cursor.ResultType)<\/em> \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u0435\u0440\u043d\u0451\u0442 <em>false<\/em>. \u041c\u0435\u0442\u043e\u0434 <em>IsBuiltInType<\/em> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 else-\u0432\u0435\u0442\u043a\u0435, \u0437\u043d\u0430\u0447\u0438\u0442 <em>cursor.ResultType<\/em> \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>null<\/em>.<\/p>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 <em>IsBuiltInType<\/em> \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0440\u0430\u0432\u0435\u043d <em>null<\/em>, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f <em>false<\/em>.<\/p>\n<pre><code class=\"cs\">private static bool IsBuiltInType(ClangType cursor) {   var result = false;   if (cursor != null &amp;&amp; ....)   {     return true;   }   return result; } <\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e <em>IsBuiltInType(cursor.ResultType)<\/em> \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c <em>false<\/em>.<\/p>\n<p>\u0425\u043c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0436\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e? \u0422\u0443\u0442 \u044f\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 copy-paste. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043b \u043f\u043e\u0445\u043e\u0436\u0438\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0432\u044b\u0448\u0435. \u0412\u043e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 <em>cursor.ResultType<\/em> \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 <em>cursor.CursorType<\/em> \u0437\u0430\u0431\u044b\u043b.<\/p>\n<h4>Issue 9<\/h4>\n<pre><code class=\"cs\">private int BuildCompletionsForMarkupExtension(....) {   ....   if (t.SupportCtorArgument == MetadataTypeCtorArgument.HintValues)   {     ....   }   else if (attribName.Contains(\".\"))   {     if (t.SupportCtorArgument != MetadataTypeCtorArgument.Type)     {       ....       if (   mType != null            &amp;&amp; t.SupportCtorArgument ==              MetadataTypeCtorArgument.HintValues)        \/\/ &lt;=       {         var hints = FilterHintValues(....);         completions.AddRange(hints.Select(.....));       }       ....     }     } } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3022\/\">V3022<\/a> Expression &#8216;mType != null &amp;&amp; t.SupportCtorArgument == MetadataTypeCtorArgument.HintValues&#8217; is always false. CompletionEngine.cs 601<\/p>\n<p>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e <em>SupportCtorArgument<\/em> \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 else-\u0432\u0435\u0442\u043a\u0435 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438. <em>SupportCtorArgument<\/em> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u0430\u0432\u0442\u043e\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c. \u0415\u0441\u043b\u0438 \u0431\u044b \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0431\u044b\u043b\u043e \u0440\u0430\u0432\u043d\u043e <em>MetadataTypeCtorArgument.HintValues<\/em>, \u0442\u043e \u0434\u043e \u044d\u0442\u043e\u0439 else-\u0432\u0435\u0442\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u043d\u0435 \u0434\u043e\u0448\u043b\u043e \u0431\u044b. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043b\u043e\u0436\u043d\u044b\u043c, \u0430 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 then-\u0432\u0435\u0442\u043a\u0435, \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d.<\/p>\n<h4>Issue 10<\/h4>\n<pre><code class=\"cs\">private void RegisterLanguageService(ISourceFile sourceFile) {   ....   var languageServiceProvider = IoC.Get&lt;IStudio>()                                    .LanguageServiceProviders                                    .FirstOrDefault(....)?.Value;    LanguageService = languageServiceProvider.CreateLanguageService();  \/\/ &lt;=    if (LanguageService != null)   {     ....   } } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3105\/\">V3105<\/a> The &#8216;languageServiceProvider&#8217; variable was used after it was assigned through null-conditional operator. NullReferenceException is possible. CodeEditorViewModel.cs 309<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \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 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e null-\u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430. \u0418 \u043a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &#8216;?.&#8217; \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>languageServiceProvider<\/em>. \u041d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0431\u0435\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438. \u041f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <em>NullReferenceException<\/em>. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c &#8216;?.&#8217; \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 <em>CreateLanguageService<\/em>.<\/p>\n<h4>Issue 11<\/h4>\n<pre><code class=\"cs\">public void SetCursorPosition(int column, int row) {   ....   if (LeftAndRightMarginEnabled)   {     if (CursorState.OriginMode &amp;&amp; CursorState.CurrentColumn &lt; LeftMargin)       CursorState.CurrentColumn = LeftMargin;     if (CursorState.CurrentColumn >= RightMargin)       RightMargin = RightMargin;                   \/\/ &lt;=   }   .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3005\/\">V3005<\/a> The &#8216;RightMargin&#8217; variable is assigned to itself. VirtualTerminalController.cs 1446<\/p>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>RightMargin<\/em> \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u0430 \u0441\u0435\u0431\u0435. \u041a\u043e\u0434, \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e, \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439. \u0418, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0437\u043d\u0430\u0435\u0442, \u043a\u0430\u043a \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435. \u041c\u044b \u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0433\u0430\u0434\u044b\u0432\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0442\u044c <em>RightMargin<\/em>.<\/p>\n<h4>Issue 12<\/h4>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0438 \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435.<\/p>\n<pre><code class=\"cs\">public class ColorScheme {   private static List&lt;ColorScheme> s_colorSchemes =     new List&lt;ColorScheme>();   private static Dictionary&lt;string, ColorScheme> s_colorSchemeIDs =     new Dictionary&lt;string, ColorScheme>();   private static readonly ColorScheme DefaultColorScheme =      ColorScheme.SolarizedLight;   ....   public static readonly ColorScheme SolarizedLight = new ColorScheme   {     ....   }; } <\/code><\/pre>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0441\u0440\u0435\u0434\u0438 \u044d\u0442\u0438\u0445 \u0441\u0442\u0440\u043e\u043a \u043e\u0448\u0438\u0431\u043a\u0443. \u0417\u0430\u0434\u0430\u0447\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0430, \u0432\u0435\u0434\u044c \u0437\u0430 &#171;&#8230;.&#187; \u044f \u0441\u043a\u0440\u044b\u043b \u043f\u043e\u0447\u0442\u0438 200 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043a\u0438. \u0414\u043e\u0433\u0430\u0434\u0430\u043b\u0438\u0441\u044c?<\/p>\n<p>\u0423\u0431\u0435\u0440\u0451\u043c \u0435\u0449\u0451 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430.<\/p>\n<pre><code class=\"cs\">public class ColorScheme {   private static readonly ColorScheme DefaultColorScheme =      ColorScheme.SolarizedLight;   ....   public static readonly ColorScheme SolarizedLight = new ColorScheme   {     ....   }; } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3070\/\">V3070<\/a> Uninitialized variable &#8216;SolarizedLight&#8217; is used when initializing the &#8216;DefaultColorScheme&#8217; variable. ColorScheme.cs 32<\/p>\n<p>\u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0438\u0437 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u0432\u0441\u0451 \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e. \u0412\u0441\u0451 \u0434\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u0435 <em>DefaultColorScheme<\/em> \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043d\u0435 \u0442\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u043b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442. \u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <em>DefaultColorScheme<\/em>, \u043f\u043e\u043b\u0435 <em>SolarizedLight<\/em> \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u2013 <em>null<\/em>. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0438 \u043f\u043e\u043b\u044e <em>DefaultColorScheme<\/em> \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>null<\/em>. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u043e \u044d\u0442\u043e \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043a \u0434\u0430\u043d\u043d\u043e\u0439 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0438\u0437 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 AvalonStudio \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u0430 \u043d\u0430\u0439\u0442\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a. \u042f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0432\u043d\u0435\u0441\u0451\u0442 \u0441\u0432\u043e\u0439 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0432\u043a\u043b\u0430\u0434 \u0432 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0421\u0442\u043e\u0438\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e IDE \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u0441\u0435\u0439\u0447\u0430\u0441 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u0430\u043b\u043e. \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0438\u0445 \u0441\u0442\u0430\u043d\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435. \u0422\u0430\u043a \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0441\u0440\u0435\u0434\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0435\u0431\u0435 \u043f\u043e \u0434\u0443\u0448\u0435. \u0418 \u0434\u0430\u0436\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043b\u0451\u0433\u043a\u0438\u043c \u0438 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u043e\u0434 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PVS-Studio. \u0410 \u0432 \u044d\u0442\u043e\u043c \u0432\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0431\u043d\u044b\u0439 \u043a\u043b\u044e\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u043d\u0430 \u043d\u0430\u0448\u0435\u043c <a href=\"https:\/\/pvs-studio.com\/pvs-studio\/try-free\/?utm_source=habr&amp;utm_medium=articles&amp;utm_content=avalonstudio&amp;utm_term=link_try-free\">\u0441\u0430\u0439\u0442\u0435<\/a> :).<\/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: Artem Rovenskii. <a href=\"https:\/\/pvs-studio.com\/en\/blog\/posts\/csharp\/0966\/\">Any bugs in your IDE? Checking AvalonStudio with PVS-Studio<\/a>.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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\/articles\/677174\/\"> https:\/\/habr.com\/ru\/articles\/677174\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u043c\u0438\u0440\u0443 \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0441\u0432\u043e\u0438 \u043b\u044e\u0431\u0438\u043c\u044b\u0435 IDE \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043e\u0434\u043d\u0443 \u0438\u0437 \u043d\u0438\u0445 \u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0430\u043c\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0416\u0438\u0437\u043d\u044c \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u0431\u0435\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041a \u0442\u0430\u043a\u043e\u0432\u044b\u043c \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f IDE (Integrated development environment). \u041e\u043d\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0446\u0435\u043b\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0443\u043f\u0440\u043e\u0449\u0430\u044e\u0449\u0438\u0445 \u0436\u0438\u0437\u043d\u044c. \u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0441\u0440\u0435\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440, \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044e \u043e\u0434\u043d\u0443 \u0438\u0437 IDE \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c. \u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043a\u043e\u0434\u0430 PVS-Studio. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043a\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043d\u0430 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f C, C++, C# \u0438 Java.<\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>AvalonStudio \u2013 \u044d\u0442\u043e \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u0430\u044f IDE, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u043d\u0430 C#. \u042d\u0442\u0430 \u0441\u0440\u0435\u0434\u0430 \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043f\u043e\u0434 Embedded C, C++, .NET Core, Avalonia \u0438 TypeScript. AvalonStudio \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 <a href=\"https:\/\/avaloniaui.net\/\">Avalonia UI<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b, \u043a\u0441\u0442\u0430\u0442\u0438, \u0442\u043e\u0436\u0435 <a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/csharp\/0701\/\">\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u0438<\/a>.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 AvalonStudio \u0431\u044b\u043b\u043e \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 <a href=\"https:\/\/github.com\/VitalElement\/AvalonStudio\/tree\/2ee2adbf1772c54531f0d5b0bc96a4789d6b826f\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043d\u0430 GitHub<\/a>. \u0421\u0440\u0435\u0434\u0438 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u044f \u043e\u0442\u043e\u0431\u0440\u0430\u043b \u0434\u043b\u044f \u0432\u0430\u0441 \u0441\u0430\u043c\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 :). \u041f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f!<\/p>\n<h3>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430<\/h3>\n<p>\u041a\u0430\u0436\u0434\u043e\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043e\u0434 \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043f\u0440\u0438\u043c\u0435\u0441\u044c\u044e \u043c\u043d\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0430. \u0415\u0441\u043b\u0438 \u0441 \u043a\u0430\u043a\u0438\u043c\u0438-\u043d\u0438\u0431\u0443\u0434\u044c \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u043d\u0435 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u044b, \u0442\u043e \u044f \u0441 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435\u043c \u043e\u0431\u0441\u0443\u0434\u0438\u043b \u0431\u044b \u044d\u0442\u043e \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<h4>Issue 1<\/h4>\n<pre><code class=\"cs\">private async void Timer_Tick(object sender, EventArgs e) {   ....     if (AssociatedObject.IsPointerOver)   {     var mouseDevice = (popup.GetVisualRoot() as IInputRoot)?.MouseDevice;     lastPoint = mouseDevice.GetPosition(AssociatedObject);     popup.Open();   } } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3105\/\">V3105<\/a> The &#8216;mouseDevice&#8217; variable was used after it was assigned through null-conditional operator. NullReferenceException is possible. TooltipBehavior.cs 173<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0437\u0430\u043c\u0435\u0442\u0438\u043b \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u0432 \u043a\u043e\u0434\u0435. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <em>as<\/em> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442 \u043d\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e <em>null<\/em> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e null-\u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u043b, \u0447\u0442\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 <em>as<\/em> \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c <em>null<\/em>. \u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c &#8216;?.&#8217; \u043e\u043d \u0437\u0430\u0449\u0438\u0442\u0438\u043b \u0441\u0435\u0431\u044f \u043e\u0442 <em>NullReferenceException<\/em> \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u043d\u043e \u0432\u043e\u0442 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e.<\/p>\n<h4>Issue 2<\/h4>\n<p>\u0410 \u0432\u043e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0441\u0442\u043e\u043b\u044c \u044f\u0432\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443, \u043d\u043e \u0432\u0441\u0451 \u0436\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e:<\/p>\n<pre><code class=\"cs\">private static Signature BuildSignature(IMethodSymbol symbol) {   ....   var returnTypeInfo = CheckForStaticExtension.GetReturnType(symbol);   if(returnTypeInfo.HasValue)   {     if(returnTypeInfo.Value.inbuilt)     {       signature.BuiltInReturnType = returnTypeInfo.Value.name;     }     else     {       signature.ReturnType = returnTypeInfo.Value.name;     }   }   signature.Parameters = symbol.Parameters.Select(parameter =>   {     var info = CheckForStaticExtension.GetReturnType(parameter);     ....     if(info.HasValue)     {       if(info.Value.inbuilt)       {         result.BuiltInType = info.Value.name;   \/\/ &lt;=       }       else       {         result.BuiltInType = info.Value.name;   \/\/ &lt;=       }     }     ....   }).ToList();   .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3004\/\">V3004<\/a> The &#8216;then&#8217; statement is equivalent to the &#8216;else&#8217; statement. InvocationContext.cs 400<\/p>\n<p>PVS-Studio \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b, \u0447\u0442\u043e then \u0438 else \u0432\u0435\u0442\u0432\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <em>if<\/em> \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u0434\u043d\u0438\u043c\u0435\u043c\u0441\u044f \u0447\u0443\u0442\u044c \u0432\u044b\u0448\u0435 \u043f\u043e \u043a\u043e\u0434\u0443, \u0442\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043f\u043e\u0445\u043e\u0436\u0438\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442, \u043d\u043e \u0432\u0435\u0442\u0432\u0438 \u0440\u0430\u0437\u043d\u044b\u0435. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0447\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u0432\u0435\u0442\u0432\u0435\u0439 \u043f\u0440\u043e\u0441\u0442\u043e \u043b\u0438\u0448\u043d\u044f\u044f. \u041d\u043e \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u0447\u0442\u043e \u043d\u0430 \u043c\u0435\u0441\u0442\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <em>BuiltInType<\/em> \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <em>Type<\/em>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u043e\u0433 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0430\u0432\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u0438 \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043e\u043d\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c. \u041a\u0441\u0442\u0430\u0442\u0438, \u043c\u043d\u0435 VS2022 \u0442\u043e\u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f: &#171;\u0414\u043e\u0432\u0435\u0440\u044f\u0439, \u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0439&#187;.<\/p>\n<h4>Issue 3<\/h4>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u044f \u043e\u0442\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043b, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u0431\u044b\u043b \u043d\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u0438 \u043f\u043b\u043e\u0445\u043e \u0447\u0438\u0442\u0430\u0435\u043c, \u043d\u043e \u0441\u0443\u0442\u044c \u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u0441\u0430\u043c\u043e\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043a\u043e\u0434 \u0447\u0443\u0442\u044c \u043b\u0443\u0447\u0448\u0435 \u043e\u0442\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0432\u0438\u0434\u043d\u0435\u0435.<\/p>\n<pre><code class=\"cs\">private bool CursorIsValidDeclaration(ClangCursor c) {   var result = false;    if (  (c.Kind == NClang.CursorKind.FunctionDeclaration)  \/\/ &lt;=       || c.Kind == NClang.CursorKind.CXXMethod        || c.Kind == NClang.CursorKind.Constructor        || c.Kind == NClang.CursorKind.Destructor        || c.Kind == NClang.CursorKind.FunctionDeclaration)  \/\/ &lt;=   {     result = true;   }   return result; } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3001\/\">V3001<\/a> There are identical sub-expressions &#8216;c.Kind == NClang.CursorKind.FunctionDeclaration&#8217; to the left and to the right of the &#8216;||&#8217; operator. CPlusPlusLanguageService.cs 1275<\/p>\n<p>\u041f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u043d\u0435\u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u0434\u043d\u043e \u0438\u0437 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u043f\u0440\u043e\u0441\u0442\u043e \u043b\u0438\u0448\u043d\u0435\u0435. \u0410 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438 \u0442\u0430\u043a, \u0447\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 <em>FunctionDeclaration<\/em> \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0435 :).<\/p>\n<h4>Issue 4<\/h4>\n<pre><code class=\"cs\">public override void Render(DrawingContext context) {   ....   foreach (var breakPoint in _manager?.OfType&lt;Breakpoint>().Where(....))   {     ....   }   .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3153\/\">V3153<\/a> Enumerating the result of null-conditional access operator can lead to NullReferenceException. BreakPointMargin.cs 46<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b, \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 &#8216;?.&#8217; \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 <em>null<\/em> \u0432\u043d\u0443\u0442\u0440\u0438 <em>foreach<\/em> \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430. <em>NullReferenceException<\/em> \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043d\u0430\u0441\u0442\u0438\u0433\u043d\u0435\u0442 \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043e\u0431\u0445\u043e\u0434\u0430 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438 :).<\/p>\n<p>\u0412\u043e\u043e\u0431\u0449\u0435, \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432. \u041c\u044b \u0434\u0430\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0446\u0435\u043b\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e: &#171;<a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/csharp\/0832\/\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 ?. \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<\/a>&#171;.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h4>Issue 5<\/h4>\n<pre><code class=\"cs\">public async Task&lt;(....)> LoadProject(....) {   ....   return await Task.Run(() =>   {     ....     if (   loadData.CscCommandLine != null                            \/\/ &lt;=         &amp;&amp; loadData.CscCommandLine.Count > 0)     {       ....       return (projectInfo, projectReferences, loadData.TargetPath);     }     else     {       ....       return (projectInfo, projectReferences, loadData?.TargetPath);  \/\/ &lt;=     }   }); } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3095\/\">V3095<\/a> The &#8216;loadData&#8217; object was used before it was verified against null. Check lines: 233, 262. MSBuildHost.cs 233<\/p>\n<p>\u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0434\u043e\u043b\u0433\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u0442\u0443\u0442 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442. \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>loadData<\/em> \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0432\u043d\u0430 <em>null<\/em> \u0432 \u0432\u0435\u0442\u0432\u0438 else, \u0442\u043e \u0438 \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0436\u0435 <em>if<\/em> \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u043d\u0430 <em>null<\/em>. \u0412\u043e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u043d\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 <em>loadData<\/em> \u043d\u0430 <em>null<\/em>, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435. \u0418 \u0434\u0430, \u0432 else <em>loadData<\/em> \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f. \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &#8216;?.&#8217; \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 <em>if<\/em>. \u0425\u043e\u0442\u044f, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0432 <em>return<\/em> \u043b\u0438\u0448\u043d\u0438\u0439 \u0438 \u0435\u0433\u043e \u0441\u0442\u043e\u0438\u0442 \u0443\u0431\u0440\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0443\u0442\u0430\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432.<\/p>\n<h4>Issue 6<\/h4>\n<pre><code class=\"cs\">public override void Render(DrawingContext context) {   if (_lastFrame != null &amp;&amp; !(   _lastFrame.Width == 0                                || _lastFrame.Width == 0))   {     ....   }   base.Render(context); } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3001\/\">V3001<\/a> There are identical sub-expressions &#8216;_lastFrame.Width == 0&#8217; to the left and to the right of the &#8216;||&#8217; operator. RemoteWidget.cs 308<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0434\u0432\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u043f\u043e\u0434\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0432\u0430 \u0438 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 &#8216;||&#8217;. \u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u043e\u043f\u043b\u043e\u0448\u043d\u043e\u0441\u0442\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0451\u0433\u043a\u043e\u0435: \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u0434\u043d\u043e \u0438\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 <em>Width<\/em> \u043d\u0430 <em>Height<\/em>. \u042d\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u0430\u043b\u0435\u0435 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435.<\/p>\n<h4>Issue 7<\/h4>\n<pre><code class=\"cs\">public GlobalRunSpec(....) {   ....   if (specialEntry.Value != null)   {     ....   }   RunSpec spec = new(specialOps,                      specialVariables ?? variables,                      specialEntry.Value.VariableSetup.FallbackFormat);   .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3125\/\">V3125<\/a> The &#8216;specialEntry.Value&#8217; object was used after it was verified against null. Check lines: 92, 86. GlobalRunSpec.cs 92<\/p>\n<p>PVS-Studio \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e. <em>specialEntry.Value<\/em> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e <em>null<\/em>, \u0430 \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <em>specialEntry.Value<\/em> \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u0432\u043e\u0451 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<h4>Issue 8<\/h4>\n<pre><code class=\"cs\">private static StyledText InfoTextFromCursor(ClangCursor cursor) {   ....   if (cursor.ResultType != null)   {     result.Append(cursor.ResultType.Spelling + \" \",                   IsBuiltInType(cursor.ResultType) ? theme.Keyword                                                     : theme.Type);   }   else if (cursor.CursorType != null)   {     switch (kind)     {       ....     }     result.Append(cursor.CursorType.Spelling + \" \",                   IsBuiltInType(cursor.ResultType) ? theme.Keyword   \/\/ &lt;=                                                    : theme.Type);   }   .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3022\/\">V3022<\/a> Expression &#8216;IsBuiltInType(cursor.ResultType)&#8217; is always false. CPlusPlusLanguageService.cs 1105<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0441\u0447\u0438\u0442\u0430\u0435\u0442, \u0447\u0442\u043e <em>IsBuiltInType(cursor.ResultType)<\/em> \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u0435\u0440\u043d\u0451\u0442 <em>false<\/em>. \u041c\u0435\u0442\u043e\u0434 <em>IsBuiltInType<\/em> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 else-\u0432\u0435\u0442\u043a\u0435, \u0437\u043d\u0430\u0447\u0438\u0442 <em>cursor.ResultType<\/em> \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>null<\/em>.<\/p>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 <em>IsBuiltInType<\/em> \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0440\u0430\u0432\u0435\u043d <em>null<\/em>, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f <em>false<\/em>.<\/p>\n<pre><code class=\"cs\">private static bool IsBuiltInType(ClangType cursor) {   var result = false;   if (cursor != null &amp;&amp; ....)   {     return true;   }   return result; } <\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e <em>IsBuiltInType(cursor.ResultType)<\/em> \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c <em>false<\/em>.<\/p>\n<p>\u0425\u043c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0436\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e? \u0422\u0443\u0442 \u044f\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 copy-paste. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043b \u043f\u043e\u0445\u043e\u0436\u0438\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0432\u044b\u0448\u0435. \u0412\u043e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 <em>cursor.ResultType<\/em> \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 <em>cursor.CursorType<\/em> \u0437\u0430\u0431\u044b\u043b.<\/p>\n<h4>Issue 9<\/h4>\n<pre><code class=\"cs\">private int BuildCompletionsForMarkupExtension(....) {   ....   if (t.SupportCtorArgument == MetadataTypeCtorArgument.HintValues)   {     ....   }   else if (attribName.Contains(\".\"))   {     if (t.SupportCtorArgument != MetadataTypeCtorArgument.Type)     {       ....       if (   mType != null            &amp;&amp; t.SupportCtorArgument ==              MetadataTypeCtorArgument.HintValues)        \/\/ &lt;=       {         var hints = FilterHintValues(....);         completions.AddRange(hints.Select(.....));       }       ....     }     } } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3022\/\">V3022<\/a> Expression &#8216;mType != null &amp;&amp; t.SupportCtorArgument == MetadataTypeCtorArgument.HintValues&#8217; is always false. CompletionEngine.cs 601<\/p>\n<p>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e <em>SupportCtorArgument<\/em> \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f. \u042d\u0442\u043e<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-393312","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/393312","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=393312"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/393312\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=393312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=393312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=393312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}