C# IDE SharpDevelop的一些缺陷

写这篇文章的目的就是要告诉你,趁早放弃SharpDevelop,别在它上面浪费时间!

1.不支持64bit程序的调试。
在项目名称上右键>属性>生成>目标CPU里面,只有设成Any processor (prefer 32-bit)或32位Intel兼容处理器,才能进行调试。
如果设成Any processor (prefer 64-bit)或AMD/Intel 64位处理器,就会提示“不能启动进程。不支持该请求。(Exception from HRESULT: 0x80070032)
64-bit debugging is not supported.  Please set Project -> Project Options... -> Compiling -> Target CPU to 32bit.”
如果设成Intel64位处理器,就会提示“不能启动进程。不是有效的 Win32 应用程序。 (Exception from HRESULT: 0x800700C1)”.




2.界面容易变花。
下面这段代码会有运行时错误
using System;
namespace t1
{
	class Program
	{
		public static void Main(string[] args)
		{
			int a=12;
			Console.WriteLine("{a}",a); //这一行有错误
			Console.Write("Press any key to continue . . . ");
			Console.ReadKey(true);
		}
	}
}

未处理的异常,抛出了类型为System.FormatException的异常:
System.FormatException: 输入字符串的格式不正确。
   在 System.Text.StringBuilder.FormatError()
   在 System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
   在 System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
   在 System.String.Format(IFormatProvider provider, String format, Object arg0)
   在 System.IO.TextWriter.WriteLine(String format, Object arg0)
   在 System.IO.TextWriter.SyncTextWriter.WriteLine(String format, Object arg0)
   在 System.Console.WriteLine(String format, Object arg0)
   在 t1.Program.Main(String[] args) 位置 e:\CSharp\test\t1\t1\Program.cs:行号 9

点了终止按钮后,SharpDevelop的界面很容易变花,要把窗体拖动一下才能恢复正常。虽然不是100%会变花,但是出现的概率相当高,已经严重影响正常使用了。




3.不支持C# 6.0的新特性。
比如不能用static声明静态类的引用。
从C# 6.0开始,using static后可以访问类型的静态成员,而无需限定使用类型名称进行访问,比如Console.WriteLine可以简写成WriteLine,如下
using static System.Console;   
using static System.Math;  
class Program   
{   
    static void Main()   
    {   
        WriteLine(Sqrt(3*3 + 4*4));   
    }   
}

而sharpdevelop会报错:
应输入标识符;“static”是关键字 (CS1041)
应输入 class、delegate、enum、interface 或 struct (CS1518)

sharpdevelop也不支持美元符号$,下面是微软官网给的一个例子(https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/interpolated-strings),sharpdevelop会报“意外的字符“$” (CS1056)”
using System;
public class Example
{
   public static void Main()
   {
      var name = "Horace";
      var age = 34;
      var s1 = $"He asked, \"Is your name {name}?\", but didn't wait for a reply.";
      Console.WriteLine(s1);
      
      var s2 = $"{name} is {age:D3} year{(age == 1 ? "" : "s")} old.";
      Console.WriteLine(s2); 
   }
}


关于C#6.0的讨论可以看看sharpdevelop的官方论坛:
http://community.sharpdevelop.net/forums/t/22341.aspx

(hammil) Is there any way to enable C# 6.0 in the editor, or even just in the compiler?
If not, is there a roadmap for this feature?

(ChristophWille) We would need to adapt NRefactory 5 for this - so far no one volunteered to do that.

(MattWard) Currently SharpDevelop does not support compiling using MSBuild 14. It will only use up to MSBuild 12 which does not support C# 6. You can hack around this by adding the following to your project file:
 <CscToolPath>$(MSBuildProgramFiles32)\MSBuild\14.0\Bin</CscToolPath>
This will allow your project to compile and use C# 6 features but you will see errors in the text editor since it does not understand C#6 syntax.
------
网上还有人推荐MonoDevelop作为C#的IDE, 然而MonoDevelop for Windows is available from source only,Please refer to the building guide for more information about how to install and configure your MonoDevelop.下面的这些步骤足以把新手给折腾死。
(building guide:)
    Install Gtk# (installer).
    Install the Mono libraries package (installer)
    Install Visual Studio 2017 with the .NET Desktop and .NET Core workloads and the F# optional component (note, F# is disabled by default so need to enable it in the VS installer).
    Install Git for Windows (from here)
    Install GNU Gettext tools (from here)
    Get MonoDevelop from GitHub.

Building using Visual Studio or MonoDevelop

You need at least Visual Studio 2017 or MonoDevelop 7.1  

    git clone https://github.com/mono/monodevelop --recursive
    Open main/Main.sln.
    Select the DebugWin32 configuration (this is important!).
    Build the solution.

Building using MSBuild

Open a Command Prompt in main and run winbuild.bat. You can easily run MD directly after building with the winbuild.bat script (run monodevelop\main\build\bin\monodevelop.exe).
------
JetBrains出品的Rider也是C#的IDE,JetBrains公司的实力还是很强的,IntelliJ IDEA和PyCharm等知名软件就是JetBrains开发的。不过Rider是收费而且昂贵的($349),有30天的试用期。
------
所以,C#的开发还是用Visual Studio (Community)吧。Visual Studio除了占用硬盘空间过大,其它方面几乎是无可挑剔的。

猜你喜欢

转载自blog.csdn.net/pijianzhirui/article/details/79491429
IDE