Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Microsoft in GCM namespaces/file names #500

Merged
merged 4 commits into from
Nov 1, 2021
Merged

Replace Microsoft in GCM namespaces/file names #500

merged 4 commits into from
Nov 1, 2021

Conversation

ldennington
Copy link
Contributor

@ldennington ldennington commented Oct 20, 2021

Overview

With this change, we remove Microsoft from GCM Core's project, directory, namespace, and assembly names. We made these updates in a series of four commits corresponding to the following:

  1. Update/set explicit assembly names in .csproj files (and update XAML resource/namespace paths to reflect)
  2. Update/set explicit namespaces
  3. Rename projects/directories
  4. Sign gcmcore.dll

@ldennington ldennington self-assigned this Oct 20, 2021
Copy link
Collaborator

@mjcheetham mjcheetham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can drop to something even simpler, just GitCredentialManager.*. I don't think there's a need to repeat GCM twice (even if one is the "publisher" and the other is the product).

I would also like to take the opportunity to simplify the project names and the assembly names. What do you think to the changes below:

Current Project Name New Project Name New Assembly New Namespace
TestInfrastructure GitCredentialManager.Tests
Microsoft.Git.CredentialManager Core gcmcore.dll GitCredentialManager
Microsoft.Git.CredentialManager.Tests Core.Tests GitCredentialManager.Tests
Microsoft.Git.CredentialManager.UI Core.UI gcmcoreui.dll GitCredentialManager.UI
Microsoft.Git.CredentialManager.UI.Avalonia Core.UI.Avalonia gcmcoreuiavn.dll GitCredentialManager.UI
Shared.UI.Windows Core.UI.Windows gcmcoreuiwpf.dll GitCredentialManager.UI
Git-Credential-Manager GitCredentialManager

It might also be worth splitting this change up in to 3 different parts to make it easier to grok, and traverse history.

  1. Update/set explicit assembly names in csproj files (and update XAML resource/namespace paths to reflect)
  2. Update/set explicit namespaces
  3. Rename projects/directories

This way commit 3 will/should consist only of renames and a few edits in csproj/sln refs only.

Also, by setting some explicit namespaces and assembly names in commits 1-2, we can avoid any extra changes in XAML resource paths etc due to an implicit NS/assembly name changing after the project is renamed.

@ldennington
Copy link
Contributor Author

Going to have to pause for the evening on this. Will work on what's going wrong with the namespace changes in the CredentialsView xaml files tomorrow.

Copy link
Collaborator

@mjcheetham mjcheetham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ldennington thanks for this! I've noticed a problem however 😢
Running the GitHub.UI and Atlassian.Bitbucket.UI helpers results in a crash in failing to resolve XAML resources(!)

I think the problem is that when updating the [a]xaml files, resource paths need the assembly name, and not the namespace. In WPF it is pack://application:,,,/<assembly>;component/<path> and in Avalonia it is avares://<assembly>/<path>.

Here's a patch that should fix the missing/problematic resource paths. It should be applied after the first commit (and then there'll need to be some conflict resolution on the 2nd commit):

diff --git a/src/shared/Microsoft.Git.CredentialManager.UI.Avalonia/Assets/Controls.axaml b/src/shared/Microsoft.Git.CredentialManager.UI.Avalonia/Assets/Controls.axaml
index c1f62b4..9f10e47 100644
--- a/src/shared/Microsoft.Git.CredentialManager.UI.Avalonia/Assets/Controls.axaml
+++ b/src/shared/Microsoft.Git.CredentialManager.UI.Avalonia/Assets/Controls.axaml
@@ -1,6 +1,6 @@
 <Styles xmlns="https://github.com/avaloniaui"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
-    <StyleInclude Source="avares://Microsoft.Git.CredentialManager.UI.Avalonia/Assets/ButtonHyperlink.axaml"/>
+    <StyleInclude Source="avares://gcmcoreuiavn/Assets/ButtonHyperlink.axaml"/>
     <Style Selector="TextBox.monospace">
         <Setter Property="FontFamily" Value="SF Mono, Courier New, Courier, monospace" />
     </Style>
