Browse Source

Merge branch '4.0'

pull/16/head
Matt Ward 15 years ago
parent
commit
d00cd04e67
  1. 81
      data/templates/project/CSharp/SilverlightApplication.xpt
  2. 2
      data/templates/project/CSharp/WebService.xpt
  3. 174
      data/templates/project/CSharp/WebpageProject.xpt
  4. 81
      data/templates/project/VB/SilverlightApplication.xpt
  5. 2
      data/templates/project/VB/WebService.xpt
  6. 190
      data/templates/project/VB/WebpageProject.xpt
  7. 113
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs
  8. 74
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ForNextConversionTests.cs
  9. 60
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/LocalVariableDefinitionsOnSameLineTests.cs
  10. 106
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/MultipleFieldsOnSameLineTests.cs
  11. 38
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/VBExitConversionTests.cs
  12. 4
      src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
  13. 115
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/NRefactoryToRubyConverter.cs
  14. 80
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/ForNextConversionTests.cs
  15. 2
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/LocalVariableAssignedInConstructorTestFixture.cs
  16. 64
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/LocalVariableDefinitionsOnSameLineTests.cs
  17. 115
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/MultipleFieldsOnSameLineTests.cs
  18. 41
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/VBExitConversionTests.cs
  19. 4
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyBinding.Tests.csproj
  20. 9
      src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchReplaceUtilities.cs
  21. 10
      src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchStrategy/BruteForceSearchStrategy.cs
  22. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs
  23. 16
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs
  24. 112
      src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
  25. 5
      src/Main/Base/Project/Src/Services/DisplayBinding/DisplayBindingService.cs
  26. 13
      src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs

81
data/templates/project/CSharp/SilverlightApplication.xpt

@ -19,36 +19,39 @@ @@ -19,36 +19,39 @@
<ProjectItems>
<Reference Include="System.Windows" />
<Reference Include="mscorlib" />
<Reference Include="system" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Xml" />
<Reference Include="System.Windows.Browser" />
<Reference Include="mscorlib" />
<Reference Include="system" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Xml" />
<Reference Include="System.Windows.Browser" />
</ProjectItems>
<PropertyGroup>
<PropertyGroup escapeValue="False">
<ProjectTypeGuids>{A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>${StandardNamespace}</RootNamespace>
<AssemblyName>${StandardNamespace}</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SilverlightApplication>true</SilverlightApplication>
<SupportedCultures>
</SupportedCultures>
<XapOutputs>true</XapOutputs>
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
<XapFilename>${StandardNamespace}.xap</XapFilename>
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
<SilverlightAppEntry>${StandardNamespace}.App</SilverlightAppEntry>
<TestPageFileName>TestPage.html</TestPageFileName>
<CreateTestPage>true</CreateTestPage>
<ValidateXaml>true</ValidateXaml>
<UsePlatformExtensions>false</UsePlatformExtensions>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>${StandardNamespace}</RootNamespace>
<AssemblyName>${StandardNamespace}</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SilverlightApplication>true</SilverlightApplication>
<SupportedCultures>
</SupportedCultures>
<XapOutputs>true</XapOutputs>
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
<XapFilename>${StandardNamespace}.xap</XapFilename>
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
<SilverlightAppEntry>${StandardNamespace}.App</SilverlightAppEntry>
<TestPageFileName>TestPage.html</TestPageFileName>
<CreateTestPage>true</CreateTestPage>
<ValidateXaml>true</ValidateXaml>
<UsePlatformExtensions>false</UsePlatformExtensions>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<NoConfig>true</NoConfig>
</PropertyGroup>
<PropertyGroup configuration="Debug" escapeValue="false">
@ -66,12 +69,12 @@ @@ -66,12 +69,12 @@
<Files>
<File name="App.xaml" buildAction="ApplicationDefinition" language="XML"><![CDATA[<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="${StandardNamespace}.App"
>
<Application.Resources>
</Application.Resources>
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="${StandardNamespace}.App"
>
<Application.Resources>
</Application.Resources>
</Application>]]></File>
<File name="App.xaml.cs" SubType="Code" DependentUpon="App.xaml"><![CDATA[using System;
@ -132,12 +135,12 @@ namespace ${StandardNamespace} @@ -132,12 +135,12 @@ namespace ${StandardNamespace}
}]]></File>
<File name="MainPage.xaml" buildAction="Page" language="XML"><![CDATA[<UserControl x:Class="${StandardNamespace}.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
</Grid>
</Grid>
</UserControl>]]></File>
<File name="MainPage.xaml.cs" SubType="Code" DependentUpon="MainPage.xaml"><![CDATA[using System;
@ -164,10 +167,10 @@ namespace ${StandardNamespace} @@ -164,10 +167,10 @@ namespace ${StandardNamespace}
}]]></File>
<File name="Properties\AppManifest.xml"><![CDATA[<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Deployment.Parts>
</Deployment.Parts>
<Deployment.Parts>
</Deployment.Parts>
</Deployment>]]></File>
<File name="Properties\AssemblyInfo.cs" src="DefaultAssemblyInfo.cs" />

2
data/templates/project/CSharp/WebService.xpt

@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
<Reference Include="System.Xml" />
</ProjectItems>
<PropertyGroup>
<PropertyGroup escapeValue="False">
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

174
data/templates/project/CSharp/WebpageProject.xpt

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
<?xml version="1.0"?>
<Template originator = "Tom Schroeter"
created = "24/03/2006"
created = "24/03/2006"
lastModified = "06/05/2006">
<!-- Template Header -->
@ -29,7 +29,7 @@ @@ -29,7 +29,7 @@
<Reference Include="System.Web.Services" />
</ProjectItems>
<PropertyGroup>
<PropertyGroup escapeValue="False">
<OutputType>Library</OutputType>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
</PropertyGroup>
@ -368,93 +368,93 @@ A:hover @@ -368,93 +368,93 @@ A:hover
<system.web>
<!-- DYNAMIC DEBUG COMPILATION
Set compilation debug="true" to enable ASPX debugging. Otherwise, setting this value to
false will improve runtime performance of this application.
Set compilation debug="true" to insert debugging symbols (.pdb information)
into the compiled page. Because this creates a larger file that executes
more slowly, you should set this value to true only when debugging and to
false at all other times. For more information, refer to the documentation about
debugging ASP.NET files.
-->
<compilation
defaultLanguage="c#"
debug="true"
/>
<!-- CUSTOM ERROR MESSAGES
Set customErrors mode="On" or "RemoteOnly" to enable custom error messages, "Off" to disable.
Add <error> tags for each of the errors you want to handle.
"On" Always display custom (friendly) messages.
"Off" Always display detailed ASP.NET error information.
"RemoteOnly" Display custom (friendly) messages only to users not running
on the local Web server. This setting is recommended for security purposes, so
that you do not display application detail information to remote clients.
-->
<customErrors mode="RemoteOnly" />
<!-- AUTHENTICATION
This section sets the authentication policies of the application. Possible modes are "Windows",
"Forms", "Passport" and "None"
"None" No authentication is performed.
"Windows" IIS performs authentication (Basic, Digest, or Integrated Windows) according to
its settings for the application. Anonymous access must be disabled in IIS.
"Forms" You provide a custom form (Web page) for users to enter their credentials, and then
you authenticate them in your application. A user credential token is stored in a cookie.
"Passport" Authentication is performed via a centralized authentication service provided
by Microsoft that offers a single logon and core profile services for member sites.
-->
<authentication mode="None" />
<!-- DYNAMIC DEBUG COMPILATION
Set compilation debug="true" to enable ASPX debugging. Otherwise, setting this value to
false will improve runtime performance of this application.
Set compilation debug="true" to insert debugging symbols (.pdb information)
into the compiled page. Because this creates a larger file that executes
more slowly, you should set this value to true only when debugging and to
false at all other times. For more information, refer to the documentation about
debugging ASP.NET files.
-->
<compilation
defaultLanguage="c#"
debug="true"
/>
<!-- CUSTOM ERROR MESSAGES
Set customErrors mode="On" or "RemoteOnly" to enable custom error messages, "Off" to disable.
Add <error> tags for each of the errors you want to handle.
"On" Always display custom (friendly) messages.
"Off" Always display detailed ASP.NET error information.
"RemoteOnly" Display custom (friendly) messages only to users not running
on the local Web server. This setting is recommended for security purposes, so
that you do not display application detail information to remote clients.
-->
<customErrors mode="RemoteOnly" />
<!-- AUTHENTICATION
This section sets the authentication policies of the application. Possible modes are "Windows",
"Forms", "Passport" and "None"
"None" No authentication is performed.
"Windows" IIS performs authentication (Basic, Digest, or Integrated Windows) according to
its settings for the application. Anonymous access must be disabled in IIS.
"Forms" You provide a custom form (Web page) for users to enter their credentials, and then
you authenticate them in your application. A user credential token is stored in a cookie.
"Passport" Authentication is performed via a centralized authentication service provided
by Microsoft that offers a single logon and core profile services for member sites.
-->
<authentication mode="None" />
<!-- AUTHORIZATION
This section sets the authorization policies of the application. You can allow or deny access
to application resources by user or role. Wildcards: "*" mean everyone, "?" means anonymous
(unauthenticated) users.
-->
<authorization>
<allow users="*" /> <!-- Allow all users -->
<!-- <allow users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
<deny users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
-->
</authorization>
<!-- APPLICATION-LEVEL TRACE LOGGING
Application-level tracing enables trace log output for every page within an application.
Set trace enabled="true" to enable application trace logging. If pageOutput="true", the
trace information will be displayed at the bottom of each page. Otherwise, you can view the
application trace log by browsing the "trace.axd" page from your web application
root.
-->
<trace
enabled="false"
requestLimit="10"
pageOutput="false"
traceMode="SortByTime"
This section sets the authorization policies of the application. You can allow or deny access
to application resources by user or role. Wildcards: "*" mean everyone, "?" means anonymous
(unauthenticated) users.
-->
<authorization>
<allow users="*" /> <!-- Allow all users -->
<!-- <allow users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
<deny users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
-->
</authorization>
<!-- APPLICATION-LEVEL TRACE LOGGING
Application-level tracing enables trace log output for every page within an application.
Set trace enabled="true" to enable application trace logging. If pageOutput="true", the
trace information will be displayed at the bottom of each page. Otherwise, you can view the
application trace log by browsing the "trace.axd" page from your web application
root.
-->
<trace
enabled="false"
requestLimit="10"
pageOutput="false"
traceMode="SortByTime"
localOnly="true"
/>
<!-- SESSION STATE SETTINGS
By default ASP.NET uses cookies to identify which requests belong to a particular session.
If cookies are not available, a session can be tracked by adding a session identifier to the URL.
To disable cookies, set sessionState cookieless="true".
-->
<sessionState
mode="InProc"
cookieless="true"
timeout="20"
/>
<!-- GLOBALIZATION
This section sets the globalization settings of the application.
-->
<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
/>
<!-- SESSION STATE SETTINGS
By default ASP.NET uses cookies to identify which requests belong to a particular session.
If cookies are not available, a session can be tracked by adding a session identifier to the URL.
To disable cookies, set sessionState cookieless="true".
-->
<sessionState
mode="InProc"
cookieless="true"
timeout="20"
/>
<!-- GLOBALIZATION
This section sets the globalization settings of the application.
-->
<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
/>
</system.web>
@ -462,7 +462,7 @@ A:hover @@ -462,7 +462,7 @@ A:hover
<appSettings>
<add key="SqlConnectionString"
value="Server=localhost; Database=; Uid=root; Pwd=;"
value="Server=localhost; Database=; Uid=root; Pwd=;"
/>
</appSettings>

