[] Finally! PVS-Studio Supports .NET 5 Projects
Автор
Сообщение
news_bot ®
Стаж: 6 лет 9 месяцев
Сообщений: 27286
On November 10th, 2020, Microsoft released a new version of .NET Core - .NET 5. The updated platform presents many new enhancements. For example, it allows C# developers to use features the new C# 9 offers: records, relational pattern matching, etc. Unfortunately, there was a disadvantage: PVS-Studio could not analyze these projects. However (and here's the good news)... That used to be the case. Our next release, PVS-Studio 7.13, will support projects that target .NET 5.
Aka .NET Core 4.NET 5 is the next step after .NET Core 3.1. We can see that Microsoft changed the name from .NET Core to .NET. This is to show that they will focus on this platform further on. Microsoft basically confirmed this on their official website – they've already posted three preview versions of .NET 6 there. But why did the version number go from 3.1 to 5? This does not seem surprising - remember how Windows 10 followed Windows 8.1? :) In fact, Microsoft skipped number 4 to avoid confusion between .NET Framework and .NET. However, "Entity Framework Core 5.0", based on .NET 5, will keep its "Core" postfix. Otherwise, it would not be possible to differentiate between Core and Framework versions of "Entity Framework 5.0"..NET 5 supplies developers with many new tools. For example, C# now offers an enhanced pattern matching mechanism. Then there is this unusual and interesting feature that enables you to write code outside of functions or classes. Not every developer needs this capability, but it's bound to attract some fans. A full list of C# 9 enhancements is available on Microsoft's official website.You can read about new features in .NET 5 here.PVS-Studio and .NET 5We received many requests from our clients to support .NET 5 projects. We also understood that the analyzer must support the latest innovations. However, although important, new .NET versions are not PVS-Studio's only direction for development. This is why it took us a while to present our new version that supports .NET 5 projects.The upgrade concerns our analyzer versions for Windows, Linux and macOS. PVS-Studio for Windows still requires .NET Framework 4.7.2. On Linux and macOS, the analyzer now requires .NET 5. Previously, .NET Core 3.1 was sufficient.Why did we switch the analyzer for Linux and macOS to .NET 5?Our initial plan was to switch the analyzer from .NET Core 3.1 to .NET 5 at a later time. However, this had to change when we encountered a problem. When analyzing projects for .NET Core or .NET 5, PVS-Studio actively interacts with the corresponding version's SDK. The tricky thing is, .NET 5 SDK libraries depend on the .NET 5 version's "System.Runtime" library. Meanwhile, if the analyzer targets .NET Core 3.1, it loads the 3.1 version's "System.Runtime" library. As a result, we kept getting a conflict - the analyzer could not interact with the SDK library, and the analysis was not possible.Switching from .NET Core to .NET 5 completely resolved this problem. Instantaneous EnhancementsTo support .NET 5 project analysis we needed to update some dependencies. Specifically, PVS-Studio now uses newer Roslyn and MSBuild versions. This enables the analyzer to process code, that uses C# 9 features, correctly. For example, the code below could trigger false warnings:
user = user with { Name = "Bill" }
The analyzer did not have any information about WithExpression - and thus could not process this code correctly. As a result, the analyzer issued a warning that the user variable was assigned to itself. Of course, the analysis report also contained a warning that the analyzer did not support this project. However, the latter did not make things easier. :( Luckily, the new update fixed the problem automatically. Other problems we had to fix manually.Problems with New VersionsTo stay up-to-date, the static analyzer needs to adapt to new language versions. The analyzer's developers cannot foresee all features a language may get in the future. To support a new language version, the analyzer needs more than just correct parsing and semantics structure. The analyzer's developers also need to review the tool's code, evaluate the use of various internal technologies and diagnostic rules. The analyzer will likely require additional changes after a new language version comes out.One of the new - and problematic - C# features is top-level statements. When working on the C# analyzer, we expected that local variables, conditions, loops, etc. are always inside methods. Now that you can write C# code even without declaring a class... Obviously, this is something very interesting, but it creates some problems for us. Though we doubt that all developers will start to write all code outside of classes. :)Another new feature that prompted us to change our tool's code is the init accessor. We had to rework the V3140 diagnostic rule.The rule is triggered when a property's accessors use different internal variables. The code sample below (from the RunUO Check article) triggers this diagnostic:
private bool m_IsRewardItem;
[CommandProperty( AccessLevel.GameMaster )]
public bool IsRewardItem
{
get{ return m_IsRewardItem; }
set{ m_IsRewardItem = value; InvalidateProperties(); }
}
private bool m_East;
[CommandProperty( AccessLevel.GameMaster )]
public bool East // <=
{
get{ return m_East; }
set{ m_IsRewardItem = value; InvalidateProperties(); }
}
PVS-Studio warns: V3140 Property accessors use different backing fields. WallBanner.cs 77When writing the V3140 diagnostic, we assumed that a property can have only two accessors - get and set. The new init accessor went outside this expectation. This did not just cause the diagnostic's incorrect operation - the diagnostic kept crashing and throwing an exception! Luckily, we caught this problem when testing - and fixed it successfully.
Can't Wait for the Release?You do not have to wait! Of course, now it's not too long before the release, but still... Don't you want to try the new version as soon as possible? No problem - we are eager to help! Go to the feedback page and request the new version. We'll try to respond as soon as possible - which means soon you can analyze your (and not yours only) .NET 5 projects!We also encourage you to share your experience with PVS-Studio. Whatever your experience with the analyzer, we would like to know about it. After all, it is largely thanks to user reviews that PVS-Studio develops and becomes better.
===========
Источник:
habr.com
===========
Похожие новости:
- [.NET, C#, Unity, Игры и игровые приставки, Интервью] Как проходить собеседования на Unity разработчика
- [C++, C, C#] Алгоритмы аллокации памяти, автономное зрение и специфика работы в модели Software House
- [.NET, C#] Скриптинг в C# или динамическое выполнение в runtime
- [Разработка веб-сайтов, Программирование, .NET, Тестирование веб-сервисов] Как я решил протестировать нагрузочную способность web сервера
- [IT-инфраструктура, API, Облачные сервисы, Kubernetes] Масштабирование Kubernetes в Pinterest: через сбои и аварии (перевод)
- [.NET, C#] Добавляем CRUD в ASP.NET Core проект за 10 минут с помощью EasyData
- [Python, Xcode, Swift, Машинное обучение] Запускаем модель машинного обучения на iPhone (перевод)
- [Информационная безопасность, Разработка веб-сайтов, PHP, Программирование] Слабые места PHP: думай как хакер
- [Разработка игр, C#, Unity] Судно на воздушной подушке на Unity 3D
- [Совершенный код, C#] Комментарии — ложь
Теги для поиска: #_.net, #_core, #_framework, #_c#, #_blog_kompanii_pvsstudio (
Блог компании PVS-Studio
)
Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете голосовать в опросах
Вы не можете прикреплять файлы к сообщениям
Вы не можете скачивать файлы
Текущее время: 22-Ноя 14:39
Часовой пояс: UTC + 5
Автор | Сообщение |
---|---|
news_bot ®
Стаж: 6 лет 9 месяцев |
|
On November 10th, 2020, Microsoft released a new version of .NET Core - .NET 5. The updated platform presents many new enhancements. For example, it allows C# developers to use features the new C# 9 offers: records, relational pattern matching, etc. Unfortunately, there was a disadvantage: PVS-Studio could not analyze these projects. However (and here's the good news)... That used to be the case. Our next release, PVS-Studio 7.13, will support projects that target .NET 5. Aka .NET Core 4.NET 5 is the next step after .NET Core 3.1. We can see that Microsoft changed the name from .NET Core to .NET. This is to show that they will focus on this platform further on. Microsoft basically confirmed this on their official website – they've already posted three preview versions of .NET 6 there. But why did the version number go from 3.1 to 5? This does not seem surprising - remember how Windows 10 followed Windows 8.1? :) In fact, Microsoft skipped number 4 to avoid confusion between .NET Framework and .NET. However, "Entity Framework Core 5.0", based on .NET 5, will keep its "Core" postfix. Otherwise, it would not be possible to differentiate between Core and Framework versions of "Entity Framework 5.0"..NET 5 supplies developers with many new tools. For example, C# now offers an enhanced pattern matching mechanism. Then there is this unusual and interesting feature that enables you to write code outside of functions or classes. Not every developer needs this capability, but it's bound to attract some fans. A full list of C# 9 enhancements is available on Microsoft's official website.You can read about new features in .NET 5 here.PVS-Studio and .NET 5We received many requests from our clients to support .NET 5 projects. We also understood that the analyzer must support the latest innovations. However, although important, new .NET versions are not PVS-Studio's only direction for development. This is why it took us a while to present our new version that supports .NET 5 projects.The upgrade concerns our analyzer versions for Windows, Linux and macOS. PVS-Studio for Windows still requires .NET Framework 4.7.2. On Linux and macOS, the analyzer now requires .NET 5. Previously, .NET Core 3.1 was sufficient.Why did we switch the analyzer for Linux and macOS to .NET 5?Our initial plan was to switch the analyzer from .NET Core 3.1 to .NET 5 at a later time. However, this had to change when we encountered a problem. When analyzing projects for .NET Core or .NET 5, PVS-Studio actively interacts with the corresponding version's SDK. The tricky thing is, .NET 5 SDK libraries depend on the .NET 5 version's "System.Runtime" library. Meanwhile, if the analyzer targets .NET Core 3.1, it loads the 3.1 version's "System.Runtime" library. As a result, we kept getting a conflict - the analyzer could not interact with the SDK library, and the analysis was not possible.Switching from .NET Core to .NET 5 completely resolved this problem. Instantaneous EnhancementsTo support .NET 5 project analysis we needed to update some dependencies. Specifically, PVS-Studio now uses newer Roslyn and MSBuild versions. This enables the analyzer to process code, that uses C# 9 features, correctly. For example, the code below could trigger false warnings: user = user with { Name = "Bill" }
private bool m_IsRewardItem;
[CommandProperty( AccessLevel.GameMaster )] public bool IsRewardItem { get{ return m_IsRewardItem; } set{ m_IsRewardItem = value; InvalidateProperties(); } } private bool m_East; [CommandProperty( AccessLevel.GameMaster )] public bool East // <= { get{ return m_East; } set{ m_IsRewardItem = value; InvalidateProperties(); } } Can't Wait for the Release?You do not have to wait! Of course, now it's not too long before the release, but still... Don't you want to try the new version as soon as possible? No problem - we are eager to help! Go to the feedback page and request the new version. We'll try to respond as soon as possible - which means soon you can analyze your (and not yours only) .NET 5 projects!We also encourage you to share your experience with PVS-Studio. Whatever your experience with the analyzer, we would like to know about it. After all, it is largely thanks to user reviews that PVS-Studio develops and becomes better. =========== Источник: habr.com =========== Похожие новости:
Блог компании PVS-Studio ) |
|
Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете голосовать в опросах
Вы не можете прикреплять файлы к сообщениям
Вы не можете скачивать файлы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете голосовать в опросах
Вы не можете прикреплять файлы к сообщениям
Вы не можете скачивать файлы
Текущее время: 22-Ноя 14:39
Часовой пояс: UTC + 5