Browse Source

Fixed SD2-994: Public static classes not converted correctly from C# to VB.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1738 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
1b5d91cd34
  1. 85
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetBindingExecutionManager.cs
  2. 96
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/VbcEncodingFixingLogger.cs
  3. 9
      src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.addin
  4. 3
      src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj
  5. 6
      src/Libraries/NRefactory/Project/Src/Visitors/ToVBNetConvertVisitor.cs
  6. 10
      src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBConverterTest.cs
  7. 2
      src/Tools/Tools.build

85
src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetBindingExecutionManager.cs

@ -1,85 +0,0 @@ @@ -1,85 +0,0 @@
//// <file>
//// <copyright see="prj:///doc/copyright.txt"/>
//// <license see="prj:///doc/license.txt"/>
//// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
//// <version value="$version"/>
//// </file>
//
//using System;
//using System.IO;
//using System.Diagnostics;
//using System.Collections;
//using System.Reflection;
//using System.Resources;
//using System.Windows.Forms;
//using System.Xml;
//using System.CodeDom.Compiler;
//using System.Threading;
//
//using ICSharpCode.SharpDevelop.Project;
//using ICSharpCode.SharpDevelop.Gui;
//using ICSharpCode.Core;
//
//namespace CSharpBinding
//{
// /// <summary>
// /// This class describes the main functionalaty of a language codon
// /// </summary>
// public class CSharpBindingExecutionManager
// {
// public void Execute(string filename, bool debug)
// {
// }
//
// public void Execute(IProject project, bool debug)
// {
// CSharpCompilerParameters parameters = (CSharpCompilerParameters)project.ActiveConfiguration;
//
//
// string directory = FileUtility.GetDirectoryNameWithSeparator(((CSharpCompilerParameters)project.ActiveConfiguration).OutputDirectory);
// string exe = ((CSharpCompilerParameters)project.ActiveConfiguration).OutputAssembly + ".exe";
// string args = ((CSharpCompilerParameters)project.ActiveConfiguration).CommandLineParameters;
//
//
// bool customStartup = false;
// ProcessStartInfo psi;
// if (parameters.ExecuteScript != null && parameters.ExecuteScript.Length > 0) {
// customStartup = true;
// psi = new ProcessStartInfo("\"" + parameters.ExecuteScript + "\"", args);
// } else {
// if (parameters.CompileTarget == CompileTarget.Library) {
//
// MessageService.ShowError("${res:BackendBindings.ExecutionManager.CantExecuteDLLError}");
// return;
// }
//
// string runtimeStarter = String.Empty;
//
// switch (parameters.NetRuntime) {
// case NetRuntime.Mono:
// runtimeStarter = "mono ";
// break;
// case NetRuntime.MonoInterpreter:
// runtimeStarter = "mint ";
// break;
// }
//
// if (parameters.CompileTarget != CompileTarget.WinExe && parameters.PauseConsoleOutput) {
// psi = new ProcessStartInfo(Environment.GetEnvironmentVariable("ComSpec"), "/c " + runtimeStarter + "\"" + directory + exe + "\" " + args + " & pause");
// } else {
// psi = new ProcessStartInfo(runtimeStarter + "\"" + directory + exe + "\"");
// psi.Arguments = args;
// }
// }
//
// psi.WorkingDirectory = Path.GetDirectoryName(directory);
// psi.UseShellExecute = false;
// DebuggerService DebuggerService = (DebuggerService)ServiceManager.Services.GetService(typeof(DebuggerService));
// if (debug && !customStartup) {
// DebuggerService.Start(Path.Combine(directory, exe), directory, args);
// } else {
// DebuggerService.StartWithoutDebugging(psi);
// }
// }
// }
//}

96
src/AddIns/BackendBindings/VBNetBinding/Project/Src/VbcEncodingFixingLogger.cs

