官术网_书友最值得收藏!

  • Roslyn Cookbook
  • Manish Vasani
  • 192字
  • 2021-07-15 17:07:34

Creating a compilation analyzer to analyze whole compilation and report issues

A stateful compilation analyzer registers action callbacks that require compilation-wide analysis of symbols and/or syntax to report issues about declarations or executable code in the compilation. These analyzers generally need to initialize some mutable state at the start of the analysis, which is updated while analyzing the compilation, and the final state is used to report diagnostics.

In this section, we will create an analyzer that performs compilation-wide analysis and reports. Diagnostic secure types must not implement interfaces with insecure methods for the following scenarios:

  • Assume we have an interface, say MyNamespace.ISecureType, which is a well-known secure interface, i.e. it is a marker for all secure types in an assembly.
  • Assume we have a method attribute, say MyNamespace.InsecureMethodAttribute, which marks the method on which the attribute is applied as insecure. An interface which has any member with such an attribute, must be considered insecure.
  • We want to report diagnostics for types implementing the well-known secure interface that also implements any insecure interfaces.

Analyzer performs compilation-wide analysis to detect such violating types and reports diagnostics for them in the compilation end action.

主站蜘蛛池模板: 寿光市| 莱西市| 云阳县| 砚山县| 沽源县| 东山县| 车险| 年辖:市辖区| 岳阳县| 金昌市| 武平县| 浮梁县| 肥东县| 浦县| 白沙| 大港区| 吉水县| 古田县| 济阳县| 东乌珠穆沁旗| 恩施市| 安化县| 竹溪县| 大冶市| 新沂市| 定州市| 环江| 泽库县| 阿合奇县| 贵南县| 乌什县| 横山县| 阳春市| 密云县| 朝阳市| 旬邑县| 雅安市| 双峰县| 唐山市| 永顺县| 密山市|