diff --git a/Tests/TestData/MultiFileCharacterization/CSToVBResults/ConvertCSharpConsoleAppOnly/CharacterizationTestSolution.sln b/Tests/TestData/MultiFileCharacterization/CSToVBResults/ConvertCSharpConsoleAppOnly/CharacterizationTestSolution.sln index c691a6484..8ea27f224 100644 --- a/Tests/TestData/MultiFileCharacterization/CSToVBResults/ConvertCSharpConsoleAppOnly/CharacterizationTestSolution.sln +++ b/Tests/TestData/MultiFileCharacterization/CSToVBResults/ConvertCSharpConsoleAppOnly/CharacterizationTestSolution.sln @@ -1,7 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29503.13 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34321.82 MinimumVisualStudioVersion = 10.0.40219.1 Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WindowsAppVb", "WindowsAppVb\WindowsAppVb.vbproj", "{D18AB89D-1897-4779-A937-F48661E0B6B8}" EndProject @@ -14,7 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ユニコード.txt = ユニコード.txt EndProjectSection EndProject -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VbLibrary", "VbLibrary\VbLibrary.vbproj", "{23195658-FBE7-4A3E-B79D-91AAC2D428E7}" +Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "VbLibrary", "VbLibrary\VbLibrary.vbproj", "{23195658-FBE7-4A3E-B79D-91AAC2D428E7}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "VbNetStandardLib", "VbNetStandardLib\VbNetStandardLib.vbproj", "{FBFBE639-A532-408A-960D-288E05FEEB0E}" EndProject diff --git a/Tests/TestData/MultiFileCharacterization/CSToVBResults/ConvertWholeSolution/CharacterizationTestSolution.sln b/Tests/TestData/MultiFileCharacterization/CSToVBResults/ConvertWholeSolution/CharacterizationTestSolution.sln index ba6b46bc2..d462a1431 100644 --- a/Tests/TestData/MultiFileCharacterization/CSToVBResults/ConvertWholeSolution/CharacterizationTestSolution.sln +++ b/Tests/TestData/MultiFileCharacterization/CSToVBResults/ConvertWholeSolution/CharacterizationTestSolution.sln @@ -1,7 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29503.13 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34321.82 MinimumVisualStudioVersion = 10.0.40219.1 Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WindowsAppVb", "WindowsAppVb\WindowsAppVb.vbproj", "{D18AB89D-1897-4779-A937-F48661E0B6B8}" EndProject @@ -14,7 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ユニコード.txt = ユニコード.txt EndProjectSection EndProject -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VbLibrary", "VbLibrary\VbLibrary.vbproj", "{23195658-FBE7-4A3E-B79D-91AAC2D428E7}" +Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "VbLibrary", "VbLibrary\VbLibrary.vbproj", "{23195658-FBE7-4A3E-B79D-91AAC2D428E7}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "VbNetStandardLib", "VbNetStandardLib\VbNetStandardLib.vbproj", "{FBFBE639-A532-408A-960D-288E05FEEB0E}" EndProject diff --git a/Tests/TestData/MultiFileCharacterization/SourceFiles/CharacterizationTestSolution.sln b/Tests/TestData/MultiFileCharacterization/SourceFiles/CharacterizationTestSolution.sln index 0b3b638e7..62d9b2f64 100644 --- a/Tests/TestData/MultiFileCharacterization/SourceFiles/CharacterizationTestSolution.sln +++ b/Tests/TestData/MultiFileCharacterization/SourceFiles/CharacterizationTestSolution.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29503.13 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34321.82 MinimumVisualStudioVersion = 10.0.40219.1 Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WindowsAppVb", "WindowsAppVb\WindowsAppVb.vbproj", "{D18AB89D-1897-4779-A937-F48661E0B6B8}" EndProject @@ -14,7 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ユニコード.txt = ユニコード.txt EndProjectSection EndProject -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VbLibrary", "VbLibrary\VbLibrary.vbproj", "{23195658-FBE7-4A3E-B79D-91AAC2D428E7}" +Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "VbLibrary", "VbLibrary\VbLibrary.vbproj", "{23195658-FBE7-4A3E-B79D-91AAC2D428E7}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "VbNetStandardLib", "VbNetStandardLib\VbNetStandardLib.vbproj", "{FBFBE639-A532-408A-960D-288E05FEEB0E}" EndProject diff --git a/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/Application.Designer.vb b/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/Application.Designer.vb deleted file mode 100644 index 88dd01c78..000000000 --- a/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/Application.Designer.vb +++ /dev/null @@ -1,13 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - diff --git a/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/Application.myapp b/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/Application.myapp deleted file mode 100644 index e62f1a533..000000000 --- a/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/Application.myapp +++ /dev/null @@ -1,10 +0,0 @@ - - - false - false - 0 - true - 0 - 2 - true - diff --git a/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/AssemblyInfo.vb b/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/AssemblyInfo.vb deleted file mode 100644 index 929058750..000000000 --- a/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/AssemblyInfo.vb +++ /dev/null @@ -1,35 +0,0 @@ -Imports System -Imports System.Reflection -Imports System.Runtime.InteropServices - -' General Information about an assembly is controlled through the following -' set of attributes. Change these attribute values to modify the information -' associated with an assembly. - -' Review the values of the assembly attributes - - - - - - - - - - -'The following GUID is for the ID of the typelib if this project is exposed to COM - - -' Version information for an assembly consists of the following four values: -' -' Major Version -' Minor Version -' Build Number -' Revision -' -' You can specify all the values or you can default the Build and Revision Numbers -' by using the '*' as shown below: -' - - - diff --git a/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/Resources.Designer.vb b/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/Resources.Designer.vb deleted file mode 100644 index c33d2e57f..000000000 --- a/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/Resources.Designer.vb +++ /dev/null @@ -1,63 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - -Imports System - -Namespace My.Resources - - 'This class was auto-generated by the StronglyTypedResourceBuilder - 'class via a tool like ResGen or Visual Studio. - 'To add or remove a member, edit your .ResX file then rerun ResGen - 'with the /str option, or rebuild your VS project. - ''' - ''' A strongly-typed resource class, for looking up localized strings, etc. - ''' - _ - Friend Module Resources - - Private resourceMan As Global.System.Resources.ResourceManager - - Private resourceCulture As Global.System.Globalization.CultureInfo - - ''' - ''' Returns the cached ResourceManager instance used by this class. - ''' - _ - Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager - Get - If Object.ReferenceEquals(resourceMan, Nothing) Then - Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("VbLibrary.Resources", GetType(Resources).Assembly) - resourceMan = temp - End If - Return resourceMan - End Get - End Property - - ''' - ''' Overrides the current thread's CurrentUICulture property for all - ''' resource lookups using this strongly typed resource class. - ''' - _ - Friend Property Culture() As Global.System.Globalization.CultureInfo - Get - Return resourceCulture - End Get - Set - resourceCulture = value - End Set - End Property - End Module -End Namespace diff --git a/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/Resources.resx b/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/Resources.resx deleted file mode 100644 index ea9cbcdb4..000000000 --- a/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - diff --git a/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/Settings.Designer.vb b/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/Settings.Designer.vb deleted file mode 100644 index 12ed0fde5..000000000 --- a/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/Settings.Designer.vb +++ /dev/null @@ -1,73 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - - -Namespace My - - _ - Partial Friend NotInheritable Class MySettings - Inherits Global.System.Configuration.ApplicationSettingsBase - - Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) - -#Region "My.Settings Auto-Save Functionality" -#If _MyType = "WindowsForms" Then - Private Shared addedHandler As Boolean - - Private Shared addedHandlerLockObject As New Object - - _ - Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) - If My.Application.SaveMySettingsOnExit Then - My.Settings.Save() - End If - End Sub -#End If -#End Region - - Public Shared ReadOnly Property [Default]() As MySettings - Get - -#If _MyType = "WindowsForms" Then - If Not addedHandler Then - SyncLock addedHandlerLockObject - If Not addedHandler Then - AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings - addedHandler = True - End If - End SyncLock - End If -#End If - Return defaultInstance - End Get - End Property - End Class -End Namespace - -Namespace My - - _ - Friend Module MySettingsProperty - - _ - Friend ReadOnly Property Settings() As Global.VbLibrary.My.MySettings - Get - Return Global.VbLibrary.My.MySettings.Default - End Get - End Property - End Module -End Namespace diff --git a/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/Settings.settings b/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/Settings.settings deleted file mode 100644 index 85b890b3c..000000000 --- a/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/My Project/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/VbLibrary.vbproj b/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/VbLibrary.vbproj index a9ae1619f..9824bd491 100644 --- a/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/VbLibrary.vbproj +++ b/Tests/TestData/MultiFileCharacterization/SourceFiles/VbLibrary/VbLibrary.vbproj @@ -1,124 +1,14 @@ - - - - - Debug - AnyCPU - {23195658-FBE7-4A3E-B79D-91AAC2D428E7} - Exe - VbLibrary.Module1 - VbLibrary - VbLibrary - 512 - Console - v4.8 - true - true - - - - AnyCPU - true - full - true - true - bin\Debug\ - VbLibrary.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - AnyCPU - pdbonly - false - true - true - bin\Release\ - VbLibrary.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - On - - - Binary - - - Off - - - On - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - Application.myapp - True - - - True - True - Resources.resx - - - True - Settings.settings - True - - - - - - - VbMyResourcesResXFileCodeGenerator - Resources.Designer.vb - My.Resources - Designer - - - - - MyApplicationCodeGenerator - Application.Designer.vb - - - SettingsSingleFileGenerator - My - Settings.Designer.vb - - - - - - {fbfbe639-a532-408a-960d-288e05feeb0e} - VbNetStandardLib - - - - \ No newline at end of file + + + + VbLibrary + netstandard2.1 + + + + + + + + + diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/CharacterizationTestSolution.sln b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/CharacterizationTestSolution.sln index 514ea32ee..bb2bf81ad 100644 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/CharacterizationTestSolution.sln +++ b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/CharacterizationTestSolution.sln @@ -1,7 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29503.13 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34321.82 MinimumVisualStudioVersion = 10.0.40219.1 Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WindowsAppVb", "WindowsAppVb\WindowsAppVb.vbproj", "{D18AB89D-1897-4779-A937-F48661E0B6B8}" EndProject @@ -14,7 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ユニコード.txt = ユニコード.txt EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VbLibrary", "VbLibrary\VbLibrary.csproj", "{913DD733-37BF-05CF-35C5-5BD4A0431C47}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VbLibrary", "VbLibrary\VbLibrary.csproj", "{913DD733-37BF-05CF-35C5-5BD4A0431C47}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "VbNetStandardLib", "VbNetStandardLib\VbNetStandardLib.vbproj", "{FBFBE639-A532-408A-960D-288E05FEEB0E}" EndProject diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/Application.Designer.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/Application.Designer.cs deleted file mode 100644 index 3d3b640fe..000000000 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/Application.Designer.cs +++ /dev/null @@ -1,11 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - - diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/AssemblyInfo.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/AssemblyInfo.cs deleted file mode 100644 index 4e045305e..000000000 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -// Review the values of the assembly attributes - -[assembly: AssemblyTitle("EmptyVb")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("EmptyVb")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("bc4666bc-3a80-4eb9-a9ce-7c7714d2487d")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// - -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/MyNamespace.Static.1.Designer.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/MyNamespace.Static.1.Designer.cs index bc8a7acd6..75d58675f 100644 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/MyNamespace.Static.1.Designer.cs +++ b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/MyNamespace.Static.1.Designer.cs @@ -3,468 +3,14 @@ // See the LICENSE file in the project root for more information. using System; -using System.Diagnostics; -using Microsoft.VisualBasic; -/* TODO ERROR: Skipped IfDirectiveTrivia -#If TARGET = "module" AndAlso _MYTYPE = "" Then -*//* TODO ERROR: Skipped DisabledTextTrivia -#Const _MYTYPE="Empty" -*//* TODO ERROR: Skipped EndIfDirectiveTrivia -#End If -*/ -/* TODO ERROR: Skipped IfDirectiveTrivia -#If _MYTYPE = "WindowsForms" Then -*//* TODO ERROR: Skipped DisabledTextTrivia - -#Const _MYFORMS = True -#Const _MYWEBSERVICES = True -#Const _MYUSERTYPE = "Windows" -#Const _MYCOMPUTERTYPE = "Windows" -#Const _MYAPPLICATIONTYPE = "WindowsForms" - -*//* TODO ERROR: Skipped ElifDirectiveTrivia -#ElseIf _MYTYPE = "WindowsFormsWithCustomSubMain" Then -*//* TODO ERROR: Skipped DisabledTextTrivia - -#Const _MYFORMS = True -#Const _MYWEBSERVICES = True -#Const _MYUSERTYPE = "Windows" -#Const _MYCOMPUTERTYPE = "Windows" -#Const _MYAPPLICATIONTYPE = "Console" - -*//* TODO ERROR: Skipped ElifDirectiveTrivia -#ElseIf _MYTYPE = "Windows" OrElse _MYTYPE = "" Then -*//* TODO ERROR: Skipped DisabledTextTrivia - -#Const _MYWEBSERVICES = True -#Const _MYUSERTYPE = "Windows" -#Const _MYCOMPUTERTYPE = "Windows" -#Const _MYAPPLICATIONTYPE = "Windows" - -*//* TODO ERROR: Skipped ElifDirectiveTrivia -#ElseIf _MYTYPE = "Console" Then -*/ -/* TODO ERROR: Skipped DefineDirectiveTrivia -#Const _MYWEBSERVICES = True -*//* TODO ERROR: Skipped DefineDirectiveTrivia -#Const _MYUSERTYPE = "Windows" -*//* TODO ERROR: Skipped DefineDirectiveTrivia -#Const _MYCOMPUTERTYPE = "Windows" -*//* TODO ERROR: Skipped DefineDirectiveTrivia -#Const _MYAPPLICATIONTYPE = "Console" -*/ -/* TODO ERROR: Skipped ElifDirectiveTrivia -#ElseIf _MYTYPE = "Web" Then -*//* TODO ERROR: Skipped DisabledTextTrivia - -#Const _MYFORMS = False -#Const _MYWEBSERVICES = False -#Const _MYUSERTYPE = "Web" -#Const _MYCOMPUTERTYPE = "Web" - -*//* TODO ERROR: Skipped ElifDirectiveTrivia -#ElseIf _MYTYPE = "WebControl" Then -*//* TODO ERROR: Skipped DisabledTextTrivia - -#Const _MYFORMS = False -#Const _MYWEBSERVICES = True -#Const _MYUSERTYPE = "Web" -#Const _MYCOMPUTERTYPE = "Web" - -*//* TODO ERROR: Skipped ElifDirectiveTrivia -#ElseIf _MYTYPE = "Custom" Then -*//* TODO ERROR: Skipped DisabledTextTrivia - -*//* TODO ERROR: Skipped ElifDirectiveTrivia -#ElseIf _MYTYPE <> "Empty" Then -*//* TODO ERROR: Skipped DisabledTextTrivia - -#Const _MYTYPE = "Empty" - -*//* TODO ERROR: Skipped EndIfDirectiveTrivia -#End If -*/ -/* TODO ERROR: Skipped IfDirectiveTrivia -#If _MYTYPE <> "Empty" Then -*/ -namespace VbLibrary.My +namespace Microsoft.VisualBasic { - - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYAPPLICATIONTYPE = "WindowsForms" OrElse _MYAPPLICATIONTYPE = "Windows" OrElse _MYAPPLICATIONTYPE = "Console" Then - */ - [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYAPPLICATIONTYPE = "WindowsForms" Then - *//* TODO ERROR: Skipped DisabledTextTrivia - Inherits Global.Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase - #If TARGET = "winexe" Then - _ - Friend Shared Sub Main(ByVal Args As String()) - Try - Global.System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(MyApplication.UseCompatibleTextRendering()) - Finally - End Try - My.Application.Run(Args) - End Sub - #End If - - *//* TODO ERROR: Skipped ElifDirectiveTrivia - #ElseIf _MYAPPLICATIONTYPE = "Windows" Then - *//* TODO ERROR: Skipped DisabledTextTrivia - Inherits Global.Microsoft.VisualBasic.ApplicationServices.ApplicationBase - *//* TODO ERROR: Skipped ElifDirectiveTrivia - #ElseIf _MYAPPLICATIONTYPE = "Console" Then - */ - internal partial class MyApplication : Microsoft.VisualBasic.ApplicationServices.ConsoleApplicationBase - { - /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If '_MYAPPLICATIONTYPE = "WindowsForms" - */ - } - - /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If '#If _MYAPPLICATIONTYPE = "WindowsForms" Or _MYAPPLICATIONTYPE = "Windows" or _MYAPPLICATIONTYPE = "Console" - */ - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYCOMPUTERTYPE <> "" Then - */ - [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] + [Embedded()] + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Module | AttributeTargets.Assembly, Inherited = false)] [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYCOMPUTERTYPE = "Windows" Then - */ - internal partial class MyComputer : Microsoft.VisualBasic.Devices.Computer + [System.Runtime.CompilerServices.CompilerGenerated()] + internal sealed class Embedded : Attribute { - /* TODO ERROR: Skipped ElifDirectiveTrivia - #ElseIf _MYCOMPUTERTYPE = "Web" Then - *//* TODO ERROR: Skipped DisabledTextTrivia - Inherits Global.Microsoft.VisualBasic.Devices.ServerComputer - *//* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public MyComputer() : base() - { - } - } - /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - [HideModuleName()] - [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] - internal static class MyProject - { - - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYCOMPUTERTYPE <> "" Then - */ - [System.ComponentModel.Design.HelpKeyword("My.Computer")] - internal static MyComputer Computer - { - [DebuggerHidden()] - get - { - return m_ComputerObjectProvider.GetInstance; - } - } - - private readonly static ThreadSafeObjectProvider m_ComputerObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYAPPLICATIONTYPE = "Windows" Or _MYAPPLICATIONTYPE = "WindowsForms" Or _MYAPPLICATIONTYPE = "Console" Then - */ - [System.ComponentModel.Design.HelpKeyword("My.Application")] - internal static MyApplication Application - { - [DebuggerHidden()] - get - { - return m_AppObjectProvider.GetInstance; - } - } - private readonly static ThreadSafeObjectProvider m_AppObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYUSERTYPE = "Windows" Then - */ - [System.ComponentModel.Design.HelpKeyword("My.User")] - internal static Microsoft.VisualBasic.ApplicationServices.User User - { - [DebuggerHidden()] - get - { - return m_UserObjectProvider.GetInstance; - } - } - private readonly static ThreadSafeObjectProvider m_UserObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped ElifDirectiveTrivia - #ElseIf _MYUSERTYPE = "Web" Then - *//* TODO ERROR: Skipped DisabledTextTrivia - _ - Friend ReadOnly Property User() As Global.Microsoft.VisualBasic.ApplicationServices.WebUser - _ - Get - Return m_UserObjectProvider.GetInstance() - End Get - End Property - Private ReadOnly m_UserObjectProvider As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.ApplicationServices.WebUser) - *//* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYFORMS = True Then - *//* TODO ERROR: Skipped DisabledTextTrivia - - #Const STARTUP_MY_FORM_FACTORY = "My.MyProject.Forms" - - _ - Friend ReadOnly Property Forms() As MyForms - _ - Get - Return m_MyFormsObjectProvider.GetInstance() - End Get - End Property - - _ - _ - Friend NotInheritable Class MyForms - _ - Private Shared Function Create__Instance__(Of T As {New, Global.System.Windows.Forms.Form})(ByVal Instance As T) As T - If Instance Is Nothing OrElse Instance.IsDisposed Then - If m_FormBeingCreated IsNot Nothing Then - If m_FormBeingCreated.ContainsKey(GetType(T)) = True Then - Throw New Global.System.InvalidOperationException(Global.Microsoft.VisualBasic.CompilerServices.Utils.GetResourceString("WinForms_RecursiveFormCreate")) - End If - Else - m_FormBeingCreated = New Global.System.Collections.Hashtable() - End If - m_FormBeingCreated.Add(GetType(T), Nothing) - Try - Return New T() - Catch ex As Global.System.Reflection.TargetInvocationException When ex.InnerException IsNot Nothing - Dim BetterMessage As String = Global.Microsoft.VisualBasic.CompilerServices.Utils.GetResourceString("WinForms_SeeInnerException", ex.InnerException.Message) - Throw New Global.System.InvalidOperationException(BetterMessage, ex.InnerException) - Finally - m_FormBeingCreated.Remove(GetType(T)) - End Try - Else - Return Instance - End If - End Function - - _ - Private Sub Dispose__Instance__(Of T As Global.System.Windows.Forms.Form)(ByRef instance As T) - instance.Dispose() - instance = Nothing - End Sub - - _ - _ - Public Sub New() - MyBase.New() - End Sub - - Private Shared m_FormBeingCreated As Global.System.Collections.Hashtable - - Public Overrides Function Equals(ByVal o As Object) As Boolean - Return MyBase.Equals(o) - End Function - Public Overrides Function GetHashCode() As Integer - Return MyBase.GetHashCode - End Function - _ - Friend Overloads Function [GetType]() As Global.System.Type - Return GetType(MyForms) - End Function - Public Overrides Function ToString() As String - Return MyBase.ToString - End Function - End Class - - Private m_MyFormsObjectProvider As New ThreadSafeObjectProvider(Of MyForms) - - *//* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYWEBSERVICES = True Then - */ - [System.ComponentModel.Design.HelpKeyword("My.WebServices")] - internal static MyWebServices WebServices - { - [DebuggerHidden()] - get - { - return m_MyWebServicesObjectProvider.GetInstance; - } - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [MyGroupCollection("System.Web.Services.Protocols.SoapHttpClientProtocol", "Create__Instance__", "Dispose__Instance__", "")] - internal sealed class MyWebServices - { - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - public override bool Equals(object o) - { - return base.Equals(o); - } - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - public override int GetHashCode() - { - return base.GetHashCode(); - } - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - internal new Type GetType() - { - return typeof(MyWebServices); - } - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - public override string ToString() - { - return base.ToString(); - } - - [DebuggerHidden()] - private static T Create__Instance__(T instance) where T : new() - { - if (instance is null) - { - return new T(); - } - else - { - return instance; - } - } - - [DebuggerHidden()] - private void Dispose__Instance__(ref T instance) - { - instance = default(T); - } - - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public MyWebServices() : base() - { - } - } - - private readonly static ThreadSafeObjectProvider m_MyWebServicesObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYTYPE = "Web" Then - *//* TODO ERROR: Skipped DisabledTextTrivia - - _ - Friend ReadOnly Property Request() As Global.System.Web.HttpRequest - _ - Get - Dim CurrentContext As Global.System.Web.HttpContext = Global.System.Web.HttpContext.Current - If CurrentContext IsNot Nothing Then - Return CurrentContext.Request - End If - Return Nothing - End Get - End Property - - _ - Friend ReadOnly Property Response() As Global.System.Web.HttpResponse - _ - Get - Dim CurrentContext As Global.System.Web.HttpContext = Global.System.Web.HttpContext.Current - If CurrentContext IsNot Nothing Then - Return CurrentContext.Response - End If - Return Nothing - End Get - End Property - - _ - Friend ReadOnly Property Log() As Global.Microsoft.VisualBasic.Logging.AspLog - _ - Get - Return m_LogObjectProvider.GetInstance() - End Get - End Property - - Private ReadOnly m_LogObjectProvider As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Logging.AspLog) - - *//* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If '_MYTYPE="Web" - */ - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [System.Runtime.InteropServices.ComVisible(false)] - internal sealed class ThreadSafeObjectProvider where T : new() - { - internal T GetInstance - { - /* TODO ERROR: Skipped IfDirectiveTrivia - #If TARGET = "library" Then - *//* TODO ERROR: Skipped DisabledTextTrivia - _ - Get - Dim Value As T = m_Context.Value - If Value Is Nothing Then - Value = New T - m_Context.Value() = Value - End If - Return Value - End Get - *//* TODO ERROR: Skipped ElseDirectiveTrivia - #Else - */ - [DebuggerHidden()] - get - { - if (m_ThreadStaticValue is null) - m_ThreadStaticValue = new T(); - return m_ThreadStaticValue; - } - /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - } - - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public ThreadSafeObjectProvider() : base() - { - } - - /* TODO ERROR: Skipped IfDirectiveTrivia - #If TARGET = "library" Then - *//* TODO ERROR: Skipped DisabledTextTrivia - Private ReadOnly m_Context As New Global.Microsoft.VisualBasic.MyServices.Internal.ContextValue(Of T) - *//* TODO ERROR: Skipped ElseDirectiveTrivia - #Else - */ - [System.Runtime.CompilerServices.CompilerGenerated()] - [ThreadStatic()] - private static T m_ThreadStaticValue; - /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - } } -} -/* TODO ERROR: Skipped EndIfDirectiveTrivia -#End If -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/MyNamespace.Static.2.Designer.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/MyNamespace.Static.2.Designer.cs index 80fcd5596..bd7913e6f 100644 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/MyNamespace.Static.2.Designer.cs +++ b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/MyNamespace.Static.2.Designer.cs @@ -1,242 +1,1855 @@ -using System.Collections; -using System.Collections.Generic; -using System.Data; -using System.Diagnostics; -using System.Linq; -using System.Xml.Linq; -using Microsoft.VisualBasic; // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -// See Compiler::LoadXmlSolutionExtension -namespace VbLibrary.My +using System; +using System.Diagnostics; +using Microsoft.VisualBasic.CompilerServices; + +namespace Microsoft.VisualBasic { - [Embedded()] - [DebuggerNonUserCode()] - [System.Runtime.CompilerServices.CompilerGenerated()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal sealed class InternalXmlHelper + namespace CompilerServices { + [Embedded()] + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - private InternalXmlHelper() - { - } - public static string get_Value(IEnumerable source) + internal sealed class EmbeddedOperators { - foreach (XElement item in source) - return item.Value; - return null; + private EmbeddedOperators() + { + } + public static int CompareString(string Left, string Right, bool TextCompare) + { + if (ReferenceEquals(Left, Right)) + { + return 0; + } + if (Left is null) + { + if (Right.Length == 0) + { + return 0; + } + return -1; + } + if (Right is null) + { + if (Left.Length == 0) + { + return 0; + } + return 1; + } + int Result; + if (TextCompare) + { + var OptionCompareTextFlags = System.Globalization.CompareOptions.IgnoreCase | System.Globalization.CompareOptions.IgnoreWidth | System.Globalization.CompareOptions.IgnoreKanaType; + Result = Conversions.GetCultureInfo().CompareInfo.Compare(Left, Right, OptionCompareTextFlags); + } + else + { + Result = string.CompareOrdinal(Left, Right); + } + if (Result == 0) + { + return 0; + } + else if (Result > 0) + { + return 1; + } + else + { + return -1; + } + } } - - public static void set_Value(IEnumerable source, string value) + [Embedded()] + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal sealed class Conversions { - foreach (XElement item in source) + private Conversions() + { + } + private static object GetEnumValue(object Value) + { + var underlyingType = Enum.GetUnderlyingType(Value.GetType()); + if (underlyingType.Equals(typeof(sbyte))) + { + return (sbyte)Value; + } + else if (underlyingType.Equals(typeof(byte))) + { + return (byte)Value; + } + else if (underlyingType.Equals(typeof(short))) + { + return (short)Value; + } + else if (underlyingType.Equals(typeof(ushort))) + { + return (ushort)Value; + } + else if (underlyingType.Equals(typeof(int))) + { + return (int)Value; + } + else if (underlyingType.Equals(typeof(uint))) + { + return (uint)Value; + } + else if (underlyingType.Equals(typeof(long))) + { + return (long)Value; + } + else if (underlyingType.Equals(typeof(ulong))) + { + return (ulong)Value; + } + else + { + throw new InvalidCastException(); + } + } + public static bool ToBoolean(string Value) + { + if (Value is null) + { + Value = ""; + } + try + { + var loc = GetCultureInfo(); + if (loc.CompareInfo.Compare(Value, bool.FalseString, System.Globalization.CompareOptions.IgnoreCase) == 0) + { + return false; + } + else if (loc.CompareInfo.Compare(Value, bool.TrueString, System.Globalization.CompareOptions.IgnoreCase) == 0) + { + return true; + } + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return ToBoolean(i64Value); + } + return ToBoolean(ParseDouble(Value)); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + public static bool ToBoolean(object Value) + { + if (Value is null) + { + return false; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return (bool)Value; + } + else if (Value is sbyte) + { + return ToBoolean((sbyte)Value); + } + else if (Value is byte) + { + return ToBoolean((byte)Value); + } + else if (Value is short) + { + return ToBoolean((short)Value); + } + else if (Value is ushort) + { + return ToBoolean((ushort)Value); + } + else if (Value is int) + { + return ToBoolean((int)Value); + } + else if (Value is uint) + { + return ToBoolean((uint)Value); + } + else if (Value is long) + { + return ToBoolean((long)Value); + } + else if (Value is ulong) + { + return ToBoolean((ulong)Value); + } + else if (Value is decimal) + { + return ToBoolean((decimal)Value); + } + else if (Value is float) + { + return ToBoolean((float)Value); + } + else if (Value is double) + { + return ToBoolean((double)Value); + } + else if (Value is string) + { + return ToBoolean((string)Value); + } + throw new InvalidCastException(); + } + public static byte ToByte(string Value) + { + if (Value is null) + { + return 0; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return (byte)i64Value; + } + return (byte)Math.Round(ParseDouble(Value)); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + public static byte ToByte(object Value) + { + if (Value is null) + { + return 0; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToByte((bool)Value); + } + else if (Value is sbyte) + { + return (byte)(sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (byte)(short)Value; + } + else if (Value is ushort) + { + return (byte)(ushort)Value; + } + else if (Value is int) + { + return (byte)(int)Value; + } + else if (Value is uint) + { + return (byte)(uint)Value; + } + else if (Value is long) + { + return (byte)(long)Value; + } + else if (Value is ulong) + { + return (byte)(ulong)Value; + } + else if (Value is decimal) + { + return (byte)Math.Round((decimal)Value); + } + else if (Value is float) + { + return (byte)Math.Round((float)Value); + } + else if (Value is double) + { + return (byte)Math.Round((double)Value); + } + else if (Value is string) + { + return ToByte((string)Value); + } + throw new InvalidCastException(); + } + [CLSCompliant(false)] + public static sbyte ToSByte(string Value) + { + if (Value is null) + { + return 0; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return (sbyte)i64Value; + } + return (sbyte)Math.Round(ParseDouble(Value)); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + [CLSCompliant(false)] + public static sbyte ToSByte(object Value) + { + if (Value is null) + { + return 0; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToSByte((bool)Value); + } + else if (Value is sbyte) + { + return (sbyte)Value; + } + else if (Value is byte) + { + return (sbyte)(byte)Value; + } + else if (Value is short) + { + return (sbyte)(short)Value; + } + else if (Value is ushort) + { + return (sbyte)(ushort)Value; + } + else if (Value is int) + { + return (sbyte)(int)Value; + } + else if (Value is uint) + { + return (sbyte)(uint)Value; + } + else if (Value is long) + { + return (sbyte)(long)Value; + } + else if (Value is ulong) + { + return (sbyte)(ulong)Value; + } + else if (Value is decimal) + { + return (sbyte)Math.Round((decimal)Value); + } + else if (Value is float) + { + return (sbyte)Math.Round((float)Value); + } + else if (Value is double) + { + return (sbyte)Math.Round((double)Value); + } + else if (Value is string) + { + return ToSByte((string)Value); + } + throw new InvalidCastException(); + } + public static short ToShort(string Value) + { + if (Value is null) + { + return 0; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return (short)i64Value; + } + return (short)Math.Round(ParseDouble(Value)); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + public static short ToShort(object Value) + { + if (Value is null) + { + return 0; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToShort((bool)Value); + } + else if (Value is sbyte) + { + return (sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (short)Value; + } + else if (Value is ushort) + { + return (short)(ushort)Value; + } + else if (Value is int) + { + return (short)(int)Value; + } + else if (Value is uint) + { + return (short)(uint)Value; + } + else if (Value is long) + { + return (short)(long)Value; + } + else if (Value is ulong) + { + return (short)(ulong)Value; + } + else if (Value is decimal) + { + return (short)Math.Round((decimal)Value); + } + else if (Value is float) + { + return (short)Math.Round((float)Value); + } + else if (Value is double) + { + return (short)Math.Round((double)Value); + } + else if (Value is string) + { + return ToShort((string)Value); + } + throw new InvalidCastException(); + } + [CLSCompliant(false)] + public static ushort ToUShort(string Value) + { + if (Value is null) + { + return 0; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return (ushort)i64Value; + } + return (ushort)Math.Round(ParseDouble(Value)); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + [CLSCompliant(false)] + public static ushort ToUShort(object Value) + { + if (Value is null) + { + return 0; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToUShort((bool)Value); + } + else if (Value is sbyte) + { + return (ushort)(sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (ushort)(short)Value; + } + else if (Value is ushort) + { + return (ushort)Value; + } + else if (Value is int) + { + return (ushort)(int)Value; + } + else if (Value is uint) + { + return (ushort)(uint)Value; + } + else if (Value is long) + { + return (ushort)(long)Value; + } + else if (Value is ulong) + { + return (ushort)(ulong)Value; + } + else if (Value is decimal) + { + return (ushort)Math.Round((decimal)Value); + } + else if (Value is float) + { + return (ushort)Math.Round((float)Value); + } + else if (Value is double) + { + return (ushort)Math.Round((double)Value); + } + else if (Value is string) + { + return ToUShort((string)Value); + } + throw new InvalidCastException(); + } + public static int ToInteger(string Value) + { + if (Value is null) + { + return 0; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return (int)i64Value; + } + return (int)Math.Round(ParseDouble(Value)); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + public static int ToInteger(object Value) + { + if (Value is null) + { + return 0; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToInteger((bool)Value); + } + else if (Value is sbyte) + { + return (sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (short)Value; + } + else if (Value is ushort) + { + return (ushort)Value; + } + else if (Value is int) + { + return (int)Value; + } + else if (Value is uint) + { + return (int)(uint)Value; + } + else if (Value is long) + { + return (int)(long)Value; + } + else if (Value is ulong) + { + return (int)(ulong)Value; + } + else if (Value is decimal) + { + return (int)Math.Round((decimal)Value); + } + else if (Value is float) + { + return (int)Math.Round((float)Value); + } + else if (Value is double) + { + return (int)Math.Round((double)Value); + } + else if (Value is string) + { + return ToInteger((string)Value); + } + throw new InvalidCastException(); + } + [CLSCompliant(false)] + public static uint ToUInteger(string Value) + { + if (Value is null) + { + return 0U; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return (uint)i64Value; + } + return (uint)Math.Round(ParseDouble(Value)); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + [CLSCompliant(false)] + public static uint ToUInteger(object Value) + { + if (Value is null) + { + return 0U; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToUInteger((bool)Value); + } + else if (Value is sbyte) + { + return (uint)(sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (uint)(short)Value; + } + else if (Value is ushort) + { + return (ushort)Value; + } + else if (Value is int) + { + return (uint)(int)Value; + } + else if (Value is uint) + { + return (uint)Value; + } + else if (Value is long) + { + return (uint)(long)Value; + } + else if (Value is ulong) + { + return (uint)(ulong)Value; + } + else if (Value is decimal) + { + return (uint)Math.Round((decimal)Value); + } + else if (Value is float) + { + return (uint)Math.Round((float)Value); + } + else if (Value is double) + { + return (uint)Math.Round((double)Value); + } + else if (Value is string) + { + return ToUInteger((string)Value); + } + throw new InvalidCastException(); + } + public static long ToLong(string Value) + { + if (Value is null) + { + return 0L; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return i64Value; + } + return (long)Math.Round(ParseDecimal(Value, null)); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + public static long ToLong(object Value) + { + if (Value is null) + { + return 0L; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToLong((bool)Value); + } + else if (Value is sbyte) + { + return (sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (short)Value; + } + else if (Value is ushort) + { + return (ushort)Value; + } + else if (Value is int) + { + return (int)Value; + } + else if (Value is uint) + { + return (uint)Value; + } + else if (Value is long) + { + return (long)Value; + } + else if (Value is ulong) + { + return (long)(ulong)Value; + } + else if (Value is decimal) + { + return (long)Math.Round((decimal)Value); + } + else if (Value is float) + { + return (long)Math.Round((float)Value); + } + else if (Value is double) + { + return (long)Math.Round((double)Value); + } + else if (Value is string) + { + return ToLong((string)Value); + } + throw new InvalidCastException(); + } + [CLSCompliant(false)] + public static ulong ToULong(string Value) + { + if (Value is null) + { + return 0UL; + } + try + { + var ui64Value = default(ulong); + if (IsHexOrOctValue(Value, ref ui64Value)) + { + return ui64Value; + } + return (ulong)Math.Round(ParseDecimal(Value, null)); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + [CLSCompliant(false)] + public static ulong ToULong(object Value) + { + if (Value is null) + { + return 0UL; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToULong((bool)Value); + } + else if (Value is sbyte) + { + return (ulong)(sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (ulong)(short)Value; + } + else if (Value is ushort) + { + return (ushort)Value; + } + else if (Value is int) + { + return (ulong)(int)Value; + } + else if (Value is uint) + { + return (uint)Value; + } + else if (Value is long) + { + return (ulong)(long)Value; + } + else if (Value is ulong) + { + return (ulong)Value; + } + else if (Value is decimal) + { + return (ulong)Math.Round((decimal)Value); + } + else if (Value is float) + { + return (ulong)Math.Round((float)Value); + } + else if (Value is double) + { + return (ulong)Math.Round((double)Value); + } + else if (Value is string) + { + return ToULong((string)Value); + } + throw new InvalidCastException(); + } + public static decimal ToDecimal(bool Value) + { + if (Value) + { + return -1m; + } + else + { + return 0m; + } + } + public static decimal ToDecimal(string Value) + { + if (Value is null) + { + return 0m; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return i64Value; + } + return ParseDecimal(Value, null); + } + catch (OverflowException e1) + { + throw e1; + } + catch (FormatException e2) + { + throw new InvalidCastException(e2.Message, e2); + } + } + public static decimal ToDecimal(object Value) + { + if (Value is null) + { + return 0m; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToDecimal((bool)Value); + } + else if (Value is sbyte) + { + return (sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (short)Value; + } + else if (Value is ushort) + { + return (ushort)Value; + } + else if (Value is int) + { + return (int)Value; + } + else if (Value is uint) + { + return (uint)Value; + } + else if (Value is long) + { + return (long)Value; + } + else if (Value is ulong) + { + return (ulong)Value; + } + else if (Value is decimal) + { + return (decimal)Value; + } + else if (Value is float) + { + return (decimal)(float)Value; + } + else if (Value is double) + { + return (decimal)(double)Value; + } + else if (Value is string) + { + return ToDecimal((string)Value); + } + throw new InvalidCastException(); + } + private static decimal ParseDecimal(string Value, System.Globalization.NumberFormatInfo NumberFormat) + { + System.Globalization.NumberFormatInfo NormalizedNumberFormat; + var culture = GetCultureInfo(); + if (NumberFormat is null) + { + NumberFormat = culture.NumberFormat; + } + NormalizedNumberFormat = GetNormalizedNumberFormat(NumberFormat); + const System.Globalization.NumberStyles flags = System.Globalization.NumberStyles.AllowDecimalPoint | System.Globalization.NumberStyles.AllowExponent | System.Globalization.NumberStyles.AllowLeadingSign | System.Globalization.NumberStyles.AllowLeadingWhite | System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowTrailingSign | System.Globalization.NumberStyles.AllowParentheses | System.Globalization.NumberStyles.AllowTrailingWhite | System.Globalization.NumberStyles.AllowCurrencySymbol; + Value = ToHalfwidthNumbers(Value, culture); + try + { + return decimal.Parse(Value, flags, NormalizedNumberFormat); + } + catch (FormatException FormatEx) when (!ReferenceEquals(NumberFormat, NormalizedNumberFormat)) + { + return decimal.Parse(Value, flags, NumberFormat); + } + catch (Exception Ex) + { + throw Ex; + } + } + private static System.Globalization.NumberFormatInfo GetNormalizedNumberFormat(System.Globalization.NumberFormatInfo InNumberFormat) + { + System.Globalization.NumberFormatInfo OutNumberFormat; + if (InNumberFormat.CurrencyDecimalSeparator is not null && InNumberFormat.NumberDecimalSeparator is not null && InNumberFormat.CurrencyGroupSeparator is not null && InNumberFormat.NumberGroupSeparator is not null && InNumberFormat.CurrencyDecimalSeparator.Length == 1 && InNumberFormat.NumberDecimalSeparator.Length == 1 && InNumberFormat.CurrencyGroupSeparator.Length == 1 && InNumberFormat.NumberGroupSeparator.Length == 1 && InNumberFormat.CurrencyDecimalSeparator[0] == InNumberFormat.NumberDecimalSeparator[0] && InNumberFormat.CurrencyGroupSeparator[0] == InNumberFormat.NumberGroupSeparator[0] && InNumberFormat.CurrencyDecimalDigits == InNumberFormat.NumberDecimalDigits) + { + return InNumberFormat; + } + if (InNumberFormat.CurrencyDecimalSeparator is not null && InNumberFormat.NumberDecimalSeparator is not null && InNumberFormat.CurrencyDecimalSeparator.Length == InNumberFormat.NumberDecimalSeparator.Length && InNumberFormat.CurrencyGroupSeparator is not null && InNumberFormat.NumberGroupSeparator is not null && InNumberFormat.CurrencyGroupSeparator.Length == InNumberFormat.NumberGroupSeparator.Length) + { + int i; + var loopTo = InNumberFormat.CurrencyDecimalSeparator.Length - 1; + for (i = 0; i <= loopTo; i++) + { + if (InNumberFormat.CurrencyDecimalSeparator[i] != InNumberFormat.NumberDecimalSeparator[i]) + goto MisMatch; + } + var loopTo1 = InNumberFormat.CurrencyGroupSeparator.Length - 1; + for (i = 0; i <= loopTo1; i++) + { + if (InNumberFormat.CurrencyGroupSeparator[i] != InNumberFormat.NumberGroupSeparator[i]) + goto MisMatch; + } + return InNumberFormat; + } + + MisMatch: + ; + + OutNumberFormat = (System.Globalization.NumberFormatInfo)InNumberFormat.Clone(); + OutNumberFormat.CurrencyDecimalSeparator = OutNumberFormat.NumberDecimalSeparator; + OutNumberFormat.CurrencyGroupSeparator = OutNumberFormat.NumberGroupSeparator; + OutNumberFormat.CurrencyDecimalDigits = OutNumberFormat.NumberDecimalDigits; + return OutNumberFormat; + } + public static float ToSingle(string Value) + { + if (Value is null) + { + return 0f; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return i64Value; + } + double Result = ParseDouble(Value); + if ((Result < float.MinValue || Result > float.MaxValue) && !double.IsInfinity(Result)) + { + throw new OverflowException(); + } + return (float)Result; + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + public static float ToSingle(object Value) + { + if (Value is null) + { + return 0f; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToSingle((bool)Value); + } + else if (Value is sbyte) + { + return (sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (short)Value; + } + else if (Value is ushort) + { + return (ushort)Value; + } + else if (Value is int) + { + return (int)Value; + } + else if (Value is uint) + { + return (uint)Value; + } + else if (Value is long) + { + return (long)Value; + } + else if (Value is ulong) + { + return (ulong)Value; + } + else if (Value is decimal) + { + return (float)(decimal)Value; + } + else if (Value is float) + { + return (float)Value; + } + else if (Value is double) + { + return (float)(double)Value; + } + else if (Value is string) + { + return ToSingle((string)Value); + } + throw new InvalidCastException(); + } + public static double ToDouble(string Value) + { + if (Value is null) + { + return 0d; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return i64Value; + } + return ParseDouble(Value); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + public static double ToDouble(object Value) + { + if (Value is null) + { + return 0d; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToDouble((bool)Value); + } + else if (Value is sbyte) + { + return (sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (short)Value; + } + else if (Value is ushort) + { + return (ushort)Value; + } + else if (Value is int) + { + return (int)Value; + } + else if (Value is uint) + { + return (uint)Value; + } + else if (Value is long) + { + return (long)Value; + } + else if (Value is ulong) + { + return (ulong)Value; + } + else if (Value is decimal) + { + return (double)(decimal)Value; + } + else if (Value is float) + { + return (double)(float)Value; + } + else if (Value is double) + { + return (double)Value; + } + else if (Value is string) + { + return ToDouble((string)Value); + } + throw new InvalidCastException(); + } + private static double ParseDouble(string Value) + { + System.Globalization.NumberFormatInfo NormalizedNumberFormat; + var culture = GetCultureInfo(); + var NumberFormat = culture.NumberFormat; + NormalizedNumberFormat = GetNormalizedNumberFormat(NumberFormat); + const System.Globalization.NumberStyles flags = System.Globalization.NumberStyles.AllowDecimalPoint | System.Globalization.NumberStyles.AllowExponent | System.Globalization.NumberStyles.AllowLeadingSign | System.Globalization.NumberStyles.AllowLeadingWhite | System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowTrailingSign | System.Globalization.NumberStyles.AllowParentheses | System.Globalization.NumberStyles.AllowTrailingWhite | System.Globalization.NumberStyles.AllowCurrencySymbol; + Value = ToHalfwidthNumbers(Value, culture); + try + { + return double.Parse(Value, flags, NormalizedNumberFormat); + } + catch (FormatException FormatEx) when (!ReferenceEquals(NumberFormat, NormalizedNumberFormat)) + { + return double.Parse(Value, flags, NumberFormat); + } + catch (Exception Ex) + { + throw Ex; + } + } + public static DateTime ToDate(string Value) + { + DateTime ParsedDate; + const System.Globalization.DateTimeStyles ParseStyle = System.Globalization.DateTimeStyles.AllowWhiteSpaces | System.Globalization.DateTimeStyles.NoCurrentDateDefault; + var Culture = GetCultureInfo(); + bool result = DateTime.TryParse(ToHalfwidthNumbers(Value, Culture), Culture, ParseStyle, out ParsedDate); + if (result) + { + return ParsedDate; + } + else + { + throw new InvalidCastException(); + } + } + public static DateTime ToDate(object Value) + { + if (Value is null) + { + return default(DateTime); + } + if (Value is DateTime) + { + return ToDate((DateTime)Value); + } + else if (Value is string) + { + return ToDate((string)Value); + } + throw new InvalidCastException(); + } + public static char ToChar(string Value) + { + if (Value is null || Value.Length == 0) + { + return Convert.ToChar(0 & 0xFFFF); + } + return Value[0]; + } + public static char ToChar(object Value) + { + if (Value is null) + { + return Convert.ToChar(0 & 0xFFFF); + } + if (Value is char) + { + return (char)Value; + } + else if (Value is string) + { + return ToChar((string)Value); + } + throw new InvalidCastException(); + } + public static char[] ToCharArrayRankOne(string Value) + { + if (Value is null) + { + Value = ""; + } + return Value.ToCharArray(); + } + public static char[] ToCharArrayRankOne(object Value) + { + if (Value is null) + { + return "".ToCharArray(); + } + char[] ArrayValue = Value as char[]; + if (ArrayValue is not null && ArrayValue.Rank == 1) + { + return ArrayValue; + } + else if (Value is string) + { + return ((string)Value).ToCharArray(); + } + throw new InvalidCastException(); + } + public static new string ToString(short Value) + { + return Value.ToString(); + } + public static new string ToString(int Value) { - item.Value = value; - break; + return Value.ToString(); } - } - public static string get_AttributeValue(IEnumerable source, XName name) - { - foreach (XElement item in source) - return (string)item.Attribute(name); - return null; - } - - public static void set_AttributeValue(IEnumerable source, XName name, string value) - { - foreach (XElement item in source) + [CLSCompliant(false)] + public static new string ToString(uint Value) { - item.SetAttributeValue(name, value); - break; + return Value.ToString(); } - } - public static string get_AttributeValue(XElement source, XName name) - { - return (string)source.Attribute(name); - } - - public static void set_AttributeValue(XElement source, XName name, string value) - { - source.SetAttributeValue(name, value); - } - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static XAttribute CreateAttribute(XName name, object value) - { - if (value is null) + public static new string ToString(long Value) { - return null; + return Value.ToString(); } - return new XAttribute(name, value); - } - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static XAttribute CreateNamespaceAttribute(XName name, XNamespace ns) - { - var a = new XAttribute(name, ns.NamespaceName); - a.AddAnnotation(ns); - return a; - } - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static object RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, object obj) - { - if (obj is not null) + [CLSCompliant(false)] + public static new string ToString(ulong Value) + { + return Value.ToString(); + } + public static new string ToString(float Value) + { + return Value.ToString(); + } + public static new string ToString(double Value) + { + return Value.ToString("G"); + } + public static new string ToString(DateTime Value) + { + long TimeTicks = Value.TimeOfDay.Ticks; + if (TimeTicks == Value.Ticks || Value.Year == 1899 && Value.Month == 12 && Value.Day == 30) + { + return Value.ToString("T"); + } + else if (TimeTicks == 0L) + { + return Value.ToString("d"); + } + else + { + return Value.ToString("G"); + } + } + public static new string ToString(decimal Value) + { + return Value.ToString("G"); + } + public static new string ToString(object Value) + { + if (Value is null) + { + return null; + } + else + { + string StringValue = Value as string; + if (StringValue is not null) + { + return StringValue; + } + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToString((bool)Value); + } + else if (Value is sbyte) + { + return ((sbyte)Value).ToString(); + } + else if (Value is byte) + { + return ((byte)Value).ToString(); + } + else if (Value is short) + { + return ((short)Value).ToString(); + } + else if (Value is ushort) + { + return ((ushort)Value).ToString(); + } + else if (Value is int) + { + return ((int)Value).ToString(); + } + else if (Value is uint) + { + return ((uint)Value).ToString(); + } + else if (Value is long) + { + return ((long)Value).ToString(); + } + else if (Value is ulong) + { + return ((ulong)Value).ToString(); + } + else if (Value is decimal) + { + return ((decimal)Value).ToString(); + } + else if (Value is float) + { + return ((float)Value).ToString(); + } + else if (Value is double) + { + return ((double)Value).ToString(); + } + else if (Value is char) + { + return ToString((char)Value); + } + else if (Value is DateTime) + { + return ToString((DateTime)Value); + } + else + { + char[] CharArray = Value as char[]; + if (CharArray is not null) + { + return new string(CharArray); + } + } + throw new InvalidCastException(); + } + public static new string ToString(bool Value) { - XElement elem = obj as XElement; - if (elem is not null) + if (Value) + { + return bool.TrueString; + } + else + { + return bool.FalseString; + } + } + public static new string ToString(byte Value) + { + return Value.ToString(); + } + public static new string ToString(char Value) + { + return Value.ToString(); + } + internal static System.Globalization.CultureInfo GetCultureInfo() + { + return System.Globalization.CultureInfo.CurrentCulture; + } + internal static string ToHalfwidthNumbers(string s, System.Globalization.CultureInfo culture) + { + return s; + } + internal static bool IsHexOrOctValue(string Value, ref long i64Value) + { + char ch; + int Length; + var FirstNonspace = default(int); + string TmpValue; + Length = Value.Length; + while (FirstNonspace < Length) + { + ch = Value[FirstNonspace]; + if (ch == '&' && FirstNonspace + 2 < Length) + { + goto GetSpecialValue; + } + if (ch != Strings.ChrW(32) && ch != Strings.ChrW(0x3000)) + { + return false; + } + FirstNonspace += 1; + } + return false; + GetSpecialValue: + ; + + ch = char.ToLowerInvariant(Value[FirstNonspace + 1]); + TmpValue = ToHalfwidthNumbers(Value.Substring(FirstNonspace + 2), GetCultureInfo()); + if (ch == 'h') + { + i64Value = Convert.ToInt64(TmpValue, 16); + } + else if (ch == 'o') { - return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elem); + i64Value = Convert.ToInt64(TmpValue, 8); } else { - IEnumerable elems = obj as IEnumerable; - if (elems is not null) + throw new FormatException(); + } + return true; + } + internal static bool IsHexOrOctValue(string Value, ref ulong ui64Value) + { + char ch; + int Length; + var FirstNonspace = default(int); + string TmpValue; + Length = Value.Length; + while (FirstNonspace < Length) + { + ch = Value[FirstNonspace]; + if (ch == '&' && FirstNonspace + 2 < Length) { - return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elems); + goto GetSpecialValue; } + if (ch != Strings.ChrW(32) && ch != Strings.ChrW(0x3000)) + { + return false; + } + FirstNonspace += 1; + } + return false; + GetSpecialValue: + ; + + ch = char.ToLowerInvariant(Value[FirstNonspace + 1]); + TmpValue = ToHalfwidthNumbers(Value.Substring(FirstNonspace + 2), GetCultureInfo()); + if (ch == 'h') + { + ui64Value = Convert.ToUInt64(TmpValue, 16); + } + else if (ch == 'o') + { + ui64Value = Convert.ToUInt64(TmpValue, 8); + } + else + { + throw new FormatException(); } + return true; } - return obj; - } - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static IEnumerable RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, IEnumerable obj) - { - if (obj is not null) + public static T ToGenericParameter(object Value) { - IEnumerable elems = obj as IEnumerable; - if (elems is not null) + if (Value is null) + { + return default(T); + } + var reflectedType = typeof(T); + if (Equals(reflectedType, typeof(bool))) + { + return (T)(object)ToBoolean(Value); + } + else if (Equals(reflectedType, typeof(sbyte))) + { + return (T)(object)ToSByte(Value); + } + else if (Equals(reflectedType, typeof(byte))) + { + return (T)(object)ToByte(Value); + } + else if (Equals(reflectedType, typeof(short))) + { + return (T)(object)ToShort(Value); + } + else if (Equals(reflectedType, typeof(ushort))) + { + return (T)(object)ToUShort(Value); + } + else if (Equals(reflectedType, typeof(int))) + { + return (T)(object)ToInteger(Value); + } + else if (Equals(reflectedType, typeof(uint))) + { + return (T)(object)ToUInteger(Value); + } + else if (Equals(reflectedType, typeof(long))) + { + return (T)(object)ToLong(Value); + } + else if (Equals(reflectedType, typeof(ulong))) + { + return (T)(object)ToULong(Value); + } + else if (Equals(reflectedType, typeof(decimal))) + { + return (T)(object)ToDecimal(Value); + } + else if (Equals(reflectedType, typeof(float))) + { + return (T)(object)ToSingle(Value); + } + else if (Equals(reflectedType, typeof(double))) + { + return (T)(object)ToDouble(Value); + } + else if (Equals(reflectedType, typeof(DateTime))) + { + return (T)(object)ToDate(Value); + } + else if (Equals(reflectedType, typeof(char))) + { + return (T)(object)ToChar(Value); + } + else if (Equals(reflectedType, typeof(string))) { - return elems.Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessXElement); + return (T)ToString(Value); } else { - return obj.Cast().Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessObject); + return (T)Value; } } - return obj; } + [Embedded()] [DebuggerNonUserCode()] [System.Runtime.CompilerServices.CompilerGenerated()] [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - private sealed class RemoveNamespaceAttributesClosure + internal sealed class ProjectData { - private readonly string[] m_inScopePrefixes; - private readonly XNamespace[] m_inScopeNs; - private readonly List m_attributes; - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal RemoveNamespaceAttributesClosure(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes) + private ProjectData() + { + } + public static void SetProjectError(Exception ex) + { + } + public static void SetProjectError(Exception ex, int lErl) + { + } + public static void ClearProjectError() { - m_inScopePrefixes = inScopePrefixes; - m_inScopeNs = inScopeNs; - m_attributes = attributes; } - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal XElement ProcessXElement(XElement elem) + } + [Embedded()] + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal sealed class Utils + { + private Utils() { - return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem); } - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal object ProcessObject(object obj) + public static Array CopyArray(Array arySrc, Array aryDest) { - XElement elem = obj as XElement; - if (elem is not null) + if (arySrc is null) + { + return aryDest; + } + int lLength; + lLength = arySrc.Length; + if (lLength == 0) + { + return aryDest; + } + if (aryDest.Rank != arySrc.Rank) + { + throw new InvalidCastException(); + } + int iDim; + var loopTo = aryDest.Rank - 2; + for (iDim = 0; iDim <= loopTo; iDim++) { - return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem); + if (aryDest.GetUpperBound(iDim) != arySrc.GetUpperBound(iDim)) + { + throw new ArrayTypeMismatchException(); + } + } + if (lLength > aryDest.Length) + { + lLength = aryDest.Length; + } + if (arySrc.Rank > 1) + { + int LastRank = arySrc.Rank; + int lenSrcLastRank = arySrc.GetLength(LastRank - 1); + int lenDestLastRank = aryDest.GetLength(LastRank - 1); + if (lenDestLastRank == 0) + { + return aryDest; + } + int lenCopy = lenSrcLastRank > lenDestLastRank ? lenDestLastRank : lenSrcLastRank; + int i; + var loopTo1 = arySrc.Length / lenSrcLastRank - 1; + for (i = 0; i <= loopTo1; i++) + Array.Copy(arySrc, i * lenSrcLastRank, aryDest, i * lenDestLastRank, lenCopy); } else { - return obj; + Array.Copy(arySrc, aryDest, lLength); } + return aryDest; } } + [Embedded()] + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static XElement RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, XElement e) + internal sealed class ObjectFlowControl { - if (e is not null) + internal sealed class ForLoopControl { - var a = e.FirstAttribute; - - while (a is not null) + public static bool ForNextCheckR4(float count, float limit, float StepValue) { - var nextA = a.NextAttribute; - - if (a.IsNamespaceDeclaration) + if (StepValue >= 0f) { - var ns = a.Annotation(); - string prefix = a.Name.LocalName; - - if (ns is not null) - { - if (inScopePrefixes is not null && inScopeNs is not null) - { - int lastIndex = inScopePrefixes.Length - 1; - - for (int i = 0, loopTo = lastIndex; i <= loopTo; i++) - { - string currentInScopePrefix = inScopePrefixes[i]; - var currentInScopeNs = inScopeNs[i]; - if (prefix.Equals(currentInScopePrefix)) - { - if (ns == currentInScopeNs) - { - // prefix and namespace match. Remove the unneeded ns attribute - a.Remove(); - } - - // prefix is in scope but refers to something else. Leave the ns attribute. - a = null; - break; - } - } - } - - if (a is not null) - { - // Prefix is not in scope - // Now check whether it's going to be in scope because it is in the attributes list - - if (attributes is not null) - { - int lastIndex = attributes.Count - 1; - for (int i = 0, loopTo1 = lastIndex; i <= loopTo1; i++) - { - var currentA = attributes[i]; - string currentInScopePrefix = currentA.Name.LocalName; - var currentInScopeNs = currentA.Annotation(); - if (currentInScopeNs is not null) - { - if (prefix.Equals(currentInScopePrefix)) - { - if (ns == currentInScopeNs) - { - // prefix and namespace match. Remove the unneeded ns attribute - a.Remove(); - } - - // prefix is in scope but refers to something else. Leave the ns attribute. - a = null; - break; - } - } - } - } - - if (a is not null) - { - // Prefix is definitely not in scope - a.Remove(); - // namespace is not defined either. Add this attributes list - attributes.Add(a); - } - } - } + return count <= limit; + } + else + { + return count >= limit; + } + } + public static bool ForNextCheckR8(double count, double limit, double StepValue) + { + if (StepValue >= 0d) + { + return count <= limit; + } + else + { + return count >= limit; + } + } + public static bool ForNextCheckDec(decimal count, decimal limit, decimal StepValue) + { + if (StepValue >= 0m) + { + return count <= limit; + } + else + { + return count >= limit; } - - a = nextA; } } - return e; } - + [Embedded()] + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal sealed class StaticLocalInitFlag + { + public short State; + } + [Embedded()] + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal sealed class IncompleteInitialization : Exception + { + public IncompleteInitialization() : base() + { + } + } + [Embedded()] + [AttributeUsage(AttributeTargets.Class, Inherited = false)] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [System.Runtime.CompilerServices.CompilerGenerated()] + internal sealed class StandardModuleAttribute : Attribute + { + } + [Embedded()] + [AttributeUsage(AttributeTargets.Class, Inherited = false)] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [System.Runtime.CompilerServices.CompilerGenerated()] + internal sealed class DesignerGeneratedAttribute : Attribute + { + } + [Embedded()] + [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [System.Runtime.CompilerServices.CompilerGenerated()] + internal sealed class OptionCompareAttribute : Attribute + { + } + [Embedded()] + [AttributeUsage(AttributeTargets.Class, Inherited = false)] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [System.Runtime.CompilerServices.CompilerGenerated()] + internal sealed class OptionTextAttribute : Attribute + { + } + } + [Embedded()] + [AttributeUsage(AttributeTargets.Class, Inherited = false)] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [System.Runtime.CompilerServices.CompilerGenerated()] + internal sealed class HideModuleNameAttribute : Attribute + { + } + [Embedded()] + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] + [StandardModule] + internal static class Strings + { + public static char ChrW(int CharCode) + { + if (CharCode < -32768 || CharCode > 65535) + { + throw new ArgumentException(); + } + return Convert.ToChar(CharCode & 0xFFFF); + } + public static int AscW(string String) + { + if (String is null || String.Length == 0) + { + throw new ArgumentException(); + } + return AscW(String[0]); + } + public static int AscW(char String) + { + return AscW(String); + } + } + [Embedded()] + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] + [StandardModule] + internal static class Constants + { + public const string vbCrLf = Conversions.ToString(Strings.ChrW(13)) + Strings.ChrW(10); + public const string vbNewLine = Conversions.ToString(Strings.ChrW(13)) + Strings.ChrW(10); + public const string vbCr = "\r"; + public const string vbLf = "\n"; + public const string vbBack = "\b"; + public const string vbFormFeed = "\f"; + public const string vbTab = "\t"; + public const string vbVerticalTab = "\v"; + public const string vbNullChar = "\0"; + public const string vbNullString = null; } } \ No newline at end of file diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/MyNamespace.Static.3.Designer.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/MyNamespace.Static.3.Designer.cs index 75d58675f..29ee4992f 100644 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/MyNamespace.Static.3.Designer.cs +++ b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/MyNamespace.Static.3.Designer.cs @@ -1,16 +1,241 @@ +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Xml.Linq; +using Microsoft.VisualBasic; // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; - -namespace Microsoft.VisualBasic +// See Compiler::LoadXmlSolutionExtension +namespace VbLibrary.My { [Embedded()] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Module | AttributeTargets.Assembly, Inherited = false)] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [DebuggerNonUserCode()] [System.Runtime.CompilerServices.CompilerGenerated()] - internal sealed class Embedded : Attribute + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal sealed class InternalXmlHelper { + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + private InternalXmlHelper() + { + } + public static string get_Value(IEnumerable source) + { + foreach (XElement item in source) + return item.Value; + return null; + } + + public static void set_Value(IEnumerable source, string value) + { + foreach (XElement item in source) + { + item.Value = value; + break; + } + } + public static string get_AttributeValue(IEnumerable source, XName name) + { + foreach (XElement item in source) + return (string)item.Attribute(name); + return null; + } + + public static void set_AttributeValue(IEnumerable source, XName name, string value) + { + foreach (XElement item in source) + { + item.SetAttributeValue(name, value); + break; + } + } + public static string get_AttributeValue(XElement source, XName name) + { + return (string)source.Attribute(name); + } + + public static void set_AttributeValue(XElement source, XName name, string value) + { + source.SetAttributeValue(name, value); + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public static XAttribute CreateAttribute(XName name, object value) + { + if (value is null) + { + return null; + } + return new XAttribute(name, value); + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public static XAttribute CreateNamespaceAttribute(XName name, XNamespace ns) + { + var a = new XAttribute(name, ns.NamespaceName); + a.AddAnnotation(ns); + return a; + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public static object RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, object obj) + { + if (obj is not null) + { + XElement elem = obj as XElement; + if (elem is not null) + { + return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elem); + } + else + { + IEnumerable elems = obj as IEnumerable; + if (elems is not null) + { + return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elems); + } + } + } + return obj; + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public static IEnumerable RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, IEnumerable obj) + { + if (obj is not null) + { + IEnumerable elems = obj as IEnumerable; + if (elems is not null) + { + return elems.Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessXElement); + } + else + { + return obj.Cast().Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessObject); + } + } + return obj; + } + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + private sealed class RemoveNamespaceAttributesClosure + { + private readonly string[] m_inScopePrefixes; + private readonly XNamespace[] m_inScopeNs; + private readonly List m_attributes; + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal RemoveNamespaceAttributesClosure(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes) + { + m_inScopePrefixes = inScopePrefixes; + m_inScopeNs = inScopeNs; + m_attributes = attributes; + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal XElement ProcessXElement(XElement elem) + { + return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem); + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal object ProcessObject(object obj) + { + XElement elem = obj as XElement; + if (elem is not null) + { + return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem); + } + else + { + return obj; + } + } + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public static XElement RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, XElement e) + { + if (e is not null) + { + var a = e.FirstAttribute; + + while (a is not null) + { + var nextA = a.NextAttribute; + + if (a.IsNamespaceDeclaration) + { + var ns = a.Annotation(); + string prefix = a.Name.LocalName; + + if (ns is not null) + { + if (inScopePrefixes is not null && inScopeNs is not null) + { + int lastIndex = inScopePrefixes.Length - 1; + + for (int i = 0, loopTo = lastIndex; i <= loopTo; i++) + { + string currentInScopePrefix = inScopePrefixes[i]; + var currentInScopeNs = inScopeNs[i]; + if (prefix.Equals(currentInScopePrefix)) + { + if (ns == currentInScopeNs) + { + // prefix and namespace match. Remove the unneeded ns attribute + a.Remove(); + } + + // prefix is in scope but refers to something else. Leave the ns attribute. + a = null; + break; + } + } + } + + if (a is not null) + { + // Prefix is not in scope + // Now check whether it's going to be in scope because it is in the attributes list + + if (attributes is not null) + { + int lastIndex = attributes.Count - 1; + for (int i = 0, loopTo1 = lastIndex; i <= loopTo1; i++) + { + var currentA = attributes[i]; + string currentInScopePrefix = currentA.Name.LocalName; + var currentInScopeNs = currentA.Annotation(); + if (currentInScopeNs is not null) + { + if (prefix.Equals(currentInScopePrefix)) + { + if (ns == currentInScopeNs) + { + // prefix and namespace match. Remove the unneeded ns attribute + a.Remove(); + } + + // prefix is in scope but refers to something else. Leave the ns attribute. + a = null; + break; + } + } + } + } + + if (a is not null) + { + // Prefix is definitely not in scope + a.Remove(); + // namespace is not defined either. Add this attributes list + attributes.Add(a); + } + } + } + } + + a = nextA; + } + } + return e; + } + } } \ No newline at end of file diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/Settings.Designer.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/Settings.Designer.cs deleted file mode 100644 index b50174bb1..000000000 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/Settings.Designer.cs +++ /dev/null @@ -1,88 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -using System.Diagnostics; -using Microsoft.VisualBasic; - - -namespace VbLibrary.My -{ - - [System.Runtime.CompilerServices.CompilerGenerated()] - [System.CodeDom.Compiler.GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.1.0.0")] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)] - internal sealed partial class MySettings : System.Configuration.ApplicationSettingsBase - { - - private static MySettings defaultInstance = (MySettings)Synchronized(new MySettings()); - - #region My.Settings Auto-Save Functionality - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MyType = "WindowsForms" Then - *//* TODO ERROR: Skipped DisabledTextTrivia - Private Shared addedHandler As Boolean - - Private Shared addedHandlerLockObject As New Object - - _ - Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) - If My.Application.SaveMySettingsOnExit Then - My.Settings.Save() - End If - End Sub - *//* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - #endregion - - public static MySettings Default - { - get - { - - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MyType = "WindowsForms" Then - *//* TODO ERROR: Skipped DisabledTextTrivia - If Not addedHandler Then - SyncLock addedHandlerLockObject - If Not addedHandler Then - AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings - addedHandler = True - End If - End SyncLock - End If - *//* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - return defaultInstance; - } - } - } -} - -namespace VbLibrary.My -{ - - [HideModuleName()] - [DebuggerNonUserCode()] - [System.Runtime.CompilerServices.CompilerGenerated()] - internal static class MySettingsProperty - { - - [System.ComponentModel.Design.HelpKeyword("My.Settings")] - internal static MySettings Settings - { - get - { - return MySettings.Default; - } - } - } -} \ No newline at end of file diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/Resources.Designer.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/Resources.Designer.cs deleted file mode 100644 index 9b3d19ae8..000000000 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/Resources.Designer.cs +++ /dev/null @@ -1,70 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - - -using System.Diagnostics; -using Microsoft.VisualBasic; - -namespace VbLibrary.My.Resources -{ - - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - [System.CodeDom.Compiler.GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [DebuggerNonUserCode()] - [System.Runtime.CompilerServices.CompilerGenerated()] - [HideModuleName()] - internal static class Resources - { - - private static System.Resources.ResourceManager resourceMan; - - private static System.Globalization.CultureInfo resourceCulture; - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)] - internal static System.Resources.ResourceManager ResourceManager - { - get - { - if (ReferenceEquals(resourceMan, null)) - { - var temp = new System.Resources.ResourceManager("VbLibrary.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)] - internal static System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} \ No newline at end of file diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/Resources.resx b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/Resources.resx deleted file mode 100644 index 98745a7c7..000000000 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/VbLibrary.csproj b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/VbLibrary.csproj index 92a9e71e9..a8fea172d 100644 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/VbLibrary.csproj +++ b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/VbLibrary.csproj @@ -1,128 +1,13 @@ - - - + - Debug - AnyCPU - {913DD733-37BF-05CF-35C5-5BD4A0431C47} - Exe - VbLibrary.Module1 VbLibrary - VbLibrary - 512 - Console - v4.8 - true - true - + netstandard2.1 $(DefaultItemExcludes);$(ProjectDir)**\*.vb latest - - AnyCPU - true - full - bin\Debug\ - bin\Debug\VbLibrary.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - TRACE;DEBUG - - - AnyCPU - pdbonly - true - bin\Release\ - bin\Release\VbLibrary.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - TRACE - - - On - - - Binary - - - Off - - - On - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - Application.myapp - True - - - True - True - Resources.resx - - - True - Settings.settings - True - - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - VbLibrary.My.Resources - Designer - - - - - MyApplicationCodeGenerator - Application.Designer.cs - - - SettingsSingleFileGenerator - VbLibrary.My - Settings.Designer.cs - - - - - - {fbfbe639-a532-408a-960d-288e05feeb0e} - VbNetStandardLib - + - + \ No newline at end of file diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/CharacterizationTestSolution.sln b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/CharacterizationTestSolution.sln index b3a37f341..364b36658 100644 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/CharacterizationTestSolution.sln +++ b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/CharacterizationTestSolution.sln @@ -1,7 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29503.13 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34321.82 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsAppVb", "WindowsAppVb\WindowsAppVb.csproj", "{63AE39F6-D4CF-0888-2B6F-3EF803778218}" EndProject @@ -14,7 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ユニコード.txt = ユニコード.txt EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VbLibrary", "VbLibrary\VbLibrary.csproj", "{913DD733-37BF-05CF-35C5-5BD4A0431C47}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VbLibrary", "VbLibrary\VbLibrary.csproj", "{913DD733-37BF-05CF-35C5-5BD4A0431C47}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VbNetStandardLib", "VbNetStandardLib\VbNetStandardLib.csproj", "{49DF6752-696A-0F7B-1455-E2F06769DFAE}" EndProject diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/Application.Designer.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/Application.Designer.cs deleted file mode 100644 index 3d3b640fe..000000000 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/Application.Designer.cs +++ /dev/null @@ -1,11 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - - diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/AssemblyInfo.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/AssemblyInfo.cs deleted file mode 100644 index 4e045305e..000000000 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -// Review the values of the assembly attributes - -[assembly: AssemblyTitle("EmptyVb")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("EmptyVb")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("bc4666bc-3a80-4eb9-a9ce-7c7714d2487d")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// - -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/MyNamespace.Static.1.Designer.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/MyNamespace.Static.1.Designer.cs index bc8a7acd6..75d58675f 100644 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/MyNamespace.Static.1.Designer.cs +++ b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/MyNamespace.Static.1.Designer.cs @@ -3,468 +3,14 @@ // See the LICENSE file in the project root for more information. using System; -using System.Diagnostics; -using Microsoft.VisualBasic; -/* TODO ERROR: Skipped IfDirectiveTrivia -#If TARGET = "module" AndAlso _MYTYPE = "" Then -*//* TODO ERROR: Skipped DisabledTextTrivia -#Const _MYTYPE="Empty" -*//* TODO ERROR: Skipped EndIfDirectiveTrivia -#End If -*/ -/* TODO ERROR: Skipped IfDirectiveTrivia -#If _MYTYPE = "WindowsForms" Then -*//* TODO ERROR: Skipped DisabledTextTrivia - -#Const _MYFORMS = True -#Const _MYWEBSERVICES = True -#Const _MYUSERTYPE = "Windows" -#Const _MYCOMPUTERTYPE = "Windows" -#Const _MYAPPLICATIONTYPE = "WindowsForms" - -*//* TODO ERROR: Skipped ElifDirectiveTrivia -#ElseIf _MYTYPE = "WindowsFormsWithCustomSubMain" Then -*//* TODO ERROR: Skipped DisabledTextTrivia - -#Const _MYFORMS = True -#Const _MYWEBSERVICES = True -#Const _MYUSERTYPE = "Windows" -#Const _MYCOMPUTERTYPE = "Windows" -#Const _MYAPPLICATIONTYPE = "Console" - -*//* TODO ERROR: Skipped ElifDirectiveTrivia -#ElseIf _MYTYPE = "Windows" OrElse _MYTYPE = "" Then -*//* TODO ERROR: Skipped DisabledTextTrivia - -#Const _MYWEBSERVICES = True -#Const _MYUSERTYPE = "Windows" -#Const _MYCOMPUTERTYPE = "Windows" -#Const _MYAPPLICATIONTYPE = "Windows" - -*//* TODO ERROR: Skipped ElifDirectiveTrivia -#ElseIf _MYTYPE = "Console" Then -*/ -/* TODO ERROR: Skipped DefineDirectiveTrivia -#Const _MYWEBSERVICES = True -*//* TODO ERROR: Skipped DefineDirectiveTrivia -#Const _MYUSERTYPE = "Windows" -*//* TODO ERROR: Skipped DefineDirectiveTrivia -#Const _MYCOMPUTERTYPE = "Windows" -*//* TODO ERROR: Skipped DefineDirectiveTrivia -#Const _MYAPPLICATIONTYPE = "Console" -*/ -/* TODO ERROR: Skipped ElifDirectiveTrivia -#ElseIf _MYTYPE = "Web" Then -*//* TODO ERROR: Skipped DisabledTextTrivia - -#Const _MYFORMS = False -#Const _MYWEBSERVICES = False -#Const _MYUSERTYPE = "Web" -#Const _MYCOMPUTERTYPE = "Web" - -*//* TODO ERROR: Skipped ElifDirectiveTrivia -#ElseIf _MYTYPE = "WebControl" Then -*//* TODO ERROR: Skipped DisabledTextTrivia - -#Const _MYFORMS = False -#Const _MYWEBSERVICES = True -#Const _MYUSERTYPE = "Web" -#Const _MYCOMPUTERTYPE = "Web" - -*//* TODO ERROR: Skipped ElifDirectiveTrivia -#ElseIf _MYTYPE = "Custom" Then -*//* TODO ERROR: Skipped DisabledTextTrivia - -*//* TODO ERROR: Skipped ElifDirectiveTrivia -#ElseIf _MYTYPE <> "Empty" Then -*//* TODO ERROR: Skipped DisabledTextTrivia - -#Const _MYTYPE = "Empty" - -*//* TODO ERROR: Skipped EndIfDirectiveTrivia -#End If -*/ -/* TODO ERROR: Skipped IfDirectiveTrivia -#If _MYTYPE <> "Empty" Then -*/ -namespace VbLibrary.My +namespace Microsoft.VisualBasic { - - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYAPPLICATIONTYPE = "WindowsForms" OrElse _MYAPPLICATIONTYPE = "Windows" OrElse _MYAPPLICATIONTYPE = "Console" Then - */ - [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYAPPLICATIONTYPE = "WindowsForms" Then - *//* TODO ERROR: Skipped DisabledTextTrivia - Inherits Global.Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase - #If TARGET = "winexe" Then - _ - Friend Shared Sub Main(ByVal Args As String()) - Try - Global.System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(MyApplication.UseCompatibleTextRendering()) - Finally - End Try - My.Application.Run(Args) - End Sub - #End If - - *//* TODO ERROR: Skipped ElifDirectiveTrivia - #ElseIf _MYAPPLICATIONTYPE = "Windows" Then - *//* TODO ERROR: Skipped DisabledTextTrivia - Inherits Global.Microsoft.VisualBasic.ApplicationServices.ApplicationBase - *//* TODO ERROR: Skipped ElifDirectiveTrivia - #ElseIf _MYAPPLICATIONTYPE = "Console" Then - */ - internal partial class MyApplication : Microsoft.VisualBasic.ApplicationServices.ConsoleApplicationBase - { - /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If '_MYAPPLICATIONTYPE = "WindowsForms" - */ - } - - /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If '#If _MYAPPLICATIONTYPE = "WindowsForms" Or _MYAPPLICATIONTYPE = "Windows" or _MYAPPLICATIONTYPE = "Console" - */ - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYCOMPUTERTYPE <> "" Then - */ - [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] + [Embedded()] + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Module | AttributeTargets.Assembly, Inherited = false)] [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYCOMPUTERTYPE = "Windows" Then - */ - internal partial class MyComputer : Microsoft.VisualBasic.Devices.Computer + [System.Runtime.CompilerServices.CompilerGenerated()] + internal sealed class Embedded : Attribute { - /* TODO ERROR: Skipped ElifDirectiveTrivia - #ElseIf _MYCOMPUTERTYPE = "Web" Then - *//* TODO ERROR: Skipped DisabledTextTrivia - Inherits Global.Microsoft.VisualBasic.Devices.ServerComputer - *//* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public MyComputer() : base() - { - } - } - /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - [HideModuleName()] - [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] - internal static class MyProject - { - - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYCOMPUTERTYPE <> "" Then - */ - [System.ComponentModel.Design.HelpKeyword("My.Computer")] - internal static MyComputer Computer - { - [DebuggerHidden()] - get - { - return m_ComputerObjectProvider.GetInstance; - } - } - - private readonly static ThreadSafeObjectProvider m_ComputerObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYAPPLICATIONTYPE = "Windows" Or _MYAPPLICATIONTYPE = "WindowsForms" Or _MYAPPLICATIONTYPE = "Console" Then - */ - [System.ComponentModel.Design.HelpKeyword("My.Application")] - internal static MyApplication Application - { - [DebuggerHidden()] - get - { - return m_AppObjectProvider.GetInstance; - } - } - private readonly static ThreadSafeObjectProvider m_AppObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYUSERTYPE = "Windows" Then - */ - [System.ComponentModel.Design.HelpKeyword("My.User")] - internal static Microsoft.VisualBasic.ApplicationServices.User User - { - [DebuggerHidden()] - get - { - return m_UserObjectProvider.GetInstance; - } - } - private readonly static ThreadSafeObjectProvider m_UserObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped ElifDirectiveTrivia - #ElseIf _MYUSERTYPE = "Web" Then - *//* TODO ERROR: Skipped DisabledTextTrivia - _ - Friend ReadOnly Property User() As Global.Microsoft.VisualBasic.ApplicationServices.WebUser - _ - Get - Return m_UserObjectProvider.GetInstance() - End Get - End Property - Private ReadOnly m_UserObjectProvider As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.ApplicationServices.WebUser) - *//* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYFORMS = True Then - *//* TODO ERROR: Skipped DisabledTextTrivia - - #Const STARTUP_MY_FORM_FACTORY = "My.MyProject.Forms" - - _ - Friend ReadOnly Property Forms() As MyForms - _ - Get - Return m_MyFormsObjectProvider.GetInstance() - End Get - End Property - - _ - _ - Friend NotInheritable Class MyForms - _ - Private Shared Function Create__Instance__(Of T As {New, Global.System.Windows.Forms.Form})(ByVal Instance As T) As T - If Instance Is Nothing OrElse Instance.IsDisposed Then - If m_FormBeingCreated IsNot Nothing Then - If m_FormBeingCreated.ContainsKey(GetType(T)) = True Then - Throw New Global.System.InvalidOperationException(Global.Microsoft.VisualBasic.CompilerServices.Utils.GetResourceString("WinForms_RecursiveFormCreate")) - End If - Else - m_FormBeingCreated = New Global.System.Collections.Hashtable() - End If - m_FormBeingCreated.Add(GetType(T), Nothing) - Try - Return New T() - Catch ex As Global.System.Reflection.TargetInvocationException When ex.InnerException IsNot Nothing - Dim BetterMessage As String = Global.Microsoft.VisualBasic.CompilerServices.Utils.GetResourceString("WinForms_SeeInnerException", ex.InnerException.Message) - Throw New Global.System.InvalidOperationException(BetterMessage, ex.InnerException) - Finally - m_FormBeingCreated.Remove(GetType(T)) - End Try - Else - Return Instance - End If - End Function - - _ - Private Sub Dispose__Instance__(Of T As Global.System.Windows.Forms.Form)(ByRef instance As T) - instance.Dispose() - instance = Nothing - End Sub - - _ - _ - Public Sub New() - MyBase.New() - End Sub - - Private Shared m_FormBeingCreated As Global.System.Collections.Hashtable - - Public Overrides Function Equals(ByVal o As Object) As Boolean - Return MyBase.Equals(o) - End Function - Public Overrides Function GetHashCode() As Integer - Return MyBase.GetHashCode - End Function - _ - Friend Overloads Function [GetType]() As Global.System.Type - Return GetType(MyForms) - End Function - Public Overrides Function ToString() As String - Return MyBase.ToString - End Function - End Class - - Private m_MyFormsObjectProvider As New ThreadSafeObjectProvider(Of MyForms) - - *//* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYWEBSERVICES = True Then - */ - [System.ComponentModel.Design.HelpKeyword("My.WebServices")] - internal static MyWebServices WebServices - { - [DebuggerHidden()] - get - { - return m_MyWebServicesObjectProvider.GetInstance; - } - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [MyGroupCollection("System.Web.Services.Protocols.SoapHttpClientProtocol", "Create__Instance__", "Dispose__Instance__", "")] - internal sealed class MyWebServices - { - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - public override bool Equals(object o) - { - return base.Equals(o); - } - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - public override int GetHashCode() - { - return base.GetHashCode(); - } - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - internal new Type GetType() - { - return typeof(MyWebServices); - } - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - public override string ToString() - { - return base.ToString(); - } - - [DebuggerHidden()] - private static T Create__Instance__(T instance) where T : new() - { - if (instance is null) - { - return new T(); - } - else - { - return instance; - } - } - - [DebuggerHidden()] - private void Dispose__Instance__(ref T instance) - { - instance = default(T); - } - - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public MyWebServices() : base() - { - } - } - - private readonly static ThreadSafeObjectProvider m_MyWebServicesObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MYTYPE = "Web" Then - *//* TODO ERROR: Skipped DisabledTextTrivia - - _ - Friend ReadOnly Property Request() As Global.System.Web.HttpRequest - _ - Get - Dim CurrentContext As Global.System.Web.HttpContext = Global.System.Web.HttpContext.Current - If CurrentContext IsNot Nothing Then - Return CurrentContext.Request - End If - Return Nothing - End Get - End Property - - _ - Friend ReadOnly Property Response() As Global.System.Web.HttpResponse - _ - Get - Dim CurrentContext As Global.System.Web.HttpContext = Global.System.Web.HttpContext.Current - If CurrentContext IsNot Nothing Then - Return CurrentContext.Response - End If - Return Nothing - End Get - End Property - - _ - Friend ReadOnly Property Log() As Global.Microsoft.VisualBasic.Logging.AspLog - _ - Get - Return m_LogObjectProvider.GetInstance() - End Get - End Property - - Private ReadOnly m_LogObjectProvider As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Logging.AspLog) - - *//* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If '_MYTYPE="Web" - */ - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [System.Runtime.InteropServices.ComVisible(false)] - internal sealed class ThreadSafeObjectProvider where T : new() - { - internal T GetInstance - { - /* TODO ERROR: Skipped IfDirectiveTrivia - #If TARGET = "library" Then - *//* TODO ERROR: Skipped DisabledTextTrivia - _ - Get - Dim Value As T = m_Context.Value - If Value Is Nothing Then - Value = New T - m_Context.Value() = Value - End If - Return Value - End Get - *//* TODO ERROR: Skipped ElseDirectiveTrivia - #Else - */ - [DebuggerHidden()] - get - { - if (m_ThreadStaticValue is null) - m_ThreadStaticValue = new T(); - return m_ThreadStaticValue; - } - /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - } - - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public ThreadSafeObjectProvider() : base() - { - } - - /* TODO ERROR: Skipped IfDirectiveTrivia - #If TARGET = "library" Then - *//* TODO ERROR: Skipped DisabledTextTrivia - Private ReadOnly m_Context As New Global.Microsoft.VisualBasic.MyServices.Internal.ContextValue(Of T) - *//* TODO ERROR: Skipped ElseDirectiveTrivia - #Else - */ - [System.Runtime.CompilerServices.CompilerGenerated()] - [ThreadStatic()] - private static T m_ThreadStaticValue; - /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - } } -} -/* TODO ERROR: Skipped EndIfDirectiveTrivia -#End If -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/MyNamespace.Static.2.Designer.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/MyNamespace.Static.2.Designer.cs index 80fcd5596..bd7913e6f 100644 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/MyNamespace.Static.2.Designer.cs +++ b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/MyNamespace.Static.2.Designer.cs @@ -1,242 +1,1855 @@ -using System.Collections; -using System.Collections.Generic; -using System.Data; -using System.Diagnostics; -using System.Linq; -using System.Xml.Linq; -using Microsoft.VisualBasic; // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -// See Compiler::LoadXmlSolutionExtension -namespace VbLibrary.My +using System; +using System.Diagnostics; +using Microsoft.VisualBasic.CompilerServices; + +namespace Microsoft.VisualBasic { - [Embedded()] - [DebuggerNonUserCode()] - [System.Runtime.CompilerServices.CompilerGenerated()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal sealed class InternalXmlHelper + namespace CompilerServices { + [Embedded()] + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - private InternalXmlHelper() - { - } - public static string get_Value(IEnumerable source) + internal sealed class EmbeddedOperators { - foreach (XElement item in source) - return item.Value; - return null; + private EmbeddedOperators() + { + } + public static int CompareString(string Left, string Right, bool TextCompare) + { + if (ReferenceEquals(Left, Right)) + { + return 0; + } + if (Left is null) + { + if (Right.Length == 0) + { + return 0; + } + return -1; + } + if (Right is null) + { + if (Left.Length == 0) + { + return 0; + } + return 1; + } + int Result; + if (TextCompare) + { + var OptionCompareTextFlags = System.Globalization.CompareOptions.IgnoreCase | System.Globalization.CompareOptions.IgnoreWidth | System.Globalization.CompareOptions.IgnoreKanaType; + Result = Conversions.GetCultureInfo().CompareInfo.Compare(Left, Right, OptionCompareTextFlags); + } + else + { + Result = string.CompareOrdinal(Left, Right); + } + if (Result == 0) + { + return 0; + } + else if (Result > 0) + { + return 1; + } + else + { + return -1; + } + } } - - public static void set_Value(IEnumerable source, string value) + [Embedded()] + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal sealed class Conversions { - foreach (XElement item in source) + private Conversions() + { + } + private static object GetEnumValue(object Value) + { + var underlyingType = Enum.GetUnderlyingType(Value.GetType()); + if (underlyingType.Equals(typeof(sbyte))) + { + return (sbyte)Value; + } + else if (underlyingType.Equals(typeof(byte))) + { + return (byte)Value; + } + else if (underlyingType.Equals(typeof(short))) + { + return (short)Value; + } + else if (underlyingType.Equals(typeof(ushort))) + { + return (ushort)Value; + } + else if (underlyingType.Equals(typeof(int))) + { + return (int)Value; + } + else if (underlyingType.Equals(typeof(uint))) + { + return (uint)Value; + } + else if (underlyingType.Equals(typeof(long))) + { + return (long)Value; + } + else if (underlyingType.Equals(typeof(ulong))) + { + return (ulong)Value; + } + else + { + throw new InvalidCastException(); + } + } + public static bool ToBoolean(string Value) + { + if (Value is null) + { + Value = ""; + } + try + { + var loc = GetCultureInfo(); + if (loc.CompareInfo.Compare(Value, bool.FalseString, System.Globalization.CompareOptions.IgnoreCase) == 0) + { + return false; + } + else if (loc.CompareInfo.Compare(Value, bool.TrueString, System.Globalization.CompareOptions.IgnoreCase) == 0) + { + return true; + } + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return ToBoolean(i64Value); + } + return ToBoolean(ParseDouble(Value)); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + public static bool ToBoolean(object Value) + { + if (Value is null) + { + return false; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return (bool)Value; + } + else if (Value is sbyte) + { + return ToBoolean((sbyte)Value); + } + else if (Value is byte) + { + return ToBoolean((byte)Value); + } + else if (Value is short) + { + return ToBoolean((short)Value); + } + else if (Value is ushort) + { + return ToBoolean((ushort)Value); + } + else if (Value is int) + { + return ToBoolean((int)Value); + } + else if (Value is uint) + { + return ToBoolean((uint)Value); + } + else if (Value is long) + { + return ToBoolean((long)Value); + } + else if (Value is ulong) + { + return ToBoolean((ulong)Value); + } + else if (Value is decimal) + { + return ToBoolean((decimal)Value); + } + else if (Value is float) + { + return ToBoolean((float)Value); + } + else if (Value is double) + { + return ToBoolean((double)Value); + } + else if (Value is string) + { + return ToBoolean((string)Value); + } + throw new InvalidCastException(); + } + public static byte ToByte(string Value) + { + if (Value is null) + { + return 0; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return (byte)i64Value; + } + return (byte)Math.Round(ParseDouble(Value)); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + public static byte ToByte(object Value) + { + if (Value is null) + { + return 0; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToByte((bool)Value); + } + else if (Value is sbyte) + { + return (byte)(sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (byte)(short)Value; + } + else if (Value is ushort) + { + return (byte)(ushort)Value; + } + else if (Value is int) + { + return (byte)(int)Value; + } + else if (Value is uint) + { + return (byte)(uint)Value; + } + else if (Value is long) + { + return (byte)(long)Value; + } + else if (Value is ulong) + { + return (byte)(ulong)Value; + } + else if (Value is decimal) + { + return (byte)Math.Round((decimal)Value); + } + else if (Value is float) + { + return (byte)Math.Round((float)Value); + } + else if (Value is double) + { + return (byte)Math.Round((double)Value); + } + else if (Value is string) + { + return ToByte((string)Value); + } + throw new InvalidCastException(); + } + [CLSCompliant(false)] + public static sbyte ToSByte(string Value) + { + if (Value is null) + { + return 0; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return (sbyte)i64Value; + } + return (sbyte)Math.Round(ParseDouble(Value)); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + [CLSCompliant(false)] + public static sbyte ToSByte(object Value) + { + if (Value is null) + { + return 0; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToSByte((bool)Value); + } + else if (Value is sbyte) + { + return (sbyte)Value; + } + else if (Value is byte) + { + return (sbyte)(byte)Value; + } + else if (Value is short) + { + return (sbyte)(short)Value; + } + else if (Value is ushort) + { + return (sbyte)(ushort)Value; + } + else if (Value is int) + { + return (sbyte)(int)Value; + } + else if (Value is uint) + { + return (sbyte)(uint)Value; + } + else if (Value is long) + { + return (sbyte)(long)Value; + } + else if (Value is ulong) + { + return (sbyte)(ulong)Value; + } + else if (Value is decimal) + { + return (sbyte)Math.Round((decimal)Value); + } + else if (Value is float) + { + return (sbyte)Math.Round((float)Value); + } + else if (Value is double) + { + return (sbyte)Math.Round((double)Value); + } + else if (Value is string) + { + return ToSByte((string)Value); + } + throw new InvalidCastException(); + } + public static short ToShort(string Value) + { + if (Value is null) + { + return 0; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return (short)i64Value; + } + return (short)Math.Round(ParseDouble(Value)); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + public static short ToShort(object Value) + { + if (Value is null) + { + return 0; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToShort((bool)Value); + } + else if (Value is sbyte) + { + return (sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (short)Value; + } + else if (Value is ushort) + { + return (short)(ushort)Value; + } + else if (Value is int) + { + return (short)(int)Value; + } + else if (Value is uint) + { + return (short)(uint)Value; + } + else if (Value is long) + { + return (short)(long)Value; + } + else if (Value is ulong) + { + return (short)(ulong)Value; + } + else if (Value is decimal) + { + return (short)Math.Round((decimal)Value); + } + else if (Value is float) + { + return (short)Math.Round((float)Value); + } + else if (Value is double) + { + return (short)Math.Round((double)Value); + } + else if (Value is string) + { + return ToShort((string)Value); + } + throw new InvalidCastException(); + } + [CLSCompliant(false)] + public static ushort ToUShort(string Value) + { + if (Value is null) + { + return 0; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return (ushort)i64Value; + } + return (ushort)Math.Round(ParseDouble(Value)); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + [CLSCompliant(false)] + public static ushort ToUShort(object Value) + { + if (Value is null) + { + return 0; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToUShort((bool)Value); + } + else if (Value is sbyte) + { + return (ushort)(sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (ushort)(short)Value; + } + else if (Value is ushort) + { + return (ushort)Value; + } + else if (Value is int) + { + return (ushort)(int)Value; + } + else if (Value is uint) + { + return (ushort)(uint)Value; + } + else if (Value is long) + { + return (ushort)(long)Value; + } + else if (Value is ulong) + { + return (ushort)(ulong)Value; + } + else if (Value is decimal) + { + return (ushort)Math.Round((decimal)Value); + } + else if (Value is float) + { + return (ushort)Math.Round((float)Value); + } + else if (Value is double) + { + return (ushort)Math.Round((double)Value); + } + else if (Value is string) + { + return ToUShort((string)Value); + } + throw new InvalidCastException(); + } + public static int ToInteger(string Value) + { + if (Value is null) + { + return 0; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return (int)i64Value; + } + return (int)Math.Round(ParseDouble(Value)); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + public static int ToInteger(object Value) + { + if (Value is null) + { + return 0; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToInteger((bool)Value); + } + else if (Value is sbyte) + { + return (sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (short)Value; + } + else if (Value is ushort) + { + return (ushort)Value; + } + else if (Value is int) + { + return (int)Value; + } + else if (Value is uint) + { + return (int)(uint)Value; + } + else if (Value is long) + { + return (int)(long)Value; + } + else if (Value is ulong) + { + return (int)(ulong)Value; + } + else if (Value is decimal) + { + return (int)Math.Round((decimal)Value); + } + else if (Value is float) + { + return (int)Math.Round((float)Value); + } + else if (Value is double) + { + return (int)Math.Round((double)Value); + } + else if (Value is string) + { + return ToInteger((string)Value); + } + throw new InvalidCastException(); + } + [CLSCompliant(false)] + public static uint ToUInteger(string Value) + { + if (Value is null) + { + return 0U; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return (uint)i64Value; + } + return (uint)Math.Round(ParseDouble(Value)); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + [CLSCompliant(false)] + public static uint ToUInteger(object Value) + { + if (Value is null) + { + return 0U; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToUInteger((bool)Value); + } + else if (Value is sbyte) + { + return (uint)(sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (uint)(short)Value; + } + else if (Value is ushort) + { + return (ushort)Value; + } + else if (Value is int) + { + return (uint)(int)Value; + } + else if (Value is uint) + { + return (uint)Value; + } + else if (Value is long) + { + return (uint)(long)Value; + } + else if (Value is ulong) + { + return (uint)(ulong)Value; + } + else if (Value is decimal) + { + return (uint)Math.Round((decimal)Value); + } + else if (Value is float) + { + return (uint)Math.Round((float)Value); + } + else if (Value is double) + { + return (uint)Math.Round((double)Value); + } + else if (Value is string) + { + return ToUInteger((string)Value); + } + throw new InvalidCastException(); + } + public static long ToLong(string Value) + { + if (Value is null) + { + return 0L; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return i64Value; + } + return (long)Math.Round(ParseDecimal(Value, null)); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + public static long ToLong(object Value) + { + if (Value is null) + { + return 0L; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToLong((bool)Value); + } + else if (Value is sbyte) + { + return (sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (short)Value; + } + else if (Value is ushort) + { + return (ushort)Value; + } + else if (Value is int) + { + return (int)Value; + } + else if (Value is uint) + { + return (uint)Value; + } + else if (Value is long) + { + return (long)Value; + } + else if (Value is ulong) + { + return (long)(ulong)Value; + } + else if (Value is decimal) + { + return (long)Math.Round((decimal)Value); + } + else if (Value is float) + { + return (long)Math.Round((float)Value); + } + else if (Value is double) + { + return (long)Math.Round((double)Value); + } + else if (Value is string) + { + return ToLong((string)Value); + } + throw new InvalidCastException(); + } + [CLSCompliant(false)] + public static ulong ToULong(string Value) + { + if (Value is null) + { + return 0UL; + } + try + { + var ui64Value = default(ulong); + if (IsHexOrOctValue(Value, ref ui64Value)) + { + return ui64Value; + } + return (ulong)Math.Round(ParseDecimal(Value, null)); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + [CLSCompliant(false)] + public static ulong ToULong(object Value) + { + if (Value is null) + { + return 0UL; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToULong((bool)Value); + } + else if (Value is sbyte) + { + return (ulong)(sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (ulong)(short)Value; + } + else if (Value is ushort) + { + return (ushort)Value; + } + else if (Value is int) + { + return (ulong)(int)Value; + } + else if (Value is uint) + { + return (uint)Value; + } + else if (Value is long) + { + return (ulong)(long)Value; + } + else if (Value is ulong) + { + return (ulong)Value; + } + else if (Value is decimal) + { + return (ulong)Math.Round((decimal)Value); + } + else if (Value is float) + { + return (ulong)Math.Round((float)Value); + } + else if (Value is double) + { + return (ulong)Math.Round((double)Value); + } + else if (Value is string) + { + return ToULong((string)Value); + } + throw new InvalidCastException(); + } + public static decimal ToDecimal(bool Value) + { + if (Value) + { + return -1m; + } + else + { + return 0m; + } + } + public static decimal ToDecimal(string Value) + { + if (Value is null) + { + return 0m; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return i64Value; + } + return ParseDecimal(Value, null); + } + catch (OverflowException e1) + { + throw e1; + } + catch (FormatException e2) + { + throw new InvalidCastException(e2.Message, e2); + } + } + public static decimal ToDecimal(object Value) + { + if (Value is null) + { + return 0m; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToDecimal((bool)Value); + } + else if (Value is sbyte) + { + return (sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (short)Value; + } + else if (Value is ushort) + { + return (ushort)Value; + } + else if (Value is int) + { + return (int)Value; + } + else if (Value is uint) + { + return (uint)Value; + } + else if (Value is long) + { + return (long)Value; + } + else if (Value is ulong) + { + return (ulong)Value; + } + else if (Value is decimal) + { + return (decimal)Value; + } + else if (Value is float) + { + return (decimal)(float)Value; + } + else if (Value is double) + { + return (decimal)(double)Value; + } + else if (Value is string) + { + return ToDecimal((string)Value); + } + throw new InvalidCastException(); + } + private static decimal ParseDecimal(string Value, System.Globalization.NumberFormatInfo NumberFormat) + { + System.Globalization.NumberFormatInfo NormalizedNumberFormat; + var culture = GetCultureInfo(); + if (NumberFormat is null) + { + NumberFormat = culture.NumberFormat; + } + NormalizedNumberFormat = GetNormalizedNumberFormat(NumberFormat); + const System.Globalization.NumberStyles flags = System.Globalization.NumberStyles.AllowDecimalPoint | System.Globalization.NumberStyles.AllowExponent | System.Globalization.NumberStyles.AllowLeadingSign | System.Globalization.NumberStyles.AllowLeadingWhite | System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowTrailingSign | System.Globalization.NumberStyles.AllowParentheses | System.Globalization.NumberStyles.AllowTrailingWhite | System.Globalization.NumberStyles.AllowCurrencySymbol; + Value = ToHalfwidthNumbers(Value, culture); + try + { + return decimal.Parse(Value, flags, NormalizedNumberFormat); + } + catch (FormatException FormatEx) when (!ReferenceEquals(NumberFormat, NormalizedNumberFormat)) + { + return decimal.Parse(Value, flags, NumberFormat); + } + catch (Exception Ex) + { + throw Ex; + } + } + private static System.Globalization.NumberFormatInfo GetNormalizedNumberFormat(System.Globalization.NumberFormatInfo InNumberFormat) + { + System.Globalization.NumberFormatInfo OutNumberFormat; + if (InNumberFormat.CurrencyDecimalSeparator is not null && InNumberFormat.NumberDecimalSeparator is not null && InNumberFormat.CurrencyGroupSeparator is not null && InNumberFormat.NumberGroupSeparator is not null && InNumberFormat.CurrencyDecimalSeparator.Length == 1 && InNumberFormat.NumberDecimalSeparator.Length == 1 && InNumberFormat.CurrencyGroupSeparator.Length == 1 && InNumberFormat.NumberGroupSeparator.Length == 1 && InNumberFormat.CurrencyDecimalSeparator[0] == InNumberFormat.NumberDecimalSeparator[0] && InNumberFormat.CurrencyGroupSeparator[0] == InNumberFormat.NumberGroupSeparator[0] && InNumberFormat.CurrencyDecimalDigits == InNumberFormat.NumberDecimalDigits) + { + return InNumberFormat; + } + if (InNumberFormat.CurrencyDecimalSeparator is not null && InNumberFormat.NumberDecimalSeparator is not null && InNumberFormat.CurrencyDecimalSeparator.Length == InNumberFormat.NumberDecimalSeparator.Length && InNumberFormat.CurrencyGroupSeparator is not null && InNumberFormat.NumberGroupSeparator is not null && InNumberFormat.CurrencyGroupSeparator.Length == InNumberFormat.NumberGroupSeparator.Length) + { + int i; + var loopTo = InNumberFormat.CurrencyDecimalSeparator.Length - 1; + for (i = 0; i <= loopTo; i++) + { + if (InNumberFormat.CurrencyDecimalSeparator[i] != InNumberFormat.NumberDecimalSeparator[i]) + goto MisMatch; + } + var loopTo1 = InNumberFormat.CurrencyGroupSeparator.Length - 1; + for (i = 0; i <= loopTo1; i++) + { + if (InNumberFormat.CurrencyGroupSeparator[i] != InNumberFormat.NumberGroupSeparator[i]) + goto MisMatch; + } + return InNumberFormat; + } + + MisMatch: + ; + + OutNumberFormat = (System.Globalization.NumberFormatInfo)InNumberFormat.Clone(); + OutNumberFormat.CurrencyDecimalSeparator = OutNumberFormat.NumberDecimalSeparator; + OutNumberFormat.CurrencyGroupSeparator = OutNumberFormat.NumberGroupSeparator; + OutNumberFormat.CurrencyDecimalDigits = OutNumberFormat.NumberDecimalDigits; + return OutNumberFormat; + } + public static float ToSingle(string Value) + { + if (Value is null) + { + return 0f; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return i64Value; + } + double Result = ParseDouble(Value); + if ((Result < float.MinValue || Result > float.MaxValue) && !double.IsInfinity(Result)) + { + throw new OverflowException(); + } + return (float)Result; + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + public static float ToSingle(object Value) + { + if (Value is null) + { + return 0f; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToSingle((bool)Value); + } + else if (Value is sbyte) + { + return (sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (short)Value; + } + else if (Value is ushort) + { + return (ushort)Value; + } + else if (Value is int) + { + return (int)Value; + } + else if (Value is uint) + { + return (uint)Value; + } + else if (Value is long) + { + return (long)Value; + } + else if (Value is ulong) + { + return (ulong)Value; + } + else if (Value is decimal) + { + return (float)(decimal)Value; + } + else if (Value is float) + { + return (float)Value; + } + else if (Value is double) + { + return (float)(double)Value; + } + else if (Value is string) + { + return ToSingle((string)Value); + } + throw new InvalidCastException(); + } + public static double ToDouble(string Value) + { + if (Value is null) + { + return 0d; + } + try + { + var i64Value = default(long); + if (IsHexOrOctValue(Value, ref i64Value)) + { + return i64Value; + } + return ParseDouble(Value); + } + catch (FormatException e) + { + throw new InvalidCastException(e.Message, e); + } + } + public static double ToDouble(object Value) + { + if (Value is null) + { + return 0d; + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToDouble((bool)Value); + } + else if (Value is sbyte) + { + return (sbyte)Value; + } + else if (Value is byte) + { + return (byte)Value; + } + else if (Value is short) + { + return (short)Value; + } + else if (Value is ushort) + { + return (ushort)Value; + } + else if (Value is int) + { + return (int)Value; + } + else if (Value is uint) + { + return (uint)Value; + } + else if (Value is long) + { + return (long)Value; + } + else if (Value is ulong) + { + return (ulong)Value; + } + else if (Value is decimal) + { + return (double)(decimal)Value; + } + else if (Value is float) + { + return (double)(float)Value; + } + else if (Value is double) + { + return (double)Value; + } + else if (Value is string) + { + return ToDouble((string)Value); + } + throw new InvalidCastException(); + } + private static double ParseDouble(string Value) + { + System.Globalization.NumberFormatInfo NormalizedNumberFormat; + var culture = GetCultureInfo(); + var NumberFormat = culture.NumberFormat; + NormalizedNumberFormat = GetNormalizedNumberFormat(NumberFormat); + const System.Globalization.NumberStyles flags = System.Globalization.NumberStyles.AllowDecimalPoint | System.Globalization.NumberStyles.AllowExponent | System.Globalization.NumberStyles.AllowLeadingSign | System.Globalization.NumberStyles.AllowLeadingWhite | System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowTrailingSign | System.Globalization.NumberStyles.AllowParentheses | System.Globalization.NumberStyles.AllowTrailingWhite | System.Globalization.NumberStyles.AllowCurrencySymbol; + Value = ToHalfwidthNumbers(Value, culture); + try + { + return double.Parse(Value, flags, NormalizedNumberFormat); + } + catch (FormatException FormatEx) when (!ReferenceEquals(NumberFormat, NormalizedNumberFormat)) + { + return double.Parse(Value, flags, NumberFormat); + } + catch (Exception Ex) + { + throw Ex; + } + } + public static DateTime ToDate(string Value) + { + DateTime ParsedDate; + const System.Globalization.DateTimeStyles ParseStyle = System.Globalization.DateTimeStyles.AllowWhiteSpaces | System.Globalization.DateTimeStyles.NoCurrentDateDefault; + var Culture = GetCultureInfo(); + bool result = DateTime.TryParse(ToHalfwidthNumbers(Value, Culture), Culture, ParseStyle, out ParsedDate); + if (result) + { + return ParsedDate; + } + else + { + throw new InvalidCastException(); + } + } + public static DateTime ToDate(object Value) + { + if (Value is null) + { + return default(DateTime); + } + if (Value is DateTime) + { + return ToDate((DateTime)Value); + } + else if (Value is string) + { + return ToDate((string)Value); + } + throw new InvalidCastException(); + } + public static char ToChar(string Value) + { + if (Value is null || Value.Length == 0) + { + return Convert.ToChar(0 & 0xFFFF); + } + return Value[0]; + } + public static char ToChar(object Value) + { + if (Value is null) + { + return Convert.ToChar(0 & 0xFFFF); + } + if (Value is char) + { + return (char)Value; + } + else if (Value is string) + { + return ToChar((string)Value); + } + throw new InvalidCastException(); + } + public static char[] ToCharArrayRankOne(string Value) + { + if (Value is null) + { + Value = ""; + } + return Value.ToCharArray(); + } + public static char[] ToCharArrayRankOne(object Value) + { + if (Value is null) + { + return "".ToCharArray(); + } + char[] ArrayValue = Value as char[]; + if (ArrayValue is not null && ArrayValue.Rank == 1) + { + return ArrayValue; + } + else if (Value is string) + { + return ((string)Value).ToCharArray(); + } + throw new InvalidCastException(); + } + public static new string ToString(short Value) + { + return Value.ToString(); + } + public static new string ToString(int Value) { - item.Value = value; - break; + return Value.ToString(); } - } - public static string get_AttributeValue(IEnumerable source, XName name) - { - foreach (XElement item in source) - return (string)item.Attribute(name); - return null; - } - - public static void set_AttributeValue(IEnumerable source, XName name, string value) - { - foreach (XElement item in source) + [CLSCompliant(false)] + public static new string ToString(uint Value) { - item.SetAttributeValue(name, value); - break; + return Value.ToString(); } - } - public static string get_AttributeValue(XElement source, XName name) - { - return (string)source.Attribute(name); - } - - public static void set_AttributeValue(XElement source, XName name, string value) - { - source.SetAttributeValue(name, value); - } - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static XAttribute CreateAttribute(XName name, object value) - { - if (value is null) + public static new string ToString(long Value) { - return null; + return Value.ToString(); } - return new XAttribute(name, value); - } - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static XAttribute CreateNamespaceAttribute(XName name, XNamespace ns) - { - var a = new XAttribute(name, ns.NamespaceName); - a.AddAnnotation(ns); - return a; - } - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static object RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, object obj) - { - if (obj is not null) + [CLSCompliant(false)] + public static new string ToString(ulong Value) + { + return Value.ToString(); + } + public static new string ToString(float Value) + { + return Value.ToString(); + } + public static new string ToString(double Value) + { + return Value.ToString("G"); + } + public static new string ToString(DateTime Value) + { + long TimeTicks = Value.TimeOfDay.Ticks; + if (TimeTicks == Value.Ticks || Value.Year == 1899 && Value.Month == 12 && Value.Day == 30) + { + return Value.ToString("T"); + } + else if (TimeTicks == 0L) + { + return Value.ToString("d"); + } + else + { + return Value.ToString("G"); + } + } + public static new string ToString(decimal Value) + { + return Value.ToString("G"); + } + public static new string ToString(object Value) + { + if (Value is null) + { + return null; + } + else + { + string StringValue = Value as string; + if (StringValue is not null) + { + return StringValue; + } + } + if (Value is Enum) + { + Value = GetEnumValue(Value); + } + if (Value is bool) + { + return ToString((bool)Value); + } + else if (Value is sbyte) + { + return ((sbyte)Value).ToString(); + } + else if (Value is byte) + { + return ((byte)Value).ToString(); + } + else if (Value is short) + { + return ((short)Value).ToString(); + } + else if (Value is ushort) + { + return ((ushort)Value).ToString(); + } + else if (Value is int) + { + return ((int)Value).ToString(); + } + else if (Value is uint) + { + return ((uint)Value).ToString(); + } + else if (Value is long) + { + return ((long)Value).ToString(); + } + else if (Value is ulong) + { + return ((ulong)Value).ToString(); + } + else if (Value is decimal) + { + return ((decimal)Value).ToString(); + } + else if (Value is float) + { + return ((float)Value).ToString(); + } + else if (Value is double) + { + return ((double)Value).ToString(); + } + else if (Value is char) + { + return ToString((char)Value); + } + else if (Value is DateTime) + { + return ToString((DateTime)Value); + } + else + { + char[] CharArray = Value as char[]; + if (CharArray is not null) + { + return new string(CharArray); + } + } + throw new InvalidCastException(); + } + public static new string ToString(bool Value) { - XElement elem = obj as XElement; - if (elem is not null) + if (Value) + { + return bool.TrueString; + } + else + { + return bool.FalseString; + } + } + public static new string ToString(byte Value) + { + return Value.ToString(); + } + public static new string ToString(char Value) + { + return Value.ToString(); + } + internal static System.Globalization.CultureInfo GetCultureInfo() + { + return System.Globalization.CultureInfo.CurrentCulture; + } + internal static string ToHalfwidthNumbers(string s, System.Globalization.CultureInfo culture) + { + return s; + } + internal static bool IsHexOrOctValue(string Value, ref long i64Value) + { + char ch; + int Length; + var FirstNonspace = default(int); + string TmpValue; + Length = Value.Length; + while (FirstNonspace < Length) + { + ch = Value[FirstNonspace]; + if (ch == '&' && FirstNonspace + 2 < Length) + { + goto GetSpecialValue; + } + if (ch != Strings.ChrW(32) && ch != Strings.ChrW(0x3000)) + { + return false; + } + FirstNonspace += 1; + } + return false; + GetSpecialValue: + ; + + ch = char.ToLowerInvariant(Value[FirstNonspace + 1]); + TmpValue = ToHalfwidthNumbers(Value.Substring(FirstNonspace + 2), GetCultureInfo()); + if (ch == 'h') + { + i64Value = Convert.ToInt64(TmpValue, 16); + } + else if (ch == 'o') { - return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elem); + i64Value = Convert.ToInt64(TmpValue, 8); } else { - IEnumerable elems = obj as IEnumerable; - if (elems is not null) + throw new FormatException(); + } + return true; + } + internal static bool IsHexOrOctValue(string Value, ref ulong ui64Value) + { + char ch; + int Length; + var FirstNonspace = default(int); + string TmpValue; + Length = Value.Length; + while (FirstNonspace < Length) + { + ch = Value[FirstNonspace]; + if (ch == '&' && FirstNonspace + 2 < Length) { - return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elems); + goto GetSpecialValue; } + if (ch != Strings.ChrW(32) && ch != Strings.ChrW(0x3000)) + { + return false; + } + FirstNonspace += 1; + } + return false; + GetSpecialValue: + ; + + ch = char.ToLowerInvariant(Value[FirstNonspace + 1]); + TmpValue = ToHalfwidthNumbers(Value.Substring(FirstNonspace + 2), GetCultureInfo()); + if (ch == 'h') + { + ui64Value = Convert.ToUInt64(TmpValue, 16); + } + else if (ch == 'o') + { + ui64Value = Convert.ToUInt64(TmpValue, 8); + } + else + { + throw new FormatException(); } + return true; } - return obj; - } - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static IEnumerable RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, IEnumerable obj) - { - if (obj is not null) + public static T ToGenericParameter(object Value) { - IEnumerable elems = obj as IEnumerable; - if (elems is not null) + if (Value is null) + { + return default(T); + } + var reflectedType = typeof(T); + if (Equals(reflectedType, typeof(bool))) + { + return (T)(object)ToBoolean(Value); + } + else if (Equals(reflectedType, typeof(sbyte))) + { + return (T)(object)ToSByte(Value); + } + else if (Equals(reflectedType, typeof(byte))) + { + return (T)(object)ToByte(Value); + } + else if (Equals(reflectedType, typeof(short))) + { + return (T)(object)ToShort(Value); + } + else if (Equals(reflectedType, typeof(ushort))) + { + return (T)(object)ToUShort(Value); + } + else if (Equals(reflectedType, typeof(int))) + { + return (T)(object)ToInteger(Value); + } + else if (Equals(reflectedType, typeof(uint))) + { + return (T)(object)ToUInteger(Value); + } + else if (Equals(reflectedType, typeof(long))) + { + return (T)(object)ToLong(Value); + } + else if (Equals(reflectedType, typeof(ulong))) + { + return (T)(object)ToULong(Value); + } + else if (Equals(reflectedType, typeof(decimal))) + { + return (T)(object)ToDecimal(Value); + } + else if (Equals(reflectedType, typeof(float))) + { + return (T)(object)ToSingle(Value); + } + else if (Equals(reflectedType, typeof(double))) + { + return (T)(object)ToDouble(Value); + } + else if (Equals(reflectedType, typeof(DateTime))) + { + return (T)(object)ToDate(Value); + } + else if (Equals(reflectedType, typeof(char))) + { + return (T)(object)ToChar(Value); + } + else if (Equals(reflectedType, typeof(string))) { - return elems.Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessXElement); + return (T)ToString(Value); } else { - return obj.Cast().Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessObject); + return (T)Value; } } - return obj; } + [Embedded()] [DebuggerNonUserCode()] [System.Runtime.CompilerServices.CompilerGenerated()] [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - private sealed class RemoveNamespaceAttributesClosure + internal sealed class ProjectData { - private readonly string[] m_inScopePrefixes; - private readonly XNamespace[] m_inScopeNs; - private readonly List m_attributes; - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal RemoveNamespaceAttributesClosure(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes) + private ProjectData() + { + } + public static void SetProjectError(Exception ex) + { + } + public static void SetProjectError(Exception ex, int lErl) + { + } + public static void ClearProjectError() { - m_inScopePrefixes = inScopePrefixes; - m_inScopeNs = inScopeNs; - m_attributes = attributes; } - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal XElement ProcessXElement(XElement elem) + } + [Embedded()] + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal sealed class Utils + { + private Utils() { - return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem); } - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal object ProcessObject(object obj) + public static Array CopyArray(Array arySrc, Array aryDest) { - XElement elem = obj as XElement; - if (elem is not null) + if (arySrc is null) + { + return aryDest; + } + int lLength; + lLength = arySrc.Length; + if (lLength == 0) + { + return aryDest; + } + if (aryDest.Rank != arySrc.Rank) + { + throw new InvalidCastException(); + } + int iDim; + var loopTo = aryDest.Rank - 2; + for (iDim = 0; iDim <= loopTo; iDim++) { - return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem); + if (aryDest.GetUpperBound(iDim) != arySrc.GetUpperBound(iDim)) + { + throw new ArrayTypeMismatchException(); + } + } + if (lLength > aryDest.Length) + { + lLength = aryDest.Length; + } + if (arySrc.Rank > 1) + { + int LastRank = arySrc.Rank; + int lenSrcLastRank = arySrc.GetLength(LastRank - 1); + int lenDestLastRank = aryDest.GetLength(LastRank - 1); + if (lenDestLastRank == 0) + { + return aryDest; + } + int lenCopy = lenSrcLastRank > lenDestLastRank ? lenDestLastRank : lenSrcLastRank; + int i; + var loopTo1 = arySrc.Length / lenSrcLastRank - 1; + for (i = 0; i <= loopTo1; i++) + Array.Copy(arySrc, i * lenSrcLastRank, aryDest, i * lenDestLastRank, lenCopy); } else { - return obj; + Array.Copy(arySrc, aryDest, lLength); } + return aryDest; } } + [Embedded()] + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static XElement RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, XElement e) + internal sealed class ObjectFlowControl { - if (e is not null) + internal sealed class ForLoopControl { - var a = e.FirstAttribute; - - while (a is not null) + public static bool ForNextCheckR4(float count, float limit, float StepValue) { - var nextA = a.NextAttribute; - - if (a.IsNamespaceDeclaration) + if (StepValue >= 0f) { - var ns = a.Annotation(); - string prefix = a.Name.LocalName; - - if (ns is not null) - { - if (inScopePrefixes is not null && inScopeNs is not null) - { - int lastIndex = inScopePrefixes.Length - 1; - - for (int i = 0, loopTo = lastIndex; i <= loopTo; i++) - { - string currentInScopePrefix = inScopePrefixes[i]; - var currentInScopeNs = inScopeNs[i]; - if (prefix.Equals(currentInScopePrefix)) - { - if (ns == currentInScopeNs) - { - // prefix and namespace match. Remove the unneeded ns attribute - a.Remove(); - } - - // prefix is in scope but refers to something else. Leave the ns attribute. - a = null; - break; - } - } - } - - if (a is not null) - { - // Prefix is not in scope - // Now check whether it's going to be in scope because it is in the attributes list - - if (attributes is not null) - { - int lastIndex = attributes.Count - 1; - for (int i = 0, loopTo1 = lastIndex; i <= loopTo1; i++) - { - var currentA = attributes[i]; - string currentInScopePrefix = currentA.Name.LocalName; - var currentInScopeNs = currentA.Annotation(); - if (currentInScopeNs is not null) - { - if (prefix.Equals(currentInScopePrefix)) - { - if (ns == currentInScopeNs) - { - // prefix and namespace match. Remove the unneeded ns attribute - a.Remove(); - } - - // prefix is in scope but refers to something else. Leave the ns attribute. - a = null; - break; - } - } - } - } - - if (a is not null) - { - // Prefix is definitely not in scope - a.Remove(); - // namespace is not defined either. Add this attributes list - attributes.Add(a); - } - } - } + return count <= limit; + } + else + { + return count >= limit; + } + } + public static bool ForNextCheckR8(double count, double limit, double StepValue) + { + if (StepValue >= 0d) + { + return count <= limit; + } + else + { + return count >= limit; + } + } + public static bool ForNextCheckDec(decimal count, decimal limit, decimal StepValue) + { + if (StepValue >= 0m) + { + return count <= limit; + } + else + { + return count >= limit; } - - a = nextA; } } - return e; } - + [Embedded()] + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal sealed class StaticLocalInitFlag + { + public short State; + } + [Embedded()] + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal sealed class IncompleteInitialization : Exception + { + public IncompleteInitialization() : base() + { + } + } + [Embedded()] + [AttributeUsage(AttributeTargets.Class, Inherited = false)] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [System.Runtime.CompilerServices.CompilerGenerated()] + internal sealed class StandardModuleAttribute : Attribute + { + } + [Embedded()] + [AttributeUsage(AttributeTargets.Class, Inherited = false)] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [System.Runtime.CompilerServices.CompilerGenerated()] + internal sealed class DesignerGeneratedAttribute : Attribute + { + } + [Embedded()] + [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [System.Runtime.CompilerServices.CompilerGenerated()] + internal sealed class OptionCompareAttribute : Attribute + { + } + [Embedded()] + [AttributeUsage(AttributeTargets.Class, Inherited = false)] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [System.Runtime.CompilerServices.CompilerGenerated()] + internal sealed class OptionTextAttribute : Attribute + { + } + } + [Embedded()] + [AttributeUsage(AttributeTargets.Class, Inherited = false)] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [System.Runtime.CompilerServices.CompilerGenerated()] + internal sealed class HideModuleNameAttribute : Attribute + { + } + [Embedded()] + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] + [StandardModule] + internal static class Strings + { + public static char ChrW(int CharCode) + { + if (CharCode < -32768 || CharCode > 65535) + { + throw new ArgumentException(); + } + return Convert.ToChar(CharCode & 0xFFFF); + } + public static int AscW(string String) + { + if (String is null || String.Length == 0) + { + throw new ArgumentException(); + } + return AscW(String[0]); + } + public static int AscW(char String) + { + return AscW(String); + } + } + [Embedded()] + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] + [StandardModule] + internal static class Constants + { + public const string vbCrLf = Conversions.ToString(Strings.ChrW(13)) + Strings.ChrW(10); + public const string vbNewLine = Conversions.ToString(Strings.ChrW(13)) + Strings.ChrW(10); + public const string vbCr = "\r"; + public const string vbLf = "\n"; + public const string vbBack = "\b"; + public const string vbFormFeed = "\f"; + public const string vbTab = "\t"; + public const string vbVerticalTab = "\v"; + public const string vbNullChar = "\0"; + public const string vbNullString = null; } } \ No newline at end of file diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/MyNamespace.Static.3.Designer.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/MyNamespace.Static.3.Designer.cs index 75d58675f..29ee4992f 100644 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/MyNamespace.Static.3.Designer.cs +++ b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/MyNamespace.Static.3.Designer.cs @@ -1,16 +1,241 @@ +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Xml.Linq; +using Microsoft.VisualBasic; // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; - -namespace Microsoft.VisualBasic +// See Compiler::LoadXmlSolutionExtension +namespace VbLibrary.My { [Embedded()] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Module | AttributeTargets.Assembly, Inherited = false)] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [DebuggerNonUserCode()] [System.Runtime.CompilerServices.CompilerGenerated()] - internal sealed class Embedded : Attribute + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal sealed class InternalXmlHelper { + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + private InternalXmlHelper() + { + } + public static string get_Value(IEnumerable source) + { + foreach (XElement item in source) + return item.Value; + return null; + } + + public static void set_Value(IEnumerable source, string value) + { + foreach (XElement item in source) + { + item.Value = value; + break; + } + } + public static string get_AttributeValue(IEnumerable source, XName name) + { + foreach (XElement item in source) + return (string)item.Attribute(name); + return null; + } + + public static void set_AttributeValue(IEnumerable source, XName name, string value) + { + foreach (XElement item in source) + { + item.SetAttributeValue(name, value); + break; + } + } + public static string get_AttributeValue(XElement source, XName name) + { + return (string)source.Attribute(name); + } + + public static void set_AttributeValue(XElement source, XName name, string value) + { + source.SetAttributeValue(name, value); + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public static XAttribute CreateAttribute(XName name, object value) + { + if (value is null) + { + return null; + } + return new XAttribute(name, value); + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public static XAttribute CreateNamespaceAttribute(XName name, XNamespace ns) + { + var a = new XAttribute(name, ns.NamespaceName); + a.AddAnnotation(ns); + return a; + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public static object RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, object obj) + { + if (obj is not null) + { + XElement elem = obj as XElement; + if (elem is not null) + { + return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elem); + } + else + { + IEnumerable elems = obj as IEnumerable; + if (elems is not null) + { + return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elems); + } + } + } + return obj; + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public static IEnumerable RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, IEnumerable obj) + { + if (obj is not null) + { + IEnumerable elems = obj as IEnumerable; + if (elems is not null) + { + return elems.Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessXElement); + } + else + { + return obj.Cast().Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessObject); + } + } + return obj; + } + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + private sealed class RemoveNamespaceAttributesClosure + { + private readonly string[] m_inScopePrefixes; + private readonly XNamespace[] m_inScopeNs; + private readonly List m_attributes; + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal RemoveNamespaceAttributesClosure(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes) + { + m_inScopePrefixes = inScopePrefixes; + m_inScopeNs = inScopeNs; + m_attributes = attributes; + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal XElement ProcessXElement(XElement elem) + { + return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem); + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal object ProcessObject(object obj) + { + XElement elem = obj as XElement; + if (elem is not null) + { + return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem); + } + else + { + return obj; + } + } + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public static XElement RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, XElement e) + { + if (e is not null) + { + var a = e.FirstAttribute; + + while (a is not null) + { + var nextA = a.NextAttribute; + + if (a.IsNamespaceDeclaration) + { + var ns = a.Annotation(); + string prefix = a.Name.LocalName; + + if (ns is not null) + { + if (inScopePrefixes is not null && inScopeNs is not null) + { + int lastIndex = inScopePrefixes.Length - 1; + + for (int i = 0, loopTo = lastIndex; i <= loopTo; i++) + { + string currentInScopePrefix = inScopePrefixes[i]; + var currentInScopeNs = inScopeNs[i]; + if (prefix.Equals(currentInScopePrefix)) + { + if (ns == currentInScopeNs) + { + // prefix and namespace match. Remove the unneeded ns attribute + a.Remove(); + } + + // prefix is in scope but refers to something else. Leave the ns attribute. + a = null; + break; + } + } + } + + if (a is not null) + { + // Prefix is not in scope + // Now check whether it's going to be in scope because it is in the attributes list + + if (attributes is not null) + { + int lastIndex = attributes.Count - 1; + for (int i = 0, loopTo1 = lastIndex; i <= loopTo1; i++) + { + var currentA = attributes[i]; + string currentInScopePrefix = currentA.Name.LocalName; + var currentInScopeNs = currentA.Annotation(); + if (currentInScopeNs is not null) + { + if (prefix.Equals(currentInScopePrefix)) + { + if (ns == currentInScopeNs) + { + // prefix and namespace match. Remove the unneeded ns attribute + a.Remove(); + } + + // prefix is in scope but refers to something else. Leave the ns attribute. + a = null; + break; + } + } + } + } + + if (a is not null) + { + // Prefix is definitely not in scope + a.Remove(); + // namespace is not defined either. Add this attributes list + attributes.Add(a); + } + } + } + } + + a = nextA; + } + } + return e; + } + } } \ No newline at end of file diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/Settings.Designer.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/Settings.Designer.cs deleted file mode 100644 index b50174bb1..000000000 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/Settings.Designer.cs +++ /dev/null @@ -1,88 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -using System.Diagnostics; -using Microsoft.VisualBasic; - - -namespace VbLibrary.My -{ - - [System.Runtime.CompilerServices.CompilerGenerated()] - [System.CodeDom.Compiler.GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.1.0.0")] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)] - internal sealed partial class MySettings : System.Configuration.ApplicationSettingsBase - { - - private static MySettings defaultInstance = (MySettings)Synchronized(new MySettings()); - - #region My.Settings Auto-Save Functionality - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MyType = "WindowsForms" Then - *//* TODO ERROR: Skipped DisabledTextTrivia - Private Shared addedHandler As Boolean - - Private Shared addedHandlerLockObject As New Object - - _ - Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) - If My.Application.SaveMySettingsOnExit Then - My.Settings.Save() - End If - End Sub - *//* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - #endregion - - public static MySettings Default - { - get - { - - /* TODO ERROR: Skipped IfDirectiveTrivia - #If _MyType = "WindowsForms" Then - *//* TODO ERROR: Skipped DisabledTextTrivia - If Not addedHandler Then - SyncLock addedHandlerLockObject - If Not addedHandler Then - AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings - addedHandler = True - End If - End SyncLock - End If - *//* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - return defaultInstance; - } - } - } -} - -namespace VbLibrary.My -{ - - [HideModuleName()] - [DebuggerNonUserCode()] - [System.Runtime.CompilerServices.CompilerGenerated()] - internal static class MySettingsProperty - { - - [System.ComponentModel.Design.HelpKeyword("My.Settings")] - internal static MySettings Settings - { - get - { - return MySettings.Default; - } - } - } -} \ No newline at end of file diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/Resources.Designer.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/Resources.Designer.cs deleted file mode 100644 index 9b3d19ae8..000000000 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/Resources.Designer.cs +++ /dev/null @@ -1,70 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - - -using System.Diagnostics; -using Microsoft.VisualBasic; - -namespace VbLibrary.My.Resources -{ - - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - [System.CodeDom.Compiler.GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [DebuggerNonUserCode()] - [System.Runtime.CompilerServices.CompilerGenerated()] - [HideModuleName()] - internal static class Resources - { - - private static System.Resources.ResourceManager resourceMan; - - private static System.Globalization.CultureInfo resourceCulture; - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)] - internal static System.Resources.ResourceManager ResourceManager - { - get - { - if (ReferenceEquals(resourceMan, null)) - { - var temp = new System.Resources.ResourceManager("VbLibrary.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)] - internal static System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} \ No newline at end of file diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/Resources.resx b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/Resources.resx deleted file mode 100644 index 98745a7c7..000000000 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/VbLibrary.csproj b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/VbLibrary.csproj index 9b886fc40..8a712594c 100644 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/VbLibrary.csproj +++ b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/VbLibrary.csproj @@ -1,128 +1,13 @@ - - - + - Debug - AnyCPU - {913DD733-37BF-05CF-35C5-5BD4A0431C47} - Exe - VbLibrary.Module1 VbLibrary - VbLibrary - 512 - Console - v4.8 - true - true - + netstandard2.1 $(DefaultItemExcludes);$(ProjectDir)**\*.vb latest - - AnyCPU - true - full - bin\Debug\ - bin\Debug\VbLibrary.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - TRACE;DEBUG - - - AnyCPU - pdbonly - true - bin\Release\ - bin\Release\VbLibrary.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - TRACE - - - On - - - Binary - - - Off - - - On - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - Application.myapp - True - - - True - True - Resources.resx - - - True - Settings.settings - True - - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - VbLibrary.My.Resources - Designer - - - - - MyApplicationCodeGenerator - Application.Designer.cs - - - SettingsSingleFileGenerator - VbLibrary.My - Settings.Designer.cs - - - - - - {49DF6752-696A-0F7B-1455-E2F06769DFAE} - VbNetStandardLib - + - + \ No newline at end of file diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 8a5af6fb6..0ea2bd3a5 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -10,6 +10,7 @@ + all diff --git a/Web/ClientApp/package.json b/Web/ClientApp/package.json index 7877a54df..81606d266 100644 --- a/Web/ClientApp/package.json +++ b/Web/ClientApp/package.json @@ -1,64 +1,64 @@ -{ - "name": "codeconverter", - "version": "0.1.0", - "private": true, - "eslintConfig": { - "extends": "react-app" - }, - "scripts": { - "prestart": "node aspnetcore-https && node aspnetcore-react", - "start": "rimraf ./build && react-scripts start", - "build": "react-scripts build", - "test": "cross-env CI=true react-scripts test --env=jsdom", - "eject": "react-scripts eject", - "lint": "eslint ./src/" - }, - "browserslist": { - "production": [ - ">0.2%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 1 chrome version", - "last 1 firefox version", - "last 1 safari version" - ] - }, - "babel": { - "presets": [ - [ - "@babel/preset-react", - { - "runtime": "automatic" - } - ] - ] - }, - "dependencies": { - "@monaco-editor/react": "^4.4.4", - "axios": "^1.6.0", - "bootstrap": "^5.1.3", - "monaco-editor": "^0.33.0", - "prop-types": "^15.8.1", - "react": "^18.1.0", - "react-dom": "^18.1.0", - "react-router-bootstrap": "^0.26.1", - "react-router-dom": "^6.3.0", - "reactstrap": "^9.0.2" - }, - "devDependencies": { - "@types/jest": "^27.4.1", - "@types/react": "^18.0.8", - "@types/react-dom": "^18.0.3", - "ajv": "^8.11.0", - "cross-env": "^7.0.3", - "eslint-config-react-app": "^7.0.1", - "http-proxy-middleware": "^2.0.6", - "jquery": "^3.6.0", - "popper.js": "^1.16.1", - "react-scripts": "^5.0.1", - "rimraf": "^3.0.2", - "typescript": "^4.6.4" - } -} +{ + "name": "codeconverter", + "version": "0.1.0", + "private": true, + "eslintConfig": { + "extends": "react-app" + }, + "scripts": { + "prestart": "node aspnetcore-https && node aspnetcore-react", + "start": "rimraf ./build && react-scripts start", + "build": "react-scripts build", + "test": "cross-env CI=true react-scripts test --env=jsdom", + "eject": "react-scripts eject", + "lint": "eslint ./src/" + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + }, + "babel": { + "presets": [ + [ + "@babel/preset-react", + { + "runtime": "automatic" + } + ] + ] + }, + "dependencies": { + "@monaco-editor/react": "^4.4.4", + "axios": "^1.6.0", + "bootstrap": "^5.1.3", + "monaco-editor": "^0.33.0", + "prop-types": "^15.8.1", + "react": "^18.1.0", + "react-dom": "^18.1.0", + "react-router-bootstrap": "^0.26.1", + "react-router-dom": "^6.3.0", + "reactstrap": "^9.0.2" + }, + "devDependencies": { + "@types/jest": "^27.4.1", + "@types/react": "^18.0.8", + "@types/react-dom": "^18.0.3", + "ajv": "^8.11.0", + "cross-env": "^7.0.3", + "eslint-config-react-app": "^7.0.1", + "http-proxy-middleware": "^2.0.6", + "jquery": "^3.6.0", + "popper.js": "^1.16.1", + "react-scripts": "^5.0.1", + "rimraf": "^3.0.2", + "typescript": "^4.6.4" + } +}