@ -0,0 +1,96 @@ @@ -0,0 +1,96 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
using Microsoft.Build.Framework;
using ICSharpCode.SharpDevelop.Dom;
namespace VBNetBinding
{
/*
public class VbcEncodingFixingLogger : IMSBuildAdditionalLogger
{
public ILogger CreateLogger(MSBuildEngine engine)
{
return new VbcLoggerImpl(engine);
}
private class VbcLoggerImpl : ILogger
{
MSBuildEngine engine;
public VbcLoggerImpl(MSBuildEngine engine)
{
this.engine = engine;
}
public LoggerVerbosity Verbosity {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public string Parameters {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
IEventSource eventSource;
public void Initialize(IEventSource eventSource)
{
this.eventSource = eventSource;
engine.MessageView.AppendText("Running FxCop on " + Path.GetFileNameWithoutExtension(engine.CurrentProjectFile) + "\r\n");
eventSource.ErrorRaised += OnError;
eventSource.WarningRaised += OnWarning;
}
public void Shutdown()
{
if (eventSource != null) {
eventSource.ErrorRaised -= OnError;
eventSource.WarningRaised -= OnWarning;
eventSource = null;
}
}
void OnError(object sender, BuildErrorEventArgs e)
{
FixMessage();
}
void OnWarning(object sender, BuildWarningEventArgs e)
{
FixMessage();
}
void FixMessage()
{
engine.CurrentErrorOrWarning.ErrorText = FixEncoding(engine.CurrentErrorOrWarning.ErrorText);
//engine.CurrentErrorOrWarning.FileName = FixEncoding(engine.CurrentErrorOrWarning.FileName);
}
TODO: Fix SD2-995
static string FixEncoding(string encoding)
{
return encoding;
}
}
}
*/
}

9
src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.addin

@ -37,6 +37,15 @@ @@ -37,6 +37,15 @@
<String id="vbc" text = "vbc"/>
</Path>
<!--
<Path name = "/SharpDevelop/MSBuildEngine/AdditionalLoggers">
<TaskBoundAdditionalLogger
id = "VbcEncodingFixingLogger"
taskname = "vbc"
class = "VBNetBinding.VbcEncodingFixingLogger"/>
</Path>
-->
<Path name = "/Workspace/Parser">
<Parser id = "VBNet"
supportedextensions = ".vb"

3
src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj

@ -40,12 +40,12 @@ @@ -40,12 +40,12 @@
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.XML" />
<Reference Include="Microsoft.Build.Framework" />
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration\AssemblyInfo.cs" />
<EmbeddedResource Include="Resources\BuildOptions.xfrm" />
<Compile Include="Src\VBNetAmbience.cs" />
<Compile Include="Src\VBNetBindingExecutionManager.cs" />
<Compile Include="Src\VBNetLanguageBinding.cs" />
<Compile Include="Src\FormattingStrategy\VBNetFormattingStrategy.cs" />
<Compile Include="Src\OptionPanels\BuildOptions.cs">
@ -69,6 +69,7 @@ @@ -69,6 +69,7 @@
<Compile Include="..\..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>Configuration\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Src\VbcEncodingFixingLogger.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj">

6
src/Libraries/NRefactory/Project/Src/Visitors/ToVBNetConvertVisitor.cs

@ -63,6 +63,12 @@ namespace ICSharpCode.NRefactory.Visitors @@ -63,6 +63,12 @@ namespace ICSharpCode.NRefactory.Visitors
TypeDeclaration outerType = currentType;
currentType = typeDeclaration;
if ((typeDeclaration.Modifier & Modifiers.Static) == Modifiers.Static) {
typeDeclaration.Modifier &= ~Modifiers.Static;
typeDeclaration.Modifier |= Modifiers.Sealed;
typeDeclaration.Children.Insert(0, new ConstructorDeclaration("#ctor", Modifiers.Private, null, null));
}
// Conflicting field/property names -> m_field
List<string> properties = new List<string>();
foreach (object o in typeDeclaration.Children) {

10
src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBConverterTest.cs

@ -419,5 +419,15 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter @@ -419,5 +419,15 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter
{
TestStatement("T oldValue = default(T);", "Dim oldValue As T = Nothing");
}
[Test]
public void StaticClass()
{
TestProgram("public static class Test {}", @"Public NotInheritable Class Test
Private Sub New()
End Sub
End Class
");
}
}
}

2
src/Tools/Tools.build

@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
-->
</Target>
<Target Name="Rebuild" DependsOnTargets="Clean;Build"/>
<Target Name="Rebuild" DependsOnTargets="Build"/>
<ItemGroup>
<PrepareReleaseProject Include="SVNChangeLogToXml\SVNChangeLogToXml.csproj" />

Loading…
Cancel
Save