diff --git a/src/shared/Microsoft.Git.CredentialManager.UI.Avalonia/AvaloniaApp.axaml b/src/shared/Microsoft.Git.CredentialManager.UI.Avalonia/AvaloniaApp.axaml
index 849e63b..486f84c 100644
--- a/src/shared/Microsoft.Git.CredentialManager.UI.Avalonia/AvaloniaApp.axaml
+++ b/src/shared/Microsoft.Git.CredentialManager.UI.Avalonia/AvaloniaApp.axaml
@@ -4,12 +4,12 @@
              Name="Git Credential Manager">
     <Application.Styles>
         <FluentTheme Mode="Light"/>
-        <StyleInclude Source="avares://Microsoft.Git.CredentialManager.UI.Avalonia/Assets/Controls.axaml"/>
+        <StyleInclude Source="avares://gcmcoreuiavn/Assets/Controls.axaml"/>
     </Application.Styles>
     <Application.Resources>
         <ResourceDictionary>
             <ResourceDictionary.MergedDictionaries>
-                <ResourceInclude Source="avares://Microsoft.Git.CredentialManager.UI.Avalonia/Assets/LightBase.axaml"/>
+                <ResourceInclude Source="avares://gcmcoreuiavn/Assets/LightBase.axaml"/>
             </ResourceDictionary.MergedDictionaries>
         </ResourceDictionary>
     </Application.Resources>
diff --git a/src/shared/Microsoft.Git.CredentialManager.UI.Avalonia/Controls/AboutWindow.axaml b/src/shared/Microsoft.Git.CredentialManager.UI.Avalonia/Controls/AboutWindow.axaml
index 22ec73b..7658a77 100644
--- a/src/shared/Microsoft.Git.CredentialManager.UI.Avalonia/Controls/AboutWindow.axaml
+++ b/src/shared/Microsoft.Git.CredentialManager.UI.Avalonia/Controls/AboutWindow.axaml
@@ -10,12 +10,12 @@
     <Window.Resources>
         <ResourceDictionary>
             <ResourceDictionary.MergedDictionaries>
-                <ResourceInclude Source="avares://Microsoft.Git.CredentialManager.UI.Avalonia/Assets/Images.axaml"/>
+                <ResourceInclude Source="gcmcoreuiavn/Assets/Images.axaml"/>
             </ResourceDictionary.MergedDictionaries>
         </ResourceDictionary>
     </Window.Resources>
     <Window.Styles>
-        <StyleInclude Source="avares://Microsoft.Git.CredentialManager.UI.Avalonia/Assets/Controls.axaml"/>
+        <StyleInclude Source="avares://gcmcoreuiavn/Assets/Controls.axaml"/>
     </Window.Styles>
     <StackPanel Margin="20">
         <Image HorizontalAlignment="Center"
diff --git a/src/shared/Microsoft.Git.CredentialManager.UI.Avalonia/Controls/DialogWindow.axaml b/src/shared/Microsoft.Git.CredentialManager.UI.Avalonia/Controls/DialogWindow.axaml
index 2940c8d..e0949cf 100644
--- a/src/shared/Microsoft.Git.CredentialManager.UI.Avalonia/Controls/DialogWindow.axaml
+++ b/src/shared/Microsoft.Git.CredentialManager.UI.Avalonia/Controls/DialogWindow.axaml
@@ -2,7 +2,7 @@
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-        xmlns:vm="clr-namespace:Microsoft.Git.CredentialManager.UI.ViewModels;assembly=Microsoft.Git.CredentialManager.UI"
+        xmlns:vm="clr-namespace:Microsoft.Git.CredentialManager.UI.ViewModels;assembly=gcmcoreui"
         xmlns:converters="clr-namespace:Microsoft.Git.CredentialManager.UI.Converters"
         mc:Ignorable="d" d:DesignWidth="420" d:DesignHeight="520"
         x:Class="Microsoft.Git.CredentialManager.UI.Controls.DialogWindow"
diff --git a/src/windows/Atlassian.Bitbucket.UI.Windows/Assets/Styles.xaml b/src/windows/Atlassian.Bitbucket.UI.Windows/Assets/Styles.xaml
index 338e98e..67fe8a5 100644
--- a/src/windows/Atlassian.Bitbucket.UI.Windows/Assets/Styles.xaml
+++ b/src/windows/Atlassian.Bitbucket.UI.Windows/Assets/Styles.xaml
@@ -1,6 +1,6 @@
 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
     <ResourceDictionary.MergedDictionaries>
