使用Visual Studio代码并使用定义的符号 [英] Using Visual Studio Code and using defined symbols

查看:73
本文介绍了使用Visual Studio代码并使用定义的符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编辑了整个问题,因为这不仅适用于Unity3D,而且适用于所有.sln项目.

I have edited the whole question, since this is not only for Unity3D, but at all .sln projects.

我安装了Visual Studio Code(不是Visual Studio,但这是: https://code.visualstudio.com/)在我的Macbook上工作.否则,VSCode在普通项目和Unity3D项目中都可以正常工作.我在所有类上都获得了Intellisense,包括Unity3D特定类,例如GameObject.所以我认为我的安装和启动顺序正确.

I have a installation of Visual Studio Code(Not Visual Studio, but this:https://code.visualstudio.com/) on my Macbook at work. VSCode is otherwise working just fine with normal and Unity3D projects. I get Intellisense on all classes, including Unity3D specific ones, like GameObject. So I think my installation and startup sequence is correct.

我唯一的问题是,VSCode似乎无法识别.csproj文件中定义的常量.首先,我通过一些Unity3D插件注意到了这一点,但是它在普通的Visual Studio项目中也是持久的.

Only problem I have, is that VSCode does not seem to recognize constants defined in the .csproj files. First I noticed this with some Unity3D plugins, but it is persistent on normal Visual Studio projects too.

我的示例项目是一个从Internet下载的虚拟应用程序,但是在MonoDevelop上可以正常使用.这是我的代码

My sample project is a dummy application downloaded from internet, but it is fully working on MonoDevelop. This is my code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DummyConsoleApplication
    {
    class Program
        {
            static void Main(string[] args)
            {
                tester();
            }

            #if DEBUG
            static void tester(){

            }
            #endif
        }
    }

Main中的函数调用在编辑器上导致未找到异常,但由于.csproj文件具有以下行,因此编译良好:

The function call in Main causes a not found exception on the editor, but it compiles fine, since the .csproj file has this line:

<DefineConstants>DEBUG;TRACE</DefineConstants>

对于这是否是VSCode的正常行为的任何验证,将不胜感激.另外,如果有人知道任何解决方案,即使是骇人听闻的解决方案,也可以克服此错误并强制Intellisense自动完成,这也会有所帮助.

Any verification on if this is normal behaviour for VSCode would be greately appreciated. Also, if anyone is aware of any solution, even hacky ones, to get past this bug and force Intellisense to autocomplete would help out too.

我得到的错误是:

The name 'tester' does not exist in the current context [DummyConsoleApplication]

我的硬件是装有优胜美地的Macbook,编译器是dnx-mono.1.0.0-beta4.

My hardware is a Macbook with Yosemite and my compiler is dnx-mono.1.0.0-beta4.

推荐答案

这是 OmniSharp 的已知限制.,Visual Studio Code是内置的C#引擎.有一个打开增强请求,用于添加< DefineConstants> 支持,但与 MSBuild支持相关的一个较大问题

This is a known limitation with OmniSharp, the C# engine that Visual Studio Code is built around. There is an open enhancement request for adding <DefineConstants> support, but it is tied to a larger issue with regards to MSBuild Support.

当前,Visual Studio Code不支持此配置.您可以尝试通过 launch.json 定义常量,但最多只能提供很少的支持.

Currently, this isn't a supported configuration under Visual Studio Code. You can try to define your constants through the launch.json instead, but support is minimal at best.

这篇关于使用Visual Studio代码并使用定义的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