VCCLCompilerTool.AdditionalOptions プロパティ

コマンド ラインの末尾、ファイル名の直前に追加するオプションを取得または設定します。 たとえば、あるオプションがオブジェクト モデルでサポートされない場合に指定します。

名前空間:  Microsoft.VisualStudio.VCProjectEngine
アセンブリ:  Microsoft.VisualStudio.VCProjectEngine (Microsoft.VisualStudio.VCProjectEngine.dll 内)

構文

'宣言
Property AdditionalOptions As String
string AdditionalOptions { get; set; }
property String^ AdditionalOptions {
    String^ get ();
    void set (String^ value);
}
abstract AdditionalOptions : string with get, set
function get AdditionalOptions () : String 
function set AdditionalOptions (value : String)

プロパティ値

型 : String
コマンド ラインの末尾、ファイル名の直前に追加するオプション。

EnablePREfast プロパティおよび AdditionalOptions プロパティを使用して /analyze:WX- スイッチを設定する方法を次の例に示します。いずれのプロパティも、これを行う必要があります。/analyze:WX- を指定することは、コード分析警告が /WX を指定したコンパイルではエラーとして扱われないことを意味します。 詳細については、「/analyze (コード分析)」を参照してください。

この例を実行するには、「方法 : オートメーション オブジェクト モデルのコード例をコンパイルおよび実行する」の説明に従ってコードを入力し、実行します。 次に、Visual Studio の新しいインスタンスで、Visual C++ プロジェクトを読み込み、アドイン マネージャーを使用してアドインをアクティブにします。

' 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 セキュリティ

  • 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

関連項目

VCCLCompilerTool インターフェイス

Microsoft.VisualStudio.VCProjectEngine 名前空間