paul1956 / CSharpToVB

New version of CSharpToVB converter
MIT License
26 stars 9 forks source link

Compilation errors and runtime error #69

Closed Whismeril closed 3 years ago

Whismeril commented 3 years ago

Hello,

compilation returns me errors 's_LightModeColorDictionary' is not defined and 's_DarkModeColorDictionary' is not defined In the file ColorSelector.vb I've found this 2 commented lines ` 'Friend s_DarkModeColorDictionary As New Dictionary(Of String, ColorDescriptor)(StringComparer.OrdinalIgnoreCase)

'Friend s_LightModeColorDictionary As New Dictionary(Of String, ColorDescriptor)(StringComparer.OrdinalIgnoreCase)`

I've tried uncomment them. Then compilation goes on, but at runtime, eventHandler MyApplication_UnhandledException occurs. The problem is in Fom1.Load, this line DefaultColor = CurrentThemeDictionary(ThemeDefaultColor) returns error default key doesn't exist in dictionary, value of ThemeDefaultColor is "default"

I've tried download zip code and clone the repository, both give me these errors.

I've Visual Studio Community 2019 16.8.5. SDK .NET 5 and NetStandard 2 are installed.

Where is my mistake?

Thanks

Whismeril commented 3 years ago

Second problem comes because I don't have LightModeColorDictionary.csv and DarkModeColorDictionary.csv in My Documents and program doesn't load default values. I've found this files in directory Asset so I've moved them it in My Documents, (because Sub UpdateColorDictionariesFromFile doesn't update dictionaries if files in Asset and My Document are the same)

paul1956 commented 3 years ago

@Whismeril This current version requires 16.9 Preview 4 to support Visual Basic Source Generation. This was an unfortunate result of wanting to move to Source Generation too soon without specifying 16.9 Preview as a requirement. I have updated it to support Visual Studio 2019 Version 16.8.0 IF Assets Csv_LightModeColorDictionary.vb and Csv_DarkModeColorDictionary.vb are included in project.

Whismeril commented 3 years ago

Thanks

Whismeril commented 3 years ago

Compilation errors steel occurs

Capture1

It seems be cause of this lines are commented Capture2

Whismeril commented 3 years ago

Runtime errors steel occurs too.

In form Load, as this time s_LightModeColorDictionary and s_DarkModeColorDictionary are empty image

So CurrentThemeDictionary is empty too. image

Sub UpdateColorDictionariesFromFile doesn't fill data in s_LightModeColorDictionary and s_DarkModeColorDictionary because there is not data to update (for the test I've deleted files in My Documents, let them in Asset Directory) It means that files in Asset Directory should be filled before by sub LoadColorDictionaryFromFile but are not.

Whismeril commented 3 years ago

this correction works for me, but name UpdateColorDictionariesFromFile is not good now

    Public Sub UpdateColorDictionariesFromFile()
        Dim executableDirectoryPath As String = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Assets")
        Dim assetColorFile As String = Path.Combine(executableDirectoryPath, _lightModeDictionaryFileName)
        Dim userColorFile As String = Path.Combine(FileIO.SpecialDirectories.MyDocuments, _lightModeDictionaryFileName)

        If s_LightModeColorDictionary.Count = 0 Then 'load file in Asset directory if needed
            LoadColorDictionaryFromFile(assetColorFile, s_LightModeColorDictionary)
        End If

        If File.Exists(userColorFile) AndAlso assetColorFile.AreNotSame(userColorFile) Then
            s_LightModeColorDictionary = MergeColorDictionary(userColorFile, File.GetLastAccessTime(assetColorFile), s_LightModeColorDictionary)
        End If
        assetColorFile = Path.Combine(executableDirectoryPath, _darkModeDictionaryFileName)
        userColorFile = Path.Combine(FileIO.SpecialDirectories.MyDocuments, _darkModeDictionaryFileName)

        If s_DarkModeColorDictionary.Count = 0 Then 'load file in Asset directory if needed
            LoadColorDictionaryFromFile(assetColorFile, s_DarkModeColorDictionary)
        End If

        If File.Exists(userColorFile) AndAlso assetColorFile.AreNotSame(userColorFile) Then
            s_DarkModeColorDictionary = MergeColorDictionary(userColorFile, File.GetLastWriteTime(assetColorFile), s_DarkModeColorDictionary)
        End If
    End Sub
paul1956 commented 3 years ago

@Whismeril I will post a fix tonight. I should have tested this more on 16.8

paul1956 commented 3 years ago

@Whismeri tested and posted fix in Branch Support16.8. I will leave that there until 16.9 ships. Sorry for the issue. You should delete the 2 saved dictionaries in MyDocuments. You don't need to load the dictionaries they are static data in Assets for 16.8. Until I have full Theming editing them is a bad idea.

Whismeril commented 3 years ago

Thanks for you reactivity. I used your converter yesterday to translate source I let on french open source platform. I’ve found few mistakes with = and is. I’ll make short example and open a specific issue.

paul1956 commented 3 years ago

@Whismeril Yes please open a separate issue. I will look into it, I know it is not possible for me to get everyone correct especially if you do one file or snippet at a time. Whole project or solution does a better but n perfect job.