81
data/templates/project/VB/SilverlightApplication.xpt

@ -19,36 +19,39 @@ @@ -19,36 +19,39 @@
<ProjectItems>
<Reference Include="System.Windows" />
<Reference Include="mscorlib" />
<Reference Include="system" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Xml" />
<Reference Include="System.Windows.Browser" />
<Reference Include="mscorlib" />
<Reference Include="system" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Xml" />
<Reference Include="System.Windows.Browser" />
</ProjectItems>
<PropertyGroup>
<PropertyGroup escapeValue="False">
<ProjectTypeGuids>{A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>${StandardNamespace}</RootNamespace>
<AssemblyName>${StandardNamespace}</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SilverlightApplication>true</SilverlightApplication>
<SupportedCultures>
</SupportedCultures>
<XapOutputs>true</XapOutputs>
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
<XapFilename>${StandardNamespace}.xap</XapFilename>
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
<SilverlightAppEntry>${StandardNamespace}.App</SilverlightAppEntry>
<TestPageFileName>TestPage.html</TestPageFileName>
<CreateTestPage>true</CreateTestPage>
<ValidateXaml>true</ValidateXaml>
<UsePlatformExtensions>false</UsePlatformExtensions>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>${StandardNamespace}</RootNamespace>
<AssemblyName>${StandardNamespace}</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SilverlightApplication>true</SilverlightApplication>
<SupportedCultures>
</SupportedCultures>
<XapOutputs>true</XapOutputs>
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
<XapFilename>${StandardNamespace}.xap</XapFilename>
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
<SilverlightAppEntry>${StandardNamespace}.App</SilverlightAppEntry>
<TestPageFileName>TestPage.html</TestPageFileName>
<CreateTestPage>true</CreateTestPage>
<ValidateXaml>true</ValidateXaml>
<UsePlatformExtensions>false</UsePlatformExtensions>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<NoConfig>true</NoConfig>
</PropertyGroup>
<PropertyGroup configuration="Debug" escapeValue="false">
@ -66,12 +69,12 @@ @@ -66,12 +69,12 @@
<Files>
<File name="App.xaml" buildAction="ApplicationDefinition" language="XML"><![CDATA[<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="App"
>
<Application.Resources>
</Application.Resources>
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="App"
>
<Application.Resources>
</Application.Resources>
</Application>]]></File>
<File name="App.xaml.vb" SubType="Code" DependentUpon="App.xaml"><![CDATA[${StandardHeader.VBNET}
@ -127,12 +130,12 @@ End Class @@ -127,12 +130,12 @@ End Class
]]></File>
<File name="MainPage.xaml" buildAction="Page" language="XML"><![CDATA[<UserControl x:Class="MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
</Grid>
</Grid>
</UserControl>]]></File>
<File name="MainPage.xaml.vb" SubType="Code" DependentUpon="MainPage.xaml"><![CDATA[${StandardHeader.VBNET}
@ -156,10 +159,10 @@ End Class @@ -156,10 +159,10 @@ End Class
]]></File>
<File name="Properties\AppManifest.xml"><![CDATA[<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Deployment.Parts>
</Deployment.Parts>
<Deployment.Parts>
</Deployment.Parts>
</Deployment>]]></File>
<File name="Properties\AssemblyInfo.vb" src="DefaultAssemblyInfo.vb" />

2
data/templates/project/VB/WebService.xpt

@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
<Reference Include="System.Xml" />
</ProjectItems>
<PropertyGroup>
<PropertyGroup escapeValue="False">
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

190
data/templates/project/VB/WebpageProject.xpt

@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
<Reference Include="System.Web.Services" />
</ProjectItems>
<PropertyGroup>
<PropertyGroup escapeValue="False">
<OutputType>Library</OutputType>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
</PropertyGroup>
@ -42,6 +42,7 @@ @@ -42,6 +42,7 @@
<Files>
<!--*************************************************************************-->
<File name=".\Default.aspx.vb" DependentUpon="Default.aspx"><![CDATA[${StandardHeader.VBNET}Imports System.Collections
IMports System
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
@ -132,6 +133,7 @@ End Class @@ -132,6 +133,7 @@ End Class
]]></File>
<File name=".\Global.asax.vb" DependentUpon="Global.asax">
<![CDATA[Imports System.Collections
Imports System
Imports System.ComponentModel
Imports System.Web
Imports System.Web.SessionState
@ -155,35 +157,35 @@ Public Class [Global] @@ -155,35 +157,35 @@ Public Class [Global]
#End Region
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Protected Sub Application_Start(sender As [Object], e As EventArgs)
Protected Sub Application_Start(sender As Object, e As EventArgs)
End Sub
Protected Sub Session_Start(sender As [Object], e As EventArgs)
Protected Sub Session_Start(sender As Object, e As EventArgs)
End Sub
Protected Sub Application_BeginRequest(sender As [Object], e As EventArgs)
Protected Sub Application_BeginRequest(sender As Object, e As EventArgs)
End Sub
Protected Sub Application_EndRequest(sender As [Object], e As EventArgs)
Protected Sub Application_EndRequest(sender As Object, e As EventArgs)
End Sub
Protected Sub Application_AuthenticateRequest(sender As [Object], e As EventArgs)
Protected Sub Application_AuthenticateRequest(sender As Object, e As EventArgs)
End Sub
Protected Sub Application_Error(sender As [Object], e As EventArgs)
Protected Sub Application_Error(sender As Object, e As EventArgs)
End Sub
Protected Sub Session_End(sender As [Object], e As EventArgs)
Protected Sub Session_End(sender As Object, e As EventArgs)
End Sub
Protected Sub Application_End(sender As [Object], e As EventArgs)
Protected Sub Application_End(sender As Object, e As EventArgs)
End Sub
@ -335,93 +337,93 @@ A:hover @@ -335,93 +337,93 @@ A:hover
<system.web>
<!-- DYNAMIC DEBUG COMPILATION
Set compilation debug="true" to enable ASPX debugging. Otherwise, setting this value to
false will improve runtime performance of this application.
Set compilation debug="true" to insert debugging symbols (.pdb information)
into the compiled page. Because this creates a larger file that executes
more slowly, you should set this value to true only when debugging and to
false at all other times. For more information, refer to the documentation about
debugging ASP.NET files.
-->
<compilation
defaultLanguage="c#"
debug="true"
/>
<!-- CUSTOM ERROR MESSAGES
Set customErrors mode="On" or "RemoteOnly" to enable custom error messages, "Off" to disable.
Add <error> tags for each of the errors you want to handle.
"On" Always display custom (friendly) messages.
"Off" Always display detailed ASP.NET error information.
"RemoteOnly" Display custom (friendly) messages only to users not running
on the local Web server. This setting is recommended for security purposes, so
that you do not display application detail information to remote clients.
-->
<customErrors mode="RemoteOnly" />
<!-- AUTHENTICATION
This section sets the authentication policies of the application. Possible modes are "Windows",
"Forms", "Passport" and "None"
"None" No authentication is performed.
"Windows" IIS performs authentication (Basic, Digest, or Integrated Windows) according to
its settings for the application. Anonymous access must be disabled in IIS.
"Forms" You provide a custom form (Web page) for users to enter their credentials, and then
you authenticate them in your application. A user credential token is stored in a cookie.
"Passport" Authentication is performed via a centralized authentication service provided
by Microsoft that offers a single logon and core profile services for member sites.
-->
<authentication mode="None" />
<!-- DYNAMIC DEBUG COMPILATION
Set compilation debug="true" to enable ASPX debugging. Otherwise, setting this value to
false will improve runtime performance of this application.
Set compilation debug="true" to insert debugging symbols (.pdb information)
into the compiled page. Because this creates a larger file that executes
more slowly, you should set this value to true only when debugging and to
false at all other times. For more information, refer to the documentation about
debugging ASP.NET files.
-->
<compilation
defaultLanguage="c#"
debug="true"
/>
<!-- CUSTOM ERROR MESSAGES
Set customErrors mode="On" or "RemoteOnly" to enable custom error messages, "Off" to disable.
Add <error> tags for each of the errors you want to handle.
"On" Always display custom (friendly) messages.
"Off" Always display detailed ASP.NET error information.
"RemoteOnly" Display custom (friendly) messages only to users not running
on the local Web server. This setting is recommended for security purposes, so
that you do not display application detail information to remote clients.
-->
<customErrors mode="RemoteOnly" />
<!-- AUTHENTICATION
This section sets the authentication policies of the application. Possible modes are "Windows",
"Forms", "Passport" and "None"
"None" No authentication is performed.
"Windows" IIS performs authentication (Basic, Digest, or Integrated Windows) according to
its settings for the application. Anonymous access must be disabled in IIS.
"Forms" You provide a custom form (Web page) for users to enter their credentials, and then
you authenticate them in your application. A user credential token is stored in a cookie.
"Passport" Authentication is performed via a centralized authentication service provided
by Microsoft that offers a single logon and core profile services for member sites.
-->
<authentication mode="None" />
<!-- AUTHORIZATION
This section sets the authorization policies of the application. You can allow or deny access
to application resources by user or role. Wildcards: "*" mean everyone, "?" means anonymous
(unauthenticated) users.
-->
<authorization>
<allow users="*" /> <!-- Allow all users -->
<!-- <allow users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
<deny users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
-->
</authorization>
<!-- APPLICATION-LEVEL TRACE LOGGING
Application-level tracing enables trace log output for every page within an application.
Set trace enabled="true" to enable application trace logging. If pageOutput="true", the
trace information will be displayed at the bottom of each page. Otherwise, you can view the
application trace log by browsing the "trace.axd" page from your web application
root.
-->
<trace
enabled="false"
requestLimit="10"
pageOutput="false"
traceMode="SortByTime"
This section sets the authorization policies of the application. You can allow or deny access
to application resources by user or role. Wildcards: "*" mean everyone, "?" means anonymous
(unauthenticated) users.
-->
<authorization>
<allow users="*" /> <!-- Allow all users -->
<!-- <allow users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
<deny users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
-->
</authorization>
<!-- APPLICATION-LEVEL TRACE LOGGING
Application-level tracing enables trace log output for every page within an application.
Set trace enabled="true" to enable application trace logging. If pageOutput="true", the
trace information will be displayed at the bottom of each page. Otherwise, you can view the
application trace log by browsing the "trace.axd" page from your web application
root.
-->
<trace
enabled="false"
requestLimit="10"
pageOutput="false"
traceMode="SortByTime"
localOnly="true"
/>
<!-- SESSION STATE SETTINGS
By default ASP.NET uses cookies to identify which requests belong to a particular session.
If cookies are not available, a session can be tracked by adding a session identifier to the URL.
To disable cookies, set sessionState cookieless="true".
-->
<sessionState
mode="InProc"
cookieless="true"
timeout="20"
/>
<!-- GLOBALIZATION
This section sets the globalization settings of the application.
-->
<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
/>
<!-- SESSION STATE SETTINGS
By default ASP.NET uses cookies to identify which requests belong to a particular session.
If cookies are not available, a session can be tracked by adding a session identifier to the URL.
To disable cookies, set sessionState cookieless="true".
-->
<sessionState
mode="InProc"
cookieless="true"
timeout="20"
/>
<!-- GLOBALIZATION
This section sets the globalization settings of the application.
-->
<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
/>
</system.web>
@ -429,7 +431,7 @@ A:hover @@ -429,7 +431,7 @@ A:hover
<appSettings>
<add key="SqlConnectionString"
value="Server=localhost; Database=; Uid=root; Pwd=;"
value="Server=localhost; Database=; Uid=root; Pwd=;"
/>
</appSettings>

113
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs

@ -549,7 +549,7 @@ namespace ICSharpCode.PythonBinding @@ -549,7 +549,7 @@ namespace ICSharpCode.PythonBinding
public override object TrackedVisitExitStatement(ExitStatement exitStatement, object data)
{
Console.WriteLine("VisitExitStatement");
AppendIndentedLine("break");
return null;
}
@ -595,9 +595,51 @@ namespace ICSharpCode.PythonBinding @@ -595,9 +595,51 @@ namespace ICSharpCode.PythonBinding
return null;
}
/// <summary>
/// Converts from an NRefactory VB.NET for next loop:
///
/// for i As Integer = 0 To 4
/// Next
///
/// to Python's:
///
/// i = 0
/// while i &lt; 5:
/// </summary>
public override object TrackedVisitForNextStatement(ForNextStatement forNextStatement, object data)
{
Console.WriteLine("VisitForNextStatement");
// Convert the for loop's initializers.
string variableName = forNextStatement.VariableName;
AppendIndented(variableName);
Append(" = ");
forNextStatement.Start.AcceptVisitor(this, data);
AppendLine();
// Convert the for loop's test expression.
AppendIndented("while ");
Append(variableName);
Append(" <= ");
forNextStatement.End.AcceptVisitor(this, data);
Append(":");
AppendLine();
// Visit the for loop's body.
IncreaseIndent();
forNextStatement.EmbeddedStatement.AcceptVisitor(this, data);
// Convert the for loop's increment statement.
AppendIndented(variableName);
Append(" = ");
Append(variableName);
Append(" + ");
if (forNextStatement.Step.IsNull) {
Append("1");
} else {
forNextStatement.Step.AcceptVisitor(this, data);
}
AppendLine();
DecreaseIndent();
return null;
}
@ -765,15 +807,18 @@ namespace ICSharpCode.PythonBinding @@ -765,15 +807,18 @@ namespace ICSharpCode.PythonBinding
/// </summary>
public override object TrackedVisitLocalVariableDeclaration(LocalVariableDeclaration localVariableDeclaration, object data)
{
VariableDeclaration variableDeclaration = localVariableDeclaration.Variables[0];
if (!variableDeclaration.Initializer.IsNull) {
// Create variable declaration.
AppendIndented(variableDeclaration.Name + " = ");
// Generate the variable initializer.
variableDeclaration.Initializer.AcceptVisitor(this, data);
AppendLine();
foreach (VariableDeclaration variableDeclaration in localVariableDeclaration.Variables) {
if (!variableDeclaration.Initializer.IsNull) {
AddTypeToArrayInitializerIfMissing(variableDeclaration);
// Create variable declaration.
AppendIndented(variableDeclaration.Name + " = ");
// Generate the variable initializer.
variableDeclaration.Initializer.AcceptVisitor(this, data);
AppendLine();
}
}
return null;
}
@ -1428,9 +1473,8 @@ namespace ICSharpCode.PythonBinding @@ -1428,9 +1473,8 @@ namespace ICSharpCode.PythonBinding
/// Checks that the field declaration has an initializer that
/// sets an initial value.
/// </summary>
static bool FieldHasInitialValue(FieldDeclaration fieldDeclaration)
static bool FieldHasInitialValue(VariableDeclaration variableDeclaration)
{
VariableDeclaration variableDeclaration = fieldDeclaration.Fields[0];
Expression initializer = variableDeclaration.Initializer;
return !initializer.IsNull;
}
@ -1515,8 +1559,10 @@ namespace ICSharpCode.PythonBinding @@ -1515,8 +1559,10 @@ namespace ICSharpCode.PythonBinding
// Check the current class's fields.
if (constructorInfo != null) {
foreach (FieldDeclaration field in constructorInfo.Fields) {
if (field.Fields[0].Name == name) {
return true;
foreach (VariableDeclaration variable in field.Fields) {
if (variable.Name == name) {
return true;
}
}
}
}
@ -1653,10 +1699,7 @@ namespace ICSharpCode.PythonBinding @@ -1653,10 +1699,7 @@ namespace ICSharpCode.PythonBinding
AppendDocstring(xmlDocComments);
if (constructorInfo.Fields.Count > 0) {
foreach (FieldDeclaration field in constructorInfo.Fields) {
// Ignore field if it has no initializer.
if (FieldHasInitialValue(field)) {
CreateFieldInitialization(field);
}
CreateFieldInitialization(field);
}
}
@ -1688,11 +1731,33 @@ namespace ICSharpCode.PythonBinding @@ -1688,11 +1731,33 @@ namespace ICSharpCode.PythonBinding
/// </summary>
void CreateFieldInitialization(FieldDeclaration field)
{
VariableDeclaration variable = field.Fields[0];
string oldVariableName = variable.Name;
variable.Name = "self._" + variable.Name;
VisitVariableDeclaration(variable, null);
variable.Name = oldVariableName;
foreach (VariableDeclaration variable in field.Fields) {
// Ignore field if it has no initializer.
if (FieldHasInitialValue(variable)) {
AddTypeToArrayInitializerIfMissing(variable);
string oldVariableName = variable.Name;
variable.Name = "self._" + variable.Name;
VisitVariableDeclaration(variable, null);
variable.Name = oldVariableName;
}
}
}
void AddTypeToArrayInitializerIfMissing(VariableDeclaration variable)
{
ArrayCreateExpression arrayCreate = variable.Initializer as ArrayCreateExpression;
if (IsArrayMissingTypeToCreate(arrayCreate)) {
arrayCreate.CreateType = variable.TypeReference;
}
}
bool IsArrayMissingTypeToCreate(ArrayCreateExpression arrayCreate)
{
if (arrayCreate != null) {
return String.IsNullOrEmpty(arrayCreate.CreateType.Type);
}
return false;
}
/// <summary>

74
src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ForNextConversionTests.cs

@ -0,0 +1,74 @@ @@ -0,0 +1,74 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.NRefactory;
using ICSharpCode.PythonBinding;
using NUnit.Framework;
namespace PythonBinding.Tests.Converter
{
[TestFixture]
public class ForNextConversionTests
{
string vbnetForNextCode =
"Public Class Foo\r\n" +
" Public Function GetCount() As Integer\r\n" +
" Dim count As Integer = 0\r\n" +
" For i As Integer = 0 To 4\r\n" +
" count += 1\r\n" +
" Next\r\n" +
" Return count\r\n" +
" End Function\r\n" +
"End Class\r\n";
[Test]
public void ConvertVBNetForNextToPython()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.VBNet);
converter.IndentString = " ";
string code = converter.Convert(vbnetForNextCode);
string expectedCode =
"class Foo(object):\r\n" +
" def GetCount(self):\r\n" +
" count = 0\r\n" +
" i = 0\r\n" +
" while i <= 4:\r\n" +
" count += 1\r\n" +
" i = i + 1\r\n" +
" return count";
Assert.AreEqual(expectedCode, code);
}
string vbnetForNextWithStepCode =
"Public Class Foo\r\n" +
" Public Function GetCount() As Integer\r\n" +
" Dim count As Integer = 0\r\n" +
" For i As Integer = 0 To 4 Step 2\r\n" +
" count += 1\r\n" +
" Next\r\n" +
" Return count\r\n" +
" End Function\r\n" +
"End Class\r\n";
[Test]
public void ConvertVBNetForNextWithStepToPython()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.VBNet);
converter.IndentString = " ";
string code = converter.Convert(vbnetForNextWithStepCode );
string expectedCode =
"class Foo(object):\r\n" +
" def GetCount(self):\r\n" +
" count = 0\r\n" +
" i = 0\r\n" +
" while i <= 4:\r\n" +
" count += 1\r\n" +
" i = i + 2\r\n" +
" return count";
Assert.AreEqual(expectedCode, code);
}
}
}

