Aracılığıyla paylaş


VCCLCompilerTool.EnablePREfast Özellik

Alır veya yerel kod çözümleme etkinleştirilip etkinleştirilmediğini belirler.

Ad alanı:  Microsoft.VisualStudio.VCProjectEngine
Derleme:  Microsoft.VisualStudio.VCProjectEngine (Microsoft.VisualStudio.VCProjectEngine.dll içinde)

Sözdizimi

'Bildirim
Property EnablePREfast As Boolean
bool EnablePREfast { get; set; }
property bool EnablePREfast {
    bool get ();
    void set (bool value);
}
abstract EnablePREfast : bool with get, set
function get EnablePREfast () : boolean
function set EnablePREfast (value : boolean)

Özellik Değeri

Tür: System.Boolean
true kod çözümleme etkinleştirmek için (/analyze).

Notlar

Ek seçenekler kullanılarak ayarlanabilir AdditionalOptions özelliği.

[!NOT]

/analyzeyalnızca x 86 derleyiciler Enterprise (Geliştirici ekibi) sürümleri için kullanılabilir.

Örnekler

Aşağıdaki örnek, nasıl kullanılacağını gösterir EnablePREfast ve AdditionalOptions özelliklerini ayarlamak için /analyze:WX- geçin.(Her iki özelliği de bunu yapmak için gereklidir.) Belirtme /analyze:WX- kod çözümleme uyarılar anlamına gelir değil işleneceğini hataları olarak ile derlerken /WX.Daha fazla bilgi için bkz. /analyze (Kod Çözümleme).

Bu örneği çalıştırmak için girin ve ana hatları gibi bu örneği çalıştırmak için Nasıl yapılır: derlemek ve Otomasyon nesne modeli kod örneklerini çalıştırmak.Sonra yeni bir örneğini Visual Studio, yük bir Visual C++ proje ve eklenti etkinleştirmek için Eklenti Yöneticisi'ni kullanın.

' Add reference to Microsoft.VisualStudio.VCProjectEngine.
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics
Imports Microsoft.VisualStudio.VCProjectEngine
Imports System.Text

Sub EnablePREfastExample(ByVal dte As DTE2)
    Dim prj As VCProject
    Dim cfgs, tools As IVCCollection
    Dim cfg As VCConfiguration
    Dim tool As VCCLCompilerTool
    Dim sb As New StringBuilder

    prj = CType(dte.Solution.Projects.Item(1).Object, _
      Microsoft.VisualStudio.VCProjectEngine.VCProject)
    cfgs = CType(prj.Configurations, _
      Microsoft.VisualStudio.VCProjectEngine.IVCCollection)
    cfg = CType(cfgs.Item(1), _
      Microsoft.VisualStudio.VCProjectEngine.VCConfiguration)
    tool = CType(cfg.Tools("VCCLCompilerTool"), _
      Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool)

    sb.Length = 0
    sb.Append("Current project PREfast setting: " _
      & tool.EnablePREfast & Environment.NewLine)
    sb.Append("Flag: " & tool.AdditionalOptions)
    MsgBox(sb.ToString)

    ' Toggle PREfast setting.
    If Not (tool.EnablePREfast = True) Then
        ' PREfast is not enabled. Turn it and the WX- flag on.
        tool.EnablePREfast = True
        tool.AdditionalOptions = "/analyze:WX-"
    Else
        ' Toggle the opposite.
        tool.EnablePREfast = False
        tool.AdditionalOptions = "/analyze:WX"
    End If
    sb.Length = 0
    sb.Append("New project PREfast setting: " _
      & tool.EnablePREfast & Environment.NewLine)
    sb.Append("Flag: " & tool.AdditionalOptions)
    MsgBox(sb.ToString)
End Sub
// Add references to Microsoft.VisualStudio.VCProjectEngine and 
// System.Windows.Forms.
using System;
using Extensibility;
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.VCProjectEngine;
using System.Text;
using System.Windows.Forms;

public void EnablePREfastExample(DTE2 dte)
{
    try
    {
        VCProject prj;
        IVCCollection cfgs, tools;
        VCConfiguration cfg;
        VCCLCompilerTool tool;
        StringBuilder sb = new StringBuilder();

        prj = (Microsoft.VisualStudio.VCProjectEngine.VCProject)
          dte.Solution.Projects.Item(1).Object;
        cfgs = 
          (Microsoft.VisualStudio.VCProjectEngine.IVCCollection)
          prj.Configurations;
        cfg = 
          (Microsoft.VisualStudio.VCProjectEngine.VCConfiguration)
           cfgs.Item(1);
        tools = 
          (Microsoft.VisualStudio.VCProjectEngine.IVCCollection)
          cfg.Tools;
        tool = 
          (Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool)
          tools.Item("VCCLCompilerTool");
                                
        sb.Length = 0;
        sb.Append("Current project PREfast setting: " +
          tool.EnablePREfast + Environment.NewLine);
        sb.Append("Flag: " + tool.AdditionalOptions);
        MessageBox.Show(sb.ToString());

        // Toggle PREfast setting.
        if (!(tool.EnablePREfast == true))
        {
            // PREfast is not enabled. Turn it and the WX- flag on.
            tool.EnablePREfast = true;
            tool.AdditionalOptions = "/analyze:WX-";
        }
        else
        {
            // Toggle the opposite.
            tool.EnablePREfast = false;
            tool.AdditionalOptions = "/analyze:WX";
        }
        sb.Length = 0;
        sb.Append("New project PREfast setting: " +
          tool.EnablePREfast + Environment.NewLine);
        sb.Append("Flag: " + tool.AdditionalOptions);
        MessageBox.Show(sb.ToString());
    }
    catch (System.Exception errmsg)
    {
        MessageBox.Show("ERROR! " + errmsg.Message);
    }
}

.NET Framework Güvenliği

Ayrıca bkz.

Başvuru

VCCLCompilerTool Arabirim

Microsoft.VisualStudio.VCProjectEngine Ad Alanı

Diğer Kaynaklar

/analyze (Kod Çözümleme)