在VSIX Visual Studio中,可扩展性如何获得函数的参数是'ref','out'还是值类型

问题描述 投票:0回答:1

我在其中运行VSIX的项目中的功能是这个;

        public void Method1(string name, out int age)
        {
            age = 0;
            int g1 = 0;
            //
            int g = 0;
        }

并且要通过功能参数的VSIX项目代码为

//  Here 'codeElement' is the Function Having Parameters.
                    foreach (CodeElement codeElement2 in codeElement.Children)
                    {
                        if (codeElement2.Kind == vsCMElement.vsCMElementParameter)
                        {
                            string parameterName = codeElement2.Name;
                            string parameterDataType = ((CodeParameter)codeElement2).Type.AsString;
                            VsShellUtilities.ShowMessageBox(
                                this.package,
                                ">>>>>" + " : " + parameterName + " : " + parameterDataType,
                                "MESSAGE...",
                                OLEMSGICON.OLEMSGICON_INFO,
                                OLEMSGBUTTON.OLEMSGBUTTON_OK,
                                OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                        }
                    }

此代码可以正常工作,它给出了参数的名称及其数据类型。

如何获取参数是'out','ref'还是值类型?

((就像Method1中的参数'age'是'out')] >>

我在其中运行VSIX的项目中的功能是这样;公共无效Method1(字符串名称,超出int年龄){age = 0; int g1 = 0; // int g = 0; ...

c# visual-studio visual-studio-extensions vs-extensibility
1个回答
0
投票

使用包含更多信息的CodeParameter2界面:

© www.soinside.com 2019 - 2024. All rights reserved.