60
src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/LocalVariableDefinitionsOnSameLineTests.cs

@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.NRefactory;
using ICSharpCode.PythonBinding;
using NUnit.Framework;
namespace PythonBinding.Tests.Converter
{
[TestFixture]
public class LocalVariableDefinitionsOnSameLineTests
{
string csharp =
"class Foo\r\n" +
"{\r\n" +
" public Foo()\r\n" +
" {\r\n" +
" int i = 0, i = 2;\r\n" +
" }\r\n" +
"}";
[Test]
public void ConvertedPythonCode()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
converter.IndentString = " ";
string python = converter.Convert(csharp);
string expectedPython =
"class Foo(object):\r\n" +
" def __init__(self):\r\n" +
" i = 0\r\n" +
" i = 2";
Assert.AreEqual(expectedPython, python);
}
string vnetClassWithTwoArrayVariablesOnSameLine =
"class Foo\r\n" +
" Public Sub New()\r\n" +
" Dim i(10), j(20) as integer\r\n" +
" End Sub\r\n" +
"end class";
[Test]
public void ConvertVBNetClassWithTwoArrayVariablesOnSameLine()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.VBNet);
converter.IndentString = " ";
string python = converter.Convert(vnetClassWithTwoArrayVariablesOnSameLine);
string expectedPython =
"class Foo(object):\r\n" +
" def __init__(self):\r\n" +
" i = Array.CreateInstance(int, 10)\r\n" +
" j = Array.CreateInstance(int, 20)";
Assert.AreEqual(expectedPython, python);
}
}
}