-        <ResourceDictionary Source="pack://application:,,,/Microsoft.Git.CredentialManager.UI.Windows;component/Assets/Styles.xaml"/>
+        <ResourceDictionary Source="pack://application:,,,/gcmcoreuiwpf;component/Assets/Styles.xaml"/>
     </ResourceDictionary.MergedDictionaries>
 </ResourceDictionary>
diff --git a/src/windows/GitHub.UI.Windows/Assets/Styles.xaml b/src/windows/GitHub.UI.Windows/Assets/Styles.xaml
index 338e98e..67fe8a5 100644
--- a/src/windows/GitHub.UI.Windows/Assets/Styles.xaml
+++ b/src/windows/GitHub.UI.Windows/Assets/Styles.xaml
@@ -1,6 +1,6 @@
 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
     <ResourceDictionary.MergedDictionaries>
-        <ResourceDictionary Source="pack://application:,,,/Microsoft.Git.CredentialManager.UI.Windows;component/Assets/Styles.xaml"/>
+        <ResourceDictionary Source="pack://application:,,,/gcmcoreuiwpf;component/Assets/Styles.xaml"/>
     </ResourceDictionary.MergedDictionaries>
 </ResourceDictionary>
diff --git a/src/windows/Shared.UI.Windows/Controls/DialogWindow.xaml b/src/windows/Shared.UI.Windows/Controls/DialogWindow.xaml
index ebdf112..ef262d5 100644
--- a/src/windows/Shared.UI.Windows/Controls/DialogWindow.xaml
+++ b/src/windows/Shared.UI.Windows/Controls/DialogWindow.xaml
@@ -3,7 +3,7 @@
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
-        xmlns:viewModels="clr-namespace:Microsoft.Git.CredentialManager.UI.ViewModels;assembly=Microsoft.Git.CredentialManager.UI"
+        xmlns:viewModels="clr-namespace:Microsoft.Git.CredentialManager.UI.ViewModels;assembly=gcmcoreui"
         Width="414"
         SizeToContent="Height"
         MinHeight="320"

This change updates the following assembly names:

Microsoft.Git.CredentialManager --> gcmcore
Microsoft.Git.CredentialManager.UI --> gcmcoreui
Microsoft.Git.CredentialManager.UI.Avalonia --> gcmcoreuiavn
Shared.UI.Windows --> gcmcoreuiwpf

It also updates the corresponding xaml/iss files with the new names.
Copy link
Collaborator

@mjcheetham mjcheetham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some failing builds it seems with the Windows/WPF UI helpers?
https://github.com/microsoft/Git-Credential-Manager-Core/runs/4069838162?check_suite_focus=true

There's also some suspicious solution file change on the Shared.UI.Windows project. The rest looks ok.

Comment on lines -31 to -32
$(OutDir)Microsoft.Git.CredentialManager.dll;
$(OutDir)Microsoft.Git.CredentialManager.UI.dll;">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a problem with the changes here, but looks like we've not been signing the gcmcoreui.dll assembly (to use the new names)! Oops..

Git-Credential-Manager.sln Outdated Show resolved Hide resolved
Updated the following namespaces:

TestInfrastructure --> GitCredentialManager.Tests
Microsoft.Git.CredentialManager --> GitCredentialManager
Microsoft.Git.CredentialManager.Tests --> GitCredentialManager.Tests
Microsoft.Git.CredentialManager.UI --> GitCredentialManager.UI
Microsoft.Git.CredentialManager.UI.Avalonia -->	GitCredentialManager.UI
Shared.UI.Windows --> GitCredentialManager.UI
Git-Credential-Manager --> GitCredentialManager
This change updates the following project/directory names according to the
below:

Microsoft.Git.CredentialManager --> Core
Microsoft.Git.CredentialManager.Tests --> Core.Tests
Microsoft.Git.CredentialManager.UI --> Core.UI
Microsoft.Git.CredentialManager.UI.Avalonia --> Core.UI.Avalonia
Shared.UI.Windows --> Core.UI.Windows
Copy link
Collaborator

@mjcheetham mjcheetham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! These sorts of changes are a right PITA, good job!

@ldennington ldennington merged commit 5aa3590 into git-ecosystem:main Nov 1, 2021
This was referenced Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants