diff --git a/GitCommands/DeconstructionExtensions.cs b/GitCommands/DeconstructionExtensions.cs index 18d851f4361..04e55c14539 100644 --- a/GitCommands/DeconstructionExtensions.cs +++ b/GitCommands/DeconstructionExtensions.cs @@ -22,32 +22,5 @@ public static void Deconstruct(this IGrouping so key = source.Key; elements = source; } - - /// - /// Supports C# 7 deconstruction of . - /// - public static void Deconstruct(this Tuple source, out T1 item1) - { - item1 = source.Item1; - } - - /// - /// Supports C# 7 deconstruction of . - /// - public static void Deconstruct(this Tuple source, out T1 item1, out T2 item2) - { - item1 = source.Item1; - item2 = source.Item2; - } - - /// - /// Supports C# 7 deconstruction of . - /// - public static void Deconstruct(this Tuple source, out T1 item1, out T2 item2, out T3 item3) - { - item1 = source.Item1; - item2 = source.Item2; - item3 = source.Item3; - } } } \ No newline at end of file diff --git a/GitCommands/Git/EnvironmentConfiguration.cs b/GitCommands/Git/EnvironmentConfiguration.cs index fc57facda0f..274fabe6007 100644 --- a/GitCommands/Git/EnvironmentConfiguration.cs +++ b/GitCommands/Git/EnvironmentConfiguration.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using GitCommands.Utils; using JetBrains.Annotations; diff --git a/GitCommands/Git/GitModule.cs b/GitCommands/Git/GitModule.cs index f855ca2e42f..efaab93fa02 100644 --- a/GitCommands/Git/GitModule.cs +++ b/GitCommands/Git/GitModule.cs @@ -8,7 +8,6 @@ using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; -using System.Threading; using System.Threading.Tasks; using GitCommands.Config; using GitCommands.Git; diff --git a/GitCommands/GitCommands.csproj b/GitCommands/GitCommands.csproj index 86e48570da9..a96ad4d3853 100644 --- a/GitCommands/GitCommands.csproj +++ b/GitCommands/GitCommands.csproj @@ -85,6 +85,9 @@ True + + ..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll + diff --git a/GitCommands/Settings/AppSettings.cs b/GitCommands/Settings/AppSettings.cs index 2bf595e05be..af344b4d9d6 100644 --- a/GitCommands/Settings/AppSettings.cs +++ b/GitCommands/Settings/AppSettings.cs @@ -1496,7 +1496,7 @@ public static bool IsPortable() return Properties.Settings.Default.IsPortable; } - private static IEnumerable> GetSettingsFromRegistry() + private static IEnumerable<(string name, string value)> GetSettingsFromRegistry() { RegistryKey oldSettings = VersionIndependentRegKey.OpenSubKey("GitExtensions"); @@ -1511,7 +1511,7 @@ private static IEnumerable> GetSettingsFromRegistry() if (value != null) { - yield return Tuple.Create(name, value.ToString()); + yield return (name, value.ToString()); } } } diff --git a/GitCommands/Settings/SettingsCache.cs b/GitCommands/Settings/SettingsCache.cs index b3a67d76002..26ae9f3e202 100644 --- a/GitCommands/Settings/SettingsCache.cs +++ b/GitCommands/Settings/SettingsCache.cs @@ -64,7 +64,7 @@ public void Load() }); } - public void Import(IEnumerable> keyValuePairs) + public void Import(IEnumerable<(string name, string value)> keyValuePairs) { LockedAction(() => { diff --git a/GitCommands/Statistics/CommitCounter.cs b/GitCommands/Statistics/CommitCounter.cs index 0edfa49cb22..b0bdf341a25 100644 --- a/GitCommands/Statistics/CommitCounter.cs +++ b/GitCommands/Statistics/CommitCounter.cs @@ -6,12 +6,14 @@ namespace GitCommands.Statistics { public static class CommitCounter { - public static Tuple, int> GroupAllCommitsByContributor(IGitModule module) + public static (Dictionary commitsPerContributor, int totalCommits) + GroupAllCommitsByContributor(IGitModule module) { return GroupAllCommitsByContributor(module, DateTime.MinValue, DateTime.MaxValue); } - private static Tuple, int> GroupAllCommitsByContributor(IGitModule module, DateTime since, DateTime until) + private static (Dictionary commitsPerContributor, int totalCommits) + GroupAllCommitsByContributor(IGitModule module, DateTime since, DateTime until) { var sinceParam = since != DateTime.MinValue ? GetDateParameter(since, "since") : ""; var untilParam = until != DateTime.MaxValue ? GetDateParameter(since, "until") : ""; @@ -24,8 +26,8 @@ private static Tuple, int> GroupAllCommitsByContributor( return ParseCommitsPerContributor(unformattedCommitsPerContributor); } - private static Tuple, int> ParseCommitsPerContributor( - IEnumerable unformattedCommitsPerContributor) + private static (Dictionary commitsPerContributor, int totalCommits) + ParseCommitsPerContributor(IEnumerable unformattedCommitsPerContributor) { var commitsPerContributor = new Dictionary(); var delimiter = new[] { ' ', '\t' }; @@ -62,7 +64,7 @@ private static Tuple, int> ParseCommitsPerContributor( } } - return Tuple.Create(commitsPerContributor, totalCommits); + return (commitsPerContributor, totalCommits); } private static string GetDateParameter(DateTime sinceDate, string paramName) diff --git a/GitCommands/packages.config b/GitCommands/packages.config index 9282384d2fe..b86bd484b47 100644 --- a/GitCommands/packages.config +++ b/GitCommands/packages.config @@ -7,4 +7,5 @@ + \ No newline at end of file diff --git a/GitExtUtils/Properties/AssemblyInfo.cs b/GitExtUtils/Properties/AssemblyInfo.cs index 6ce361eb5d6..f731286cac3 100644 --- a/GitExtUtils/Properties/AssemblyInfo.cs +++ b/GitExtUtils/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; [assembly: InternalsVisibleTo("GitExtensions")] [assembly: InternalsVisibleTo("CommonTestUtils")] diff --git a/GitExtensions/Program.cs b/GitExtensions/Program.cs index c767162c5cf..188c0d81252 100644 --- a/GitExtensions/Program.cs +++ b/GitExtensions/Program.cs @@ -1,8 +1,6 @@ using System; using System.Configuration; using System.IO; -using System.Threading; -using System.Threading.Tasks; using System.Windows.Forms; using GitCommands; using GitCommands.Utils; diff --git a/GitUI/CommandsDialogs/BrowseDialog/FormBisect.cs b/GitUI/CommandsDialogs/BrowseDialog/FormBisect.cs index eee3805ff6a..8f0ae0332a1 100644 --- a/GitUI/CommandsDialogs/BrowseDialog/FormBisect.cs +++ b/GitUI/CommandsDialogs/BrowseDialog/FormBisect.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using GitCommands; diff --git a/GitUI/CommandsDialogs/BrowseDialog/FormBrowseMenus.cs b/GitUI/CommandsDialogs/BrowseDialog/FormBrowseMenus.cs index a694abc27ca..8e987a5a937 100644 --- a/GitUI/CommandsDialogs/BrowseDialog/FormBrowseMenus.cs +++ b/GitUI/CommandsDialogs/BrowseDialog/FormBrowseMenus.cs @@ -138,10 +138,10 @@ private void CreateAdditionalMainMenuItems() } } - private IEnumerable> GetAdditionalMainMenuItemsForTranslation() + private IEnumerable<(string name, object item)> GetAdditionalMainMenuItemsForTranslation() { var list = new[] { _navigateToolStripMenuItem, _viewToolStripMenuItem }; - return list.Select(menuItem => Tuple.Create(menuItem.Name, (object)menuItem)); + return list.Select(menuItem => (menuItem.Name, (object)menuItem)); } private void SetDropDownItems(ToolStripMenuItem toolStripMenuItemTarget, IEnumerable menuCommands) diff --git a/GitUI/CommandsDialogs/BrowseDialog/MenuCommand.cs b/GitUI/CommandsDialogs/BrowseDialog/MenuCommand.cs index 39604fd15c2..e7316ea9fac 100644 --- a/GitUI/CommandsDialogs/BrowseDialog/MenuCommand.cs +++ b/GitUI/CommandsDialogs/BrowseDialog/MenuCommand.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Drawing; -using System.Linq; using System.Windows.Forms; namespace GitUI.CommandsDialogs.BrowseDialog diff --git a/GitUI/CommandsDialogs/BrowseDialog/MenuCommandsBase.cs b/GitUI/CommandsDialogs/BrowseDialog/MenuCommandsBase.cs index dcf0990eab5..1811a062eaf 100644 --- a/GitUI/CommandsDialogs/BrowseDialog/MenuCommandsBase.cs +++ b/GitUI/CommandsDialogs/BrowseDialog/MenuCommandsBase.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using GitCommands; using ResourceManager; @@ -31,9 +30,9 @@ public virtual void TranslateItems(ITranslation translation) // override and return all commands created by extending class protected abstract IEnumerable GetMenuCommandsForTranslation(); - private IEnumerable> GetMenuCommandsForTranslationImpl() + private IEnumerable<(string name, object item)> GetMenuCommandsForTranslationImpl() { - return GetMenuCommandsForTranslation().Select(menu => Tuple.Create(menu.Name, (object)menu)); + return GetMenuCommandsForTranslation().Select(menu => (menu.Name, (object)menu)); } } } diff --git a/GitUI/CommandsDialogs/BuildReportTabPageExtension.cs b/GitUI/CommandsDialogs/BuildReportTabPageExtension.cs index dcd165f0184..1f967587fea 100644 --- a/GitUI/CommandsDialogs/BuildReportTabPageExtension.cs +++ b/GitUI/CommandsDialogs/BuildReportTabPageExtension.cs @@ -4,12 +4,10 @@ using System.IO; using System.Linq; using System.Net; -using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using GitCommands; using GitUI.UserControls; -using Microsoft.VisualStudio.Threading; namespace GitUI.CommandsDialogs { diff --git a/GitUI/CommandsDialogs/FormLog.cs b/GitUI/CommandsDialogs/FormLog.cs index 465b1067d25..b88af1c7c65 100644 --- a/GitUI/CommandsDialogs/FormLog.cs +++ b/GitUI/CommandsDialogs/FormLog.cs @@ -1,5 +1,4 @@ using System; -using System.Windows.Forms; using GitCommands; namespace GitUI.CommandsDialogs diff --git a/GitUI/CommandsDialogs/WorktreeDialog/FormCreateWorktree.cs b/GitUI/CommandsDialogs/WorktreeDialog/FormCreateWorktree.cs index 03f5f16a965..49dc44b718b 100644 --- a/GitUI/CommandsDialogs/WorktreeDialog/FormCreateWorktree.cs +++ b/GitUI/CommandsDialogs/WorktreeDialog/FormCreateWorktree.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Threading.Tasks; using System.Windows.Forms; using GitCommands; using GitUIPluginInterfaces; diff --git a/GitUI/GitUI.csproj b/GitUI/GitUI.csproj index 3b5d59c691b..67f8c460b48 100644 --- a/GitUI/GitUI.csproj +++ b/GitUI/GitUI.csproj @@ -102,6 +102,9 @@ True + + ..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll + diff --git a/GitUI/GitUIExtensions.cs b/GitUI/GitUIExtensions.cs index c0a89a3dced..095533a1033 100644 --- a/GitUI/GitUIExtensions.cs +++ b/GitUI/GitUIExtensions.cs @@ -4,7 +4,6 @@ using System.IO; using System.Linq; using System.Text; -using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using GitCommands; diff --git a/GitUI/packages.config b/GitUI/packages.config index 7f61dbb179a..f11aca826c5 100644 --- a/GitUI/packages.config +++ b/GitUI/packages.config @@ -10,4 +10,5 @@ + \ No newline at end of file diff --git a/Plugins/Statistics/GitImpact/FormImpact.cs b/Plugins/Statistics/GitImpact/FormImpact.cs index 39032e7f5cf..11256cf7dda 100644 --- a/Plugins/Statistics/GitImpact/FormImpact.cs +++ b/Plugins/Statistics/GitImpact/FormImpact.cs @@ -1,5 +1,4 @@ using System; -using System.Threading; using System.Windows.Forms; using GitCommands.Statistics; using GitUI; diff --git a/Plugins/Statistics/GitImpact/GitImpact.csproj b/Plugins/Statistics/GitImpact/GitImpact.csproj index 6b2ab15975a..2a609a17acb 100644 --- a/Plugins/Statistics/GitImpact/GitImpact.csproj +++ b/Plugins/Statistics/GitImpact/GitImpact.csproj @@ -50,6 +50,9 @@ + + ..\..\..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll + diff --git a/Plugins/Statistics/GitImpact/ImpactControl.cs b/Plugins/Statistics/GitImpact/ImpactControl.cs index a3542b2f000..a7c06ee4e54 100644 --- a/Plugins/Statistics/GitImpact/ImpactControl.cs +++ b/Plugins/Statistics/GitImpact/ImpactControl.cs @@ -38,10 +38,10 @@ public class ImpactControl : UserControl private Dictionary _brushes; // The changed-lines-labels for each author - private Dictionary>> _lineLabels; + private Dictionary> _lineLabels; // The week-labels - private List> _weekLabels; + private List<(PointF point, DateTime date)> _weekLabels; private HScrollBar _scrollBar; @@ -79,8 +79,8 @@ private void Clear() _authorStack = new List(); _paths = new Dictionary(); _brushes = new Dictionary(); - _lineLabels = new Dictionary>>(); - _weekLabels = new List>(); + _lineLabels = new Dictionary>(); + _weekLabels = new List<(PointF, DateTime)>(); } } @@ -305,11 +305,11 @@ private void DrawWeekLabels(Graphics g) { Brush brush = Brushes.Gray; - foreach (var (point, size) in _weekLabels) + foreach (var (point, date) in _weekLabels) { - SizeF sz = g.MeasureString(size.ToString("dd. MMM yy"), font); + SizeF sz = g.MeasureString(date.ToString("dd. MMM yy"), font); PointF pt = new PointF(point.X - (sz.Width / 2), point.Y + (sz.Height / 2)); - g.DrawString(size.ToString("dd. MMM yy"), font, brush, pt); + g.DrawString(date.ToString("dd. MMM yy"), font, brush, pt); } } } @@ -326,7 +326,7 @@ private void UpdatePathsAndLabels() { int h_max = 0; int x = 0; - var author_points_dict = new Dictionary>>(); + var author_points_dict = new Dictionary>(); lock (_dataLock) { @@ -348,10 +348,10 @@ private void UpdatePathsAndLabels() // Add rectangle to temporary list if (!author_points_dict.ContainsKey(author)) { - author_points_dict.Add(author, new List>()); + author_points_dict.Add(author, new List<(Rectangle, int)>()); } - author_points_dict[author].Add(Tuple.Create(rc, data.ChangedLines)); + author_points_dict[author].Add((rc, data.ChangedLines)); // Create a new random brush for the author if none exists yet if (!_brushes.ContainsKey(author)) @@ -368,7 +368,7 @@ private void UpdatePathsAndLabels() h_max = Math.Max(h_max, y); // Add week date label - _weekLabels.Add(Tuple.Create(new PointF(x + (BlockWidth / 2), y), weekDate)); + _weekLabels.Add((new PointF(x + (BlockWidth / 2), y), weekDate)); // Increase x for next week x += BlockWidth + TransitionWidth; @@ -382,9 +382,9 @@ private void UpdatePathsAndLabels() { var (point, date) = _weekLabels[i]; - _weekLabels[i] = Tuple.Create( - new PointF(point.X, point.Y * (float)height_factor), - date); + var adjustedPoint = new PointF(point.X, point.Y * (float)height_factor); + + _weekLabels[i] = (adjustedPoint, date); } // Clear previous paths @@ -404,20 +404,19 @@ private void UpdatePathsAndLabels() var rect = new Rectangle(unscaledRect.Left, (int)(unscaledRect.Top * height_factor), unscaledRect.Width, Math.Max(1, (int)(unscaledRect.Height * height_factor))); - points[i] = Tuple.Create(rect, num); + points[i] = (rect, num); // Add lines-changed-labels if (!_lineLabels.ContainsKey(author)) { - _lineLabels.Add(author, new List>()); + _lineLabels.Add(author, new List<(PointF, int)>()); } if (rect.Height > LinesFontSize * 1.5) { - _lineLabels[author].Add( - Tuple.Create( - new PointF(rect.Left + (BlockWidth / 2), rect.Top + (rect.Height / 2)), - num)); + var adjustedPoint = new PointF(rect.Left + (BlockWidth / 2), rect.Top + (rect.Height / 2)); + + _lineLabels[author].Add((adjustedPoint, num)); } } diff --git a/Plugins/Statistics/GitImpact/packages.config b/Plugins/Statistics/GitImpact/packages.config index 16a63cd8a78..587c43a840a 100644 --- a/Plugins/Statistics/GitImpact/packages.config +++ b/Plugins/Statistics/GitImpact/packages.config @@ -4,4 +4,5 @@ + \ No newline at end of file diff --git a/Plugins/Statistics/GitStatistics/FormGitStatistics.cs b/Plugins/Statistics/GitStatistics/FormGitStatistics.cs index b2635b8e020..e608540398a 100644 --- a/Plugins/Statistics/GitStatistics/FormGitStatistics.cs +++ b/Plugins/Statistics/GitStatistics/FormGitStatistics.cs @@ -4,7 +4,6 @@ using System.IO; using System.Linq; using System.Text; -using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using GitCommands; diff --git a/Plugins/Statistics/GitStatistics/GitStatistics.csproj b/Plugins/Statistics/GitStatistics/GitStatistics.csproj index 00eb9d6b4ab..3abaed80a8e 100644 --- a/Plugins/Statistics/GitStatistics/GitStatistics.csproj +++ b/Plugins/Statistics/GitStatistics/GitStatistics.csproj @@ -68,6 +68,9 @@ + + ..\..\..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll + diff --git a/Plugins/Statistics/GitStatistics/packages.config b/Plugins/Statistics/GitStatistics/packages.config index 16a63cd8a78..587c43a840a 100644 --- a/Plugins/Statistics/GitStatistics/packages.config +++ b/Plugins/Statistics/GitStatistics/packages.config @@ -4,4 +4,5 @@ + \ No newline at end of file diff --git a/ResourceManager/GitExtensionsFormBase.cs b/ResourceManager/GitExtensionsFormBase.cs index 3db0b378e03..9b832ffb786 100644 --- a/ResourceManager/GitExtensionsFormBase.cs +++ b/ResourceManager/GitExtensionsFormBase.cs @@ -130,7 +130,7 @@ protected void TranslateItem(string itemName, object item) return; } - var itemsToTranslate = new[] { Tuple.Create(itemName, item) }; + var itemsToTranslate = new[] { (itemName, item) }; foreach (var pair in translation) { diff --git a/ResourceManager/GitExtensionsUserControl.cs b/ResourceManager/GitExtensionsUserControl.cs index 889abc1cfa6..cc2acfea84d 100644 --- a/ResourceManager/GitExtensionsUserControl.cs +++ b/ResourceManager/GitExtensionsUserControl.cs @@ -106,7 +106,7 @@ protected void TranslateItem(string itemName, object item) return; } - var itemsToTranslate = new[] { Tuple.Create(itemName, item) }; + var itemsToTranslate = new[] { (itemName, item) }; foreach (var pair in translation) { diff --git a/ResourceManager/ResourceManager.csproj b/ResourceManager/ResourceManager.csproj index 8d61d52a516..bcf6216d6e4 100644 --- a/ResourceManager/ResourceManager.csproj +++ b/ResourceManager/ResourceManager.csproj @@ -78,6 +78,9 @@ 3.5 + + ..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll + diff --git a/ResourceManager/TranslationUtils.cs b/ResourceManager/TranslationUtils.cs index 3a9c8c94c8e..9501bb6ee87 100644 --- a/ResourceManager/TranslationUtils.cs +++ b/ResourceManager/TranslationUtils.cs @@ -1,11 +1,10 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; namespace ResourceManager { public static class TranslationUtils { - public static IEnumerable> GetObjFields(object obj, string objName) + public static IEnumerable<(string name, object item)> GetObjFields(object obj, string objName) { return Xliff.TranslationUtl.GetObjFields(obj, objName); } @@ -23,7 +22,7 @@ public static void AddTranslationItemsFromFields(string category, object obj, IT } } - public static void AddTranslationItemsFromList(string category, ITranslation translation, IEnumerable> items) + public static void AddTranslationItemsFromList(string category, ITranslation translation, IEnumerable<(string name, object item)> items) { Xliff.TranslationUtl.AddTranslationItemsFromList(category, translation, items); } @@ -33,7 +32,7 @@ public static void TranslateProperty(string category, object obj, string propert Xliff.TranslationUtl.TranslateProperty(category, obj, property, translation); } - public static void TranslateItemsFromList(string category, ITranslation translation, IEnumerable> items) + public static void TranslateItemsFromList(string category, ITranslation translation, IEnumerable<(string name, object item)> items) { Xliff.TranslationUtl.TranslateItemsFromList(category, translation, items); } diff --git a/ResourceManager/Xliff/TranslationUtl.cs b/ResourceManager/Xliff/TranslationUtl.cs index 7f89e4e772e..20f510c3d2c 100644 --- a/ResourceManager/Xliff/TranslationUtl.cs +++ b/ResourceManager/Xliff/TranslationUtl.cs @@ -20,11 +20,11 @@ private static bool AllowTranslateProperty(string text) return text.Any(char.IsLetter); } - public static IEnumerable> GetObjFields(object obj, string objName) + public static IEnumerable<(string name, object item)> GetObjFields(object obj, string objName) { if (objName != null) { - yield return Tuple.Create(objName, obj); + yield return (objName, obj); } foreach (FieldInfo fieldInfo in obj.GetType().GetFields( @@ -37,7 +37,7 @@ public static IEnumerable> GetObjFields(object obj, string continue; } - yield return Tuple.Create(fieldInfo.Name, fieldInfo.GetValue(obj)); + yield return (fieldInfo.Name, fieldInfo.GetValue(obj)); } } @@ -64,39 +64,37 @@ public static void AddTranslationItemsFromFields(string category, object obj, IT AddTranslationItemsFromList(category, translation, GetObjFields(obj, "$this")); } - private static IEnumerable GetItemPropertiesEnumerator(Tuple item) + private static IEnumerable GetItemPropertiesEnumerator(string name, object item) { - var (itemName, itemObj) = item; - - if (itemObj == null) + if (item == null) { yield break; } // Skip controls with a name started with "_NO_TRANSLATE_" // this is a naming convention, these are not translated - if (itemName.StartsWith("_NO_TRANSLATE_")) + if (name.StartsWith("_NO_TRANSLATE_")) { yield break; } Func isTranslatableItem; - if (itemObj is DataGridViewColumn) + if (item is DataGridViewColumn) { - var c = itemObj as DataGridViewColumn; + var c = item as DataGridViewColumn; isTranslatableItem = propertyInfo => IsTranslatableItemInDataGridViewColumn(propertyInfo, c); } - else if (itemObj is ComboBox || itemObj is ListBox) + else if (item is ComboBox || item is ListBox) { - isTranslatableItem = propertyInfo => IsTranslatableItemInBox(propertyInfo, itemObj); + isTranslatableItem = propertyInfo => IsTranslatableItemInBox(propertyInfo, item); } else { isTranslatableItem = IsTranslatableItemInComponent; } - foreach (var propertyInfo in itemObj.GetType() + foreach (var propertyInfo in item.GetType() .GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.SetProperty) .Where(isTranslatableItem)) @@ -105,15 +103,14 @@ private static IEnumerable GetItemPropertiesEnumerator(Tuple> items) + public static void AddTranslationItemsFromList(string category, ITranslation translation, IEnumerable<(string name, object item)> items) { - foreach (var item in items) + foreach (var (itemName, itemObj) in items) { - var (itemName, itemObj) = item; - - foreach (var property in GetItemPropertiesEnumerator(item)) + foreach (var property in GetItemPropertiesEnumerator(itemName, itemObj)) { var value = property.GetValue(itemObj, null); + if (value == null) { continue; @@ -145,13 +142,11 @@ public static void AddTranslationItemsFromList(string category, ITranslation tra } } - public static void TranslateItemsFromList(string category, ITranslation translation, IEnumerable> items) + public static void TranslateItemsFromList(string category, ITranslation translation, IEnumerable<(string name, object item)> items) { - foreach (var item in items) + foreach (var (itemName, itemObj) in items) { - var (itemName, itemObj) = item; - - foreach (var propertyInfo in GetItemPropertiesEnumerator(item)) + foreach (var propertyInfo in GetItemPropertiesEnumerator(itemName, itemObj)) { var property = propertyInfo; // copy for lambda string propertyName = property.Name; diff --git a/ResourceManager/packages.config b/ResourceManager/packages.config index c1d702be371..9c526024645 100644 --- a/ResourceManager/packages.config +++ b/ResourceManager/packages.config @@ -6,4 +6,5 @@ + \ No newline at end of file diff --git a/UnitTests/GitCommandsTests/Git/GitCommandHelpersTest.cs b/UnitTests/GitCommandsTests/Git/GitCommandHelpersTest.cs index 48109061009..8ab773b26e1 100644 --- a/UnitTests/GitCommandsTests/Git/GitCommandHelpersTest.cs +++ b/UnitTests/GitCommandsTests/Git/GitCommandHelpersTest.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using GitCommands; using NUnit.Framework; using ResourceManager;