106
src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/MultipleFieldsOnSameLineTests.cs

@ -0,0 +1,106 @@ @@ -0,0 +1,106 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.NRefactory;
using ICSharpCode.PythonBinding;
using NUnit.Framework;
namespace PythonBinding.Tests.Converter
{
[TestFixture]
public class MultipleFieldsOnSameLineTests
{
string csharpClassWithFieldsThatHaveInitialValues =
"class Foo\r\n" +
"{\r\n" +
" int i = 0, j = 1;\r\n" +
"}";
[Test]
public void ConvertCSharpClassWithFieldsThatHaveInitialValues()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
converter.IndentString = " ";
string python = converter.Convert(csharpClassWithFieldsThatHaveInitialValues);
string expectedPython =
"class Foo(object):\r\n" +
" def __init__(self):\r\n" +
" self._i = 0\r\n" +
" self._j = 1";
Assert.AreEqual(expectedPython, python);
}
string csharpClassWithTwoFieldsWhereFirstDoesNotHaveInitialValue =
"class Foo\r\n" +
"{\r\n" +
" int i, j = 1;\r\n" +
"}";
[Test]
public void ConvertCSharpClassWithFieldsWhereFirstFieldDoesNotHaveInitialValue()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
converter.IndentString = " ";
string python = converter.Convert(csharpClassWithTwoFieldsWhereFirstDoesNotHaveInitialValue);
string expectedPython =
"class Foo(object):\r\n" +
" def __init__(self):\r\n" +
" self._j = 1";
Assert.AreEqual(expectedPython, python);
}
string csharpClassWithTwoFieldsInitializedInMethod =
"class Foo\r\n" +
"{\r\n" +
" int i = 0;\r\n" +
" int j, k;\r\n" +
"\r\n" +
" public void Test()\r\n" +
" {\r\n" +
" j = 1;\r\n" +
" k = 3;\r\n" +
" }\r\n" +
"}";
[Test]
public void ConvertCSharpClassWithTwoFieldsInitializedInMethod()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
converter.IndentString = " ";
string python = converter.Convert(csharpClassWithTwoFieldsInitializedInMethod);
string expectedPython =
"class Foo(object):\r\n" +
" def __init__(self):\r\n" +
" self._i = 0\r\n" +
"\r\n" +
" def Test(self):\r\n" +
" self._j = 1\r\n" +
" self._k = 3";
Assert.AreEqual(expectedPython, python);
}
string vnetClassWithTwoArrayFieldsOnSameLine =
"class Foo\r\n" +
" Private i(10), j(20) as integer\r\n" +
"end class";
[Test]
public void ConvertVBNetClassWithTwoArrayFieldsOnSameLine()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.VBNet);
converter.IndentString = " ";
string python = converter.Convert(vnetClassWithTwoArrayFieldsOnSameLine);
string expectedPython =
"class Foo(object):\r\n" +
" def __init__(self):\r\n" +
" self._i = Array.CreateInstance(int, 10)\r\n" +
" self._j = Array.CreateInstance(int, 20)";
Assert.AreEqual(expectedPython, python);
}
}
}

38
src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/VBExitConversionTests.cs

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.NRefactory;
using ICSharpCode.PythonBinding;
using NUnit.Framework;
namespace PythonBinding.Tests.Converter
{
[TestFixture]
public class VBExitConversionTests
{
string vb =
"Public Class Class1\r\n" +
" Public Sub Test\r\n" +
" While True\r\n" +
" Exit While\r\n" +
" End While\r\n" +
" End Sub\r\n" +
"End Class\r\n";
[Test]
public void ConvertedPythonCode()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.VBNet);
converter.IndentString = " ";
string python = converter.Convert(vb);
string expectedPython =
"class Class1(object):\r\n" +
" def Test(self):\r\n" +
" while True:\r\n" +
" break";
Assert.AreEqual(expectedPython, python);
}
}
}

4
src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj

@ -122,6 +122,7 @@ @@ -122,6 +122,7 @@
<Compile Include="Converter\ConvertToPythonProjectCommandTestFixture.cs" />
<Compile Include="Converter\EventHandlerWithObjectCreationTestFixture.cs" />
<Compile Include="Converter\ForeachConversionWithMethodCallTestFixture.cs" />
<Compile Include="Converter\ForNextConversionTests.cs" />
<Compile Include="Converter\GenerateMainMethodCallTestFixture.cs" />
<Compile Include="Converter\GenericListConversionTestFixture.cs" />
<Compile Include="Converter\IntegerMethodParameterTestFixture.cs" />
@ -140,6 +141,7 @@ @@ -140,6 +141,7 @@
<Compile Include="Converter\IntegerClassFieldWithConstructorTestFixture.cs" />
<Compile Include="Converter\LocalVariableAssignedInConstructorTestFixture.cs" />
<Compile Include="Converter\LocalVariableDeclarationInIfStatementTestFixture.cs" />
<Compile Include="Converter\LocalVariableDefinitionsOnSameLineTests.cs" />
<Compile Include="Converter\LocalVariableNotInitializedTestFixture.cs" />
<Compile Include="Converter\MethodCallInConstructorTestFixture.cs" />
<Compile Include="Converter\MethodParameterConversionTestFixture.cs" />
@ -148,6 +150,7 @@ @@ -148,6 +150,7 @@
<Compile Include="Converter\IfStatementConversionTestFixture.cs" />
<Compile Include="Converter\ModulusOperatorConversionTestFixture.cs" />
<Compile Include="Converter\MultiLineCommentTestFixture.cs" />
<Compile Include="Converter\MultipleFieldsOnSameLineTests.cs" />
<Compile Include="Converter\NestedClassConversionTestFixture.cs" />
<Compile Include="Converter\NestedIfStatementConversionTestFixture.cs" />
<Compile Include="Converter\NullConversionTestFixture.cs" />
@ -176,6 +179,7 @@ @@ -176,6 +179,7 @@
<Compile Include="Converter\UnaryOperatorConversionTests.cs" />
<Compile Include="Converter\UsingStatementConversionTestFixture.cs" />
<Compile Include="Converter\VBClassConversionTestFixture.cs" />
<Compile Include="Converter\VBExitConversionTests.cs" />
<Compile Include="Converter\VBStringConcatTestFixture.cs" />
<Compile Include="Converter\WhileLoopConversionTestFixture.cs" />
<Compile Include="Converter\XmlDocCommentConversionTestFixture.cs" />

115
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/NRefactoryToRubyConverter.cs

@ -401,7 +401,13 @@ namespace ICSharpCode.RubyBinding @@ -401,7 +401,13 @@ namespace ICSharpCode.RubyBinding
expressionStatement.Expression.AcceptVisitor(this, data);
AppendLine();
return null;
}
}
public override object TrackedVisitExitStatement(ExitStatement exitStatement, object data)
{
AppendIndentedLine("break");
return null;
}
public override object TrackedVisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data)
{
@ -457,7 +463,43 @@ namespace ICSharpCode.RubyBinding @@ -457,7 +463,43 @@ namespace ICSharpCode.RubyBinding
return null;
}
public override object TrackedVisitForNextStatement(ForNextStatement forNextStatement, object data)
{
// Convert the for loop's initializers.
string variableName = forNextStatement.VariableName;
AppendIndented(variableName);
Append(" = ");
forNextStatement.Start.AcceptVisitor(this, data);
AppendLine();
// Convert the for loop's test expression.
AppendIndented("while ");
Append(variableName);
Append(" <= ");
forNextStatement.End.AcceptVisitor(this, data);
AppendLine();
// Visit the for loop's body.
IncreaseIndent();
forNextStatement.EmbeddedStatement.AcceptVisitor(this, data);
// Convert the for loop's increment statement.
AppendIndented(variableName);
Append(" = ");
Append(variableName);
Append(" + ");
if (forNextStatement.Step.IsNull) {
Append("1");
} else {
forNextStatement.Step.AcceptVisitor(this, data);
}
AppendLine();
DecreaseIndent();
AppendIndentedLine("end");
return null;
}
public override object TrackedVisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
{
@ -558,15 +600,17 @@ namespace ICSharpCode.RubyBinding @@ -558,15 +600,17 @@ namespace ICSharpCode.RubyBinding
/// </summary>
public override object TrackedVisitLocalVariableDeclaration(LocalVariableDeclaration localVariableDeclaration, object data)
{
VariableDeclaration variableDeclaration = localVariableDeclaration.Variables[0];
if (!variableDeclaration.Initializer.IsNull) {
// Create variable declaration.
AppendIndented(variableDeclaration.Name + " = ");
// Generate the variable initializer.
variableDeclaration.Initializer.AcceptVisitor(this, data);
AppendLine();
foreach (VariableDeclaration variableDeclaration in localVariableDeclaration.Variables) {
if (!variableDeclaration.Initializer.IsNull) {
// Create variable declaration.
AppendIndented(variableDeclaration.Name + " = ");
// Generate the variable initializer.
AddTypeToArrayInitializerIfMissing(variableDeclaration);
variableDeclaration.Initializer.AcceptVisitor(this, data);
AppendLine();
}
}
return null;
}
@ -603,7 +647,6 @@ namespace ICSharpCode.RubyBinding @@ -603,7 +647,6 @@ namespace ICSharpCode.RubyBinding
AppendLine();
IncreaseIndent();
// AppendDocstring(xmlDocComments);
if (methodDeclaration.Body.Children.Count > 0) {
methodDeclaration.Body.AcceptVisitor(this, data);
}
@ -828,7 +871,6 @@ namespace ICSharpCode.RubyBinding @@ -828,7 +871,6 @@ namespace ICSharpCode.RubyBinding
AppendBaseTypes(typeDeclaration.BaseTypes);
AppendLine();
IncreaseIndent();
// AppendDocstring(xmlDocComments);
if (typeDeclaration.Children.Count > 0) {
// Look for fields or a constructor for the type.
constructorInfo = RubyConstructorInfo.GetConstructorInfo(typeDeclaration);
@ -987,8 +1029,10 @@ namespace ICSharpCode.RubyBinding @@ -987,8 +1029,10 @@ namespace ICSharpCode.RubyBinding
// Check the current class's fields.
if (constructorInfo != null) {
foreach (FieldDeclaration field in constructorInfo.Fields) {
if (field.Fields[0].Name == name) {
return true;
foreach (VariableDeclaration variable in field.Fields) {
if (variable.Name == name) {
return true;
}
}
}
}
@ -1183,13 +1227,9 @@ namespace ICSharpCode.RubyBinding @@ -1183,13 +1227,9 @@ namespace ICSharpCode.RubyBinding
// Add fields at start of constructor.
IncreaseIndent();
// AppendDocstring(xmlDocComments);
if (constructorInfo.Fields.Count > 0) {
foreach (FieldDeclaration field in constructorInfo.Fields) {
// Ignore field if it has no initializer.
if (FieldHasInitialValue(field)) {
CreateFieldInitialization(field);
}
CreateFieldInitialization(field);
}
}
@ -1217,20 +1257,41 @@ namespace ICSharpCode.RubyBinding @@ -1217,20 +1257,41 @@ namespace ICSharpCode.RubyBinding
/// Checks that the field declaration has an initializer that
/// sets an initial value.
/// </summary>
static bool FieldHasInitialValue(FieldDeclaration fieldDeclaration)
static bool FieldHasInitialValue(VariableDeclaration variableDeclaration)
{
VariableDeclaration variableDeclaration = fieldDeclaration.Fields[0];
Expression initializer = variableDeclaration.Initializer;
return !initializer.IsNull;
}
void CreateFieldInitialization(FieldDeclaration field)
{
VariableDeclaration variable = field.Fields[0];
string oldVariableName = variable.Name;
variable.Name = "@" + variable.Name;
VisitVariableDeclaration(variable, null);
variable.Name = oldVariableName;
foreach (VariableDeclaration variable in field.Fields) {
// Ignore field if it has no initializer.
if (FieldHasInitialValue(variable)) {
AddTypeToArrayInitializerIfMissing(variable);
string oldVariableName = variable.Name;
variable.Name = "@" + variable.Name;
VisitVariableDeclaration(variable, null);
variable.Name = oldVariableName;
}
}
}
void AddTypeToArrayInitializerIfMissing(VariableDeclaration variable)
{
ArrayCreateExpression arrayCreate = variable.Initializer as ArrayCreateExpression;
if (IsArrayMissingTypeToCreate(arrayCreate)) {
arrayCreate.CreateType = variable.TypeReference;
}
}
bool IsArrayMissingTypeToCreate(ArrayCreateExpression arrayCreate)
{
if (arrayCreate != null) {
return String.IsNullOrEmpty(arrayCreate.CreateType.Type);
}
return false;
}
/// <summary>

80
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/ForNextConversionTests.cs

@ -0,0 +1,80 @@ @@ -0,0 +1,80 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.NRefactory;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
namespace RubyBinding.Tests.Converter
{
[TestFixture]
public class ForNextConversionTests
{
string vbnetForNextCode =
"Public Class Foo\r\n" +
" Public Function GetCount() As Integer\r\n" +
" Dim count As Integer = 0\r\n" +
" For i As Integer = 0 To 4\r\n" +
" count += 1\r\n" +
" Next\r\n" +
" Return count\r\n" +
" End Function\r\n" +
"End Class\r\n";
[Test]
public void ConvertVBNetForNextToRuby()
{
NRefactoryToRubyConverter converter = new NRefactoryToRubyConverter(SupportedLanguage.VBNet);
converter.IndentString = " ";
string code = converter.Convert(vbnetForNextCode);
string expectedCode =
"class Foo\r\n" +
" def GetCount()\r\n" +
" count = 0\r\n" +
" i = 0\r\n" +
" while i <= 4\r\n" +
" count += 1\r\n" +
" i = i + 1\r\n" +
" end\r\n" +
" return count\r\n" +
" end\r\n" +
"end";
Assert.AreEqual(expectedCode, code);
}
string vbnetForNextWithStepCode =
"Public Class Foo\r\n" +
" Public Function GetCount() As Integer\r\n" +
" Dim count As Integer = 0\r\n" +
" For i As Integer = 0 To 4 Step 2\r\n" +
" count += 1\r\n" +
" Next\r\n" +
" Return count\r\n" +
" End Function\r\n" +
"End Class\r\n";
[Test]
public void ConvertVBNetForNextWithStepToRuby()
{
NRefactoryToRubyConverter converter = new NRefactoryToRubyConverter(SupportedLanguage.VBNet);
converter.IndentString = " ";
string code = converter.Convert(vbnetForNextWithStepCode);
string expectedCode =
"class Foo\r\n" +
" def GetCount()\r\n" +
" count = 0\r\n" +
" i = 0\r\n" +
" while i <= 4\r\n" +
" count += 1\r\n" +
" i = i + 2\r\n" +
" end\r\n" +
" return count\r\n" +
" end\r\n" +
"end";
Assert.AreEqual(expectedCode, code);
}
}
}

2
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/LocalVariableAssignedInConstructorTestFixture.cs

@ -40,6 +40,6 @@ namespace RubyBinding.Tests.Converter @@ -40,6 +40,6 @@ namespace RubyBinding.Tests.Converter
"end";
Assert.AreEqual(expectedRuby, Ruby);
}
}
}
}

64
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/LocalVariableDefinitionsOnSameLineTests.cs

@ -0,0 +1,64 @@ @@ -0,0 +1,64 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.NRefactory;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
namespace RubyBinding.Tests.Converter
{
[TestFixture]
public class LocalVariableDefinitionsOnSameLineTests
{
string csharp =
"class Foo\r\n" +
"{\r\n" +
" public Foo()\r\n" +
" {\r\n" +
" int i = 0, i = 2;\r\n" +
" }\r\n" +
"}";
[Test]
public void ConvertedRubyCode()
{
NRefactoryToRubyConverter converter = new NRefactoryToRubyConverter(SupportedLanguage.CSharp);
converter.IndentString = " ";
string Ruby = converter.Convert(csharp);
string expectedRuby =
"class Foo\r\n" +
" def initialize()\r\n" +
" i = 0\r\n" +
" i = 2\r\n" +
" end\r\n" +
"end";
Assert.AreEqual(expectedRuby, Ruby);
}
string vnetClassWithTwoArrayLocalVariablesOnSameLine =
"class Foo\r\n" +
" Public Sub New()\r\n" +
" Dim i(10), j(20) as integer\r\n" +
" End Sub\r\n" +
"end class";
[Test]
public void ConvertVBNetClassWithTwoArrayVariablesOnSameLine()
{
NRefactoryToRubyConverter converter = new NRefactoryToRubyConverter(SupportedLanguage.VBNet);
converter.IndentString = " ";
string ruby = converter.Convert(vnetClassWithTwoArrayLocalVariablesOnSameLine);
string expectedRuby =
"class Foo\r\n" +
" def initialize()\r\n" +
" i = Array.CreateInstance(System::Int32, 10)\r\n" +
" j = Array.CreateInstance(System::Int32, 20)\r\n" +
" end\r\n" +
"end";
Assert.AreEqual(expectedRuby, ruby);
}
}
}

115
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/MultipleFieldsOnSameLineTests.cs

@ -0,0 +1,115 @@ @@ -0,0 +1,115 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.NRefactory;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
namespace RubyBinding.Tests.Converter
{
[TestFixture]
public class MultipleFieldsOnSameLineTests
{
string csharpClassWithFieldsThatHaveInitialValues =
"class Foo\r\n" +
"{\r\n" +
" int i = 0, j = 1;\r\n" +
"}";
[Test]
public void ConvertCSharpClassWithFieldsThatHaveInitialValues()
{
NRefactoryToRubyConverter converter = new NRefactoryToRubyConverter(SupportedLanguage.CSharp);
converter.IndentString = " ";
string ruby = converter.Convert(csharpClassWithFieldsThatHaveInitialValues);
string expectedRuby =
"class Foo\r\n" +
" def initialize()\r\n" +
" @i = 0\r\n" +
" @j = 1\r\n" +
" end\r\n" +
"end";
Assert.AreEqual(expectedRuby, ruby);
}
string csharpClassWithTwoFieldsWhereFirstDoesNotHaveInitialValue =
"class Foo\r\n" +
"{\r\n" +
" int i, j = 1;\r\n" +
"}";
[Test]
public void ConvertCSharpClassWithFieldsWhereFirstFieldDoesNotHaveInitialValue()
{
NRefactoryToRubyConverter converter = new NRefactoryToRubyConverter(SupportedLanguage.CSharp);
converter.IndentString = " ";
string ruby = converter.Convert(csharpClassWithTwoFieldsWhereFirstDoesNotHaveInitialValue);
string expectedRuby =
"class Foo\r\n" +
" def initialize()\r\n" +
" @j = 1\r\n" +
" end\r\n" +
"end";
Assert.AreEqual(expectedRuby, ruby);
}
string csharpClassWithTwoFieldsInitializedInMethod =
"class Foo\r\n" +
"{\r\n" +
" int i = 0;\r\n" +
" int j, k;\r\n" +
"\r\n" +
" public void Test()\r\n" +
" {\r\n" +
" j = 1;\r\n" +
" k = 3;\r\n" +
" }\r\n" +
"}";
[Test]
public void ConvertCSharpClassWithTwoFieldsInitializedInMethod()
{
NRefactoryToRubyConverter converter = new NRefactoryToRubyConverter(SupportedLanguage.CSharp);
converter.IndentString = " ";
string ruby = converter.Convert(csharpClassWithTwoFieldsInitializedInMethod);
string expectedRuby =
"class Foo\r\n" +
" def initialize()\r\n" +
" @i = 0\r\n" +
" end\r\n" +
"\r\n" +
" def Test()\r\n" +
" @j = 1\r\n" +
" @k = 3\r\n" +
" end\r\n" +
"end";
Assert.AreEqual(expectedRuby, ruby);
}
string vnetClassWithTwoArrayFieldsOnSameLine =
"class Foo\r\n" +
" Private i(10), j(20) as integer\r\n" +
"end class";
[Test]
public void ConvertVBNetClassWithTwoArrayFieldsOnSameLine()
{
NRefactoryToRubyConverter converter = new NRefactoryToRubyConverter(SupportedLanguage.VBNet);
converter.IndentString = " ";
string ruby = converter.Convert(vnetClassWithTwoArrayFieldsOnSameLine);
string expectedRuby =
"class Foo\r\n" +
" def initialize()\r\n" +
" @i = Array.CreateInstance(System::Int32, 10)\r\n" +
" @j = Array.CreateInstance(System::Int32, 20)\r\n" +
" end\r\n" +
"end";
Assert.AreEqual(expectedRuby, ruby);
}
}
}

41
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/VBExitConversionTests.cs

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.NRefactory;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
namespace RubyBinding.Tests.Converter
{
[TestFixture]
public class VBExitConversionTests
{
string vb =
"Public Class Class1\r\n" +
" Public Sub Test\r\n" +
" While True\r\n" +
" Exit While\r\n" +
" End While\r\n" +
" End Sub\r\n" +
"End Class\r\n";
[Test]
public void ConvertedRubyCode()
{
NRefactoryToRubyConverter converter = new NRefactoryToRubyConverter(SupportedLanguage.VBNet);
converter.IndentString = " ";
string ruby = converter.Convert(vb);
string expectedRuby =
"class Class1\r\n" +
" def Test()\r\n" +
" while true\r\n" +
" break\r\n" +
" end\r\n" +
" end\r\n" +
"end";
Assert.AreEqual(expectedRuby, ruby);
}
}
}

4
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyBinding.Tests.csproj

@ -103,6 +103,7 @@ @@ -103,6 +103,7 @@
<Compile Include="Converter\ForeachConversionTestFixture.cs" />
<Compile Include="Converter\ForeachConversionWithMethodCallTestFixture.cs" />
<Compile Include="Converter\ForLoopConversionTestFixture.cs" />
<Compile Include="Converter\ForNextConversionTests.cs" />
<Compile Include="Converter\GenerateMainMethodCallTestFixture.cs" />
<Compile Include="Converter\GenericListConversionTestFixture.cs" />
<Compile Include="Converter\IfBlockStatementConversionTestFixture.cs" />
@ -114,6 +115,7 @@ @@ -114,6 +115,7 @@
<Compile Include="Converter\IntegerMethodParameterTestFixture.cs" />
<Compile Include="Converter\LocalVariableAssignedInConstructorTestFixture.cs" />
<Compile Include="Converter\LocalVariableDeclarationInIfStatementTestFixture.cs" />
<Compile Include="Converter\LocalVariableDefinitionsOnSameLineTests.cs" />
<Compile Include="Converter\LocalVariableNotInitializedTestFixture.cs" />
<Compile Include="Converter\MethodCallInConstructorTestFixture.cs" />
<Compile Include="Converter\MethodParameterConversionTestFixture.cs" />
@ -121,6 +123,7 @@ @@ -121,6 +123,7 @@
<Compile Include="Converter\MethodWithBodyConversionTestFixture.cs" />
<Compile Include="Converter\ModulusOperatorConversionTestFixture.cs" />
<Compile Include="Converter\MultiLineCommentConversionTestFixture.cs" />
<Compile Include="Converter\MultipleFieldsOnSameLineTests.cs" />
<Compile Include="Converter\NestedClassConversionTestFixture.cs" />
<Compile Include="Converter\NestedIfStatementConversionTestFixture.cs" />
<Compile Include="Converter\NullConversionTestFixture.cs" />
@ -146,6 +149,7 @@ @@ -146,6 +149,7 @@
<Compile Include="Converter\UnaryOperatorConversionTests.cs" />
<Compile Include="Converter\UsingStatementConversionTestFixture.cs" />
<Compile Include="Converter\VBClassConversionTestFixture.cs" />
<Compile Include="Converter\VBExitConversionTests.cs" />
<Compile Include="Converter\VBStringConcatTestFixture.cs" />
<Compile Include="Converter\WhileLoopConversionTestFixture.cs" />
<Compile Include="Converter\XmlDocCommentConversionTestFixture.cs" />

9
src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchReplaceUtilities.cs

@ -30,10 +30,15 @@ namespace SearchAndReplace @@ -30,10 +30,15 @@ namespace SearchAndReplace
}
}
static bool IsWordPart(char c)
{
return char.IsLetterOrDigit(c) || c == '_';
}
public static bool IsWholeWordAt(IDocument document, int offset, int length)
{
return (offset - 1 < 0 || Char.IsWhiteSpace(document.GetCharAt(offset - 1))) &&
(offset + length + 1 >= document.TextLength || Char.IsWhiteSpace(document.GetCharAt(offset + length)));
return (offset - 1 < 0 || !IsWordPart(document.GetCharAt(offset - 1))) &&
(offset + length + 1 >= document.TextLength || !IsWordPart(document.GetCharAt(offset + length)));
}
public static ISearchStrategy CreateSearchStrategy(SearchStrategyType type)

10
src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchStrategy/BruteForceSearchStrategy.cs

@ -34,17 +34,11 @@ namespace SearchAndReplace @@ -34,17 +34,11 @@ namespace SearchAndReplace
return true;
}
bool IsWholeWordAt(IDocument document, int offset, int length)
{
return (offset - 1 < 0 || !Char.IsLetterOrDigit(document.GetCharAt(offset - 1))) &&
(offset + length + 1 >= document.TextLength || !Char.IsLetterOrDigit(document.GetCharAt(offset + length)));
}
int InternalFindNext(ITextIterator textIterator)
{
while (textIterator.MoveAhead(1)) {
if (SearchOptions.MatchCase ? MatchCaseSensitive(textIterator.Document, textIterator.Position, searchPattern) : MatchCaseInsensitive(textIterator.Document, textIterator.Position, searchPattern)) {
if (!SearchOptions.MatchWholeWord || IsWholeWordAt(textIterator.Document, textIterator.Position, searchPattern.Length)) {
if (!SearchOptions.MatchWholeWord || SearchReplaceUtilities.IsWholeWordAt(textIterator.Document, textIterator.Position, searchPattern.Length)) {
return textIterator.Position;
}
}
@ -59,7 +53,7 @@ namespace SearchAndReplace @@ -59,7 +53,7 @@ namespace SearchAndReplace
textIterator.Position = offset;
}
if (SearchOptions.MatchCase ? MatchCaseSensitive(textIterator.Document, textIterator.Position, searchPattern) : MatchCaseInsensitive(textIterator.Document, textIterator.Position, searchPattern)) {
if (!SearchOptions.MatchWholeWord || IsWholeWordAt(textIterator.Document, textIterator.Position, searchPattern.Length)) {
if (!SearchOptions.MatchWholeWord || SearchReplaceUtilities.IsWholeWordAt(textIterator.Document, textIterator.Position, searchPattern.Length)) {
if (TextSelection.IsInsideRange(textIterator.Position + searchPattern.Length - 1, offset, length)) {
return textIterator.Position;
} else {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs

@ -51,7 +51,7 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -51,7 +51,7 @@ namespace ICSharpCode.AvalonEdit.Editing
AddBinding(EditingCommands.Delete, ModifierKeys.None, Key.Delete, OnDelete(EditingCommands.SelectRightByCharacter));
AddBinding(EditingCommands.DeleteNextWord, ModifierKeys.Control, Key.Delete, OnDelete(EditingCommands.SelectRightByWord));
AddBinding(EditingCommands.Backspace, ModifierKeys.None, Key.Back, OnDelete(EditingCommands.SelectLeftByCharacter));
InputBindings.Add(new KeyBinding(EditingCommands.Backspace, Key.Back, ModifierKeys.Shift)); // make Shift-Backspace do the same as plain backspace
InputBindings.Add(TextAreaDefaultInputHandler.CreateFrozenKeyBinding(EditingCommands.Backspace, ModifierKeys.Shift, Key.Back)); // make Shift-Backspace do the same as plain backspace
AddBinding(EditingCommands.DeletePreviousWord, ModifierKeys.Control, Key.Back, OnDelete(EditingCommands.SelectLeftByWord));
AddBinding(EditingCommands.EnterParagraphBreak, ModifierKeys.None, Key.Enter, OnEnter);
AddBinding(EditingCommands.EnterLineBreak, ModifierKeys.Shift, Key.Enter, OnEnter);

16
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs

@ -230,6 +230,14 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -230,6 +230,14 @@ namespace ICSharpCode.AvalonEdit.Rendering
sealed class SpecialCharacterTextRun : FormattedTextRun
{
static readonly SolidColorBrush darkGrayBrush;
static SpecialCharacterTextRun()
{
darkGrayBrush = new SolidColorBrush(Color.FromArgb(200, 128, 128, 128));
darkGrayBrush.Freeze();
}
public SpecialCharacterTextRun(FormattedTextElement element, TextRunProperties properties)
: base(element, properties)
{
@ -237,10 +245,10 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -237,10 +245,10 @@ namespace ICSharpCode.AvalonEdit.Rendering
public override void Draw(DrawingContext drawingContext, Point origin, bool rightToLeft, bool sideways)
{
Point newOrigin = new Point(origin.X + 1, origin.Y);
var metrics = Format(double.PositiveInfinity);
Rect r = new Rect(newOrigin.X + 1, newOrigin.Y - metrics.Baseline, metrics.Width + 1, metrics.Height);
drawingContext.DrawRoundedRectangle(Brushes.DarkGray, null, r, 2.5, 2.5);
Point newOrigin = new Point(origin.X + 1.5, origin.Y);
var metrics = base.Format(double.PositiveInfinity);
Rect r = new Rect(newOrigin.X - 0.5, newOrigin.Y - metrics.Baseline, metrics.Width + 2, metrics.Height);
drawingContext.DrawRoundedRectangle(darkGrayBrush, null, r, 2.5, 2.5);
base.Draw(drawingContext, newOrigin, rightToLeft, sideways);
}

112
src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs

@ -13,7 +13,6 @@ using System.Xml.Linq; @@ -13,7 +13,6 @@ using System.Xml.Linq;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Internal.Templates;
using ICSharpCode.SharpDevelop.Project.Converter;
using Microsoft.Build.Construction;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Exceptions;
@ -29,7 +28,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -29,7 +28,7 @@ namespace ICSharpCode.SharpDevelop.Project
/// require locking on the SyncRoot. Methods that return underlying MSBuild objects require that
/// the caller locks on the SyncRoot.
/// </summary>
public class MSBuildBasedProject : AbstractProject, IProjectItemListProvider
public class MSBuildBasedProject : AbstractProject, IProjectItemListProvider, IProjectAllowChangeConfigurations
{
/// <summary>
/// The project collection that contains this project.
@ -408,6 +407,9 @@ namespace ICSharpCode.SharpDevelop.Project @@ -408,6 +407,9 @@ namespace ICSharpCode.SharpDevelop.Project
try {
System.Threading.Monitor.Enter(this.SyncRoot, ref lockTaken);
if (projectFile == null)
throw new ObjectDisposedException("MSBuildBasedProject");
if (configuration == null)
configuration = this.ActiveConfiguration;
if (platform == null)
@ -1370,19 +1372,17 @@ namespace ICSharpCode.SharpDevelop.Project @@ -1370,19 +1372,17 @@ namespace ICSharpCode.SharpDevelop.Project
#endregion
#region IProjectAllowChangeConfigurations interface implementation
/*
bool IProjectAllowChangeConfigurations.RenameProjectConfiguration(string oldName, string newName)
{
lock (SyncRoot) {
foreach (MSBuild.BuildPropertyGroup g in project.PropertyGroups) {
if (g.IsImported) {
continue;
}
MSBuild.BuildProperty prop = MSBuildInternals.GetProperty(g, "Configuration");
if (prop != null && prop.Value == oldName) {
foreach (ProjectPropertyGroupElement g in projectFile.PropertyGroups.Concat(userProjectFile.PropertyGroups)) {
// Rename the default configuration setting
var prop = g.Properties.FirstOrDefault(p => p.Name == "Configuration");
if (prop != null && prop.Value == oldName) {
prop.Value = newName;
}
// Rename the configuration in conditions
string gConfiguration, gPlatform;
MSBuildInternals.GetConfigurationAndPlatformFromCondition(g.Condition,
out gConfiguration,
@ -1399,15 +1399,14 @@ namespace ICSharpCode.SharpDevelop.Project @@ -1399,15 +1399,14 @@ namespace ICSharpCode.SharpDevelop.Project
bool IProjectAllowChangeConfigurations.RenameProjectPlatform(string oldName, string newName)
{
lock (SyncRoot) {
foreach (MSBuild.BuildPropertyGroup g in project.PropertyGroups) {
if (g.IsImported) {
continue;
}
MSBuild.BuildProperty prop = MSBuildInternals.GetProperty(g, "Platform");
if (prop != null && prop.Value == oldName) {
foreach (ProjectPropertyGroupElement g in projectFile.PropertyGroups.Concat(userProjectFile.PropertyGroups)) {
// Rename the default platform setting
var prop = g.Properties.FirstOrDefault(p => p.Name == "Platform");
if (prop != null && prop.Value == oldName) {
prop.Value = newName;
}
// Rename the platform in conditions
string gConfiguration, gPlatform;
MSBuildInternals.GetConfigurationAndPlatformFromCondition(g.Condition,
out gConfiguration,
@ -1424,27 +1423,30 @@ namespace ICSharpCode.SharpDevelop.Project @@ -1424,27 +1423,30 @@ namespace ICSharpCode.SharpDevelop.Project
bool IProjectAllowChangeConfigurations.AddProjectConfiguration(string newName, string copyFrom)
{
lock (SyncRoot) {
bool copiedGroup = false;
bool copiedGroupInMainFile = false;
if (copyFrom != null) {
foreach (MSBuild.BuildPropertyGroup g
in project.PropertyGroups.Cast<MSBuild.BuildPropertyGroup>().ToList())
{
if (g.IsImported) {
continue;
foreach (ProjectPropertyGroupElement g in projectFile.PropertyGroups.ToList()) {
string gConfiguration, gPlatform;
MSBuildInternals.GetConfigurationAndPlatformFromCondition(g.Condition,
out gConfiguration,
out gPlatform);
if (gConfiguration == copyFrom) {
CopyProperties(projectFile, g, newName, gPlatform);
copiedGroupInMainFile = true;
}
}
foreach (ProjectPropertyGroupElement g in userProjectFile.PropertyGroups.ToList()) {
string gConfiguration, gPlatform;
MSBuildInternals.GetConfigurationAndPlatformFromCondition(g.Condition,
out gConfiguration,
out gPlatform);
if (gConfiguration == copyFrom) {
CopyProperties(g, newName, gPlatform);
copiedGroup = true;
CopyProperties(userProjectFile, g, newName, gPlatform);
}
}
}
if (!copiedGroup) {
project.AddNewPropertyGroup(false).Condition = CreateCondition(newName, null);
if (!copiedGroupInMainFile) {
projectFile.AddPropertyGroup().Condition = CreateCondition(newName, null);
}
LoadConfigurationPlatformNamesFromMSBuild();
return true;
@ -1454,27 +1456,30 @@ namespace ICSharpCode.SharpDevelop.Project @@ -1454,27 +1456,30 @@ namespace ICSharpCode.SharpDevelop.Project
bool IProjectAllowChangeConfigurations.AddProjectPlatform(string newName, string copyFrom)
{
lock (SyncRoot) {
bool copiedGroup = false;
bool copiedGroupInMainFile = false;
if (copyFrom != null) {
foreach (MSBuild.BuildPropertyGroup g
in project.PropertyGroups.Cast<MSBuild.BuildPropertyGroup>().ToList())
{
if (g.IsImported) {
continue;
foreach (ProjectPropertyGroupElement g in projectFile.PropertyGroups.ToList()) {
string gConfiguration, gPlatform;
MSBuildInternals.GetConfigurationAndPlatformFromCondition(g.Condition,
out gConfiguration,
out gPlatform);
if (gPlatform == copyFrom) {
CopyProperties(projectFile, g, gConfiguration, newName);
copiedGroupInMainFile = true;
}
}
foreach (ProjectPropertyGroupElement g in userProjectFile.PropertyGroups.ToList()) {
string gConfiguration, gPlatform;
MSBuildInternals.GetConfigurationAndPlatformFromCondition(g.Condition,
out gConfiguration,
out gPlatform);
if (gPlatform == copyFrom) {
CopyProperties(g, gConfiguration, newName);
copiedGroup = true;
CopyProperties(userProjectFile, g, gConfiguration, newName);
}
}
}
if (!copiedGroup) {
project.AddNewPropertyGroup(false).Condition = CreateCondition(null, newName);
if (!copiedGroupInMainFile) {
projectFile.AddPropertyGroup().Condition = CreateCondition(null, newName);
}
LoadConfigurationPlatformNamesFromMSBuild();
return true;
@ -1484,12 +1489,12 @@ namespace ICSharpCode.SharpDevelop.Project @@ -1484,12 +1489,12 @@ namespace ICSharpCode.SharpDevelop.Project
/// <summary>
/// copy properties from g into a new property group for newConfiguration and newPlatform
/// </summary>
void CopyProperties(MSBuild.BuildPropertyGroup g, string newConfiguration, string newPlatform)
void CopyProperties(ProjectRootElement project, ProjectPropertyGroupElement g, string newConfiguration, string newPlatform)
{
MSBuild.BuildPropertyGroup ng = project.AddNewPropertyGroup(false);
ProjectPropertyGroupElement ng = project.AddPropertyGroup();
ng.Condition = CreateCondition(newConfiguration, newPlatform);
foreach (MSBuild.BuildProperty p in g) {
ng.AddNewProperty(p.Name, p.Value);
foreach (var p in g.Properties) {
ng.AddProperty(p.Name, p.Value).Condition = p.Condition;
}
}
@ -1506,14 +1511,8 @@ namespace ICSharpCode.SharpDevelop.Project @@ -1506,14 +1511,8 @@ namespace ICSharpCode.SharpDevelop.Project
if (otherConfigurationName == null) {
throw new InvalidOperationException("cannot remove the last configuration");
}
foreach (MSBuild.BuildPropertyGroup g
in project.PropertyGroups.Cast<MSBuild.BuildPropertyGroup>().ToList())
{
if (g.IsImported) {
continue;
}
MSBuild.BuildProperty prop = MSBuildInternals.GetProperty(g, "Configuration");
foreach (ProjectPropertyGroupElement g in projectFile.PropertyGroups.Concat(userProjectFile.PropertyGroups).ToList()) {
ProjectPropertyElement prop = g.Properties.FirstOrDefault(p => p.Name == "Configuration");
if (prop != null && prop.Value == name) {
prop.Value = otherConfigurationName;
}
@ -1523,7 +1522,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -1523,7 +1522,7 @@ namespace ICSharpCode.SharpDevelop.Project
out gConfiguration,
out gPlatform);
if (gConfiguration == name) {
project.RemovePropertyGroup(g);
g.Parent.RemoveChild(g);
}
}
LoadConfigurationPlatformNamesFromMSBuild();
@ -1544,14 +1543,8 @@ namespace ICSharpCode.SharpDevelop.Project @@ -1544,14 +1543,8 @@ namespace ICSharpCode.SharpDevelop.Project
if (otherPlatformName == null) {
throw new InvalidOperationException("cannot remove the last platform");
}
foreach (MSBuild.BuildPropertyGroup g
in project.PropertyGroups.Cast<MSBuild.BuildPropertyGroup>().ToList())
{
if (g.IsImported) {
continue;
}
MSBuild.BuildProperty prop = MSBuildInternals.GetProperty(g, "Platform");
foreach (ProjectPropertyGroupElement g in projectFile.PropertyGroups.Concat(userProjectFile.PropertyGroups).ToList()) {
ProjectPropertyElement prop = g.Properties.FirstOrDefault(p => p.Name == "Platform");
if (prop != null && prop.Value == name) {
prop.Value = otherPlatformName;
}
@ -1561,14 +1554,13 @@ namespace ICSharpCode.SharpDevelop.Project @@ -1561,14 +1554,13 @@ namespace ICSharpCode.SharpDevelop.Project
out gConfiguration,
out gPlatform);
if (gPlatform == name) {
project.RemovePropertyGroup(g);
g.Parent.RemoveChild(g);
}
}
LoadConfigurationPlatformNamesFromMSBuild();
return true;
}
}
*/
#endregion
#region ProjectExtensions

5
src/Main/Base/Project/Src/Services/DisplayBinding/DisplayBindingService.cs

@ -82,6 +82,11 @@ namespace ICSharpCode.SharpDevelop @@ -82,6 +82,11 @@ namespace ICSharpCode.SharpDevelop
public static IDisplayBinding GetBindingPerFileName(string filename)
{
WorkbenchSingleton.AssertMainThread();
if (FileUtility.IsUrl(filename)) {
// The normal display binding dispatching code can't handle URLs (e.g. because it uses Path.GetExtension),
// so we'll directly return the browser display binding.
return new BrowserDisplayBinding.BrowserDisplayBinding();
}
DisplayBindingDescriptor codon = GetDefaultCodonPerFileName(filename);
return codon == null ? null : codon.Binding;
}

13
src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs

@ -66,7 +66,7 @@ namespace ICSharpCode.SharpDevelop @@ -66,7 +66,7 @@ namespace ICSharpCode.SharpDevelop
if (reference != null) {
// TODO: Translate me
// progressMonitor.TaskName = "Loading " + reference.ShortName + "...";
AddReference(reference, false);
AddReference(reference, false, progressMonitor.CancellationToken);
}
}
}
@ -109,7 +109,7 @@ namespace ICSharpCode.SharpDevelop @@ -109,7 +109,7 @@ namespace ICSharpCode.SharpDevelop
}
}
void AddReference(ReferenceProjectItem reference, bool updateInterDependencies)
void AddReference(ReferenceProjectItem reference, bool updateInterDependencies, CancellationToken cancellationToken)
{
try {
AddReferencedContent(AssemblyParserService.GetProjectContentForReference(reference));
@ -122,6 +122,13 @@ namespace ICSharpCode.SharpDevelop @@ -122,6 +122,13 @@ namespace ICSharpCode.SharpDevelop
// If the user removes the reference and then re-adds it, there might be other references
// in the project depending on it, so we do the refresh after the old reference was added.
AssemblyParserService.RefreshProjectContentForReference(reference);
} catch (OperationCanceledException) {
throw;
} catch (ObjectDisposedException e) {
// ObjectDisposedException can happen if project gets disposed while LoadSolutionProjectsThread is running.
// We will ignore the ObjectDisposedException and throw OperationCanceledException instead.
cancellationToken.ThrowIfCancellationRequested();
MessageService.ShowException(e);
} catch (Exception e) {
MessageService.ShowException(e);
}
@ -268,7 +275,7 @@ namespace ICSharpCode.SharpDevelop @@ -268,7 +275,7 @@ namespace ICSharpCode.SharpDevelop
double fileCountInverse = 1.0 / fileContents.Count;
Parallel.ForEach(
fileContents,
new ParallelOptions {
new ParallelOptions {
MaxDegreeOfParallelism = Environment.ProcessorCount * 2,
CancellationToken = progressMonitor.CancellationToken
},

Loading…
Cancel
Save