Skip to content

Commit c580c81

Browse files
committed
Cleaned up .gitignore. Added logic to include Prerelease if it is set. Added validation for FunctionsToExport. Change @Class variables to targetClass.
1 parent a788659 commit c580c81

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

.gitignore

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,10 @@ groupMapping*.json
222222
*.wixpdb
223223

224224
.vscode/
225-
/tools/AutomationTestFramework/RunBooks
226-
/tools/AutomationTestFramework/TestHelpers/TestHelpers.zip
225+
/tools/AutomationTestFramework/Runbooks
227226
Results
228227
Package
229228
.DS_Store
230229
.idea
231-
/src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Logger/bin
232-
/src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/bin
233-
/src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/bin
234-
/src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Providers/bin
235-
/src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.ServiceClientAdapter/bin
236-
/tools/NetCorePsd1Sync/NetCorePsd1Sync/Properties/launchSettings.json
230+
/src/ResourceManager/RecoveryServices.Backup/**/bin
231+
launchSettings.json

tools/NetCorePsd1Sync/NetCorePsd1Sync/NetCoreDefinitionGenerator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ public static PsDefinition CreateNetCoreDefinition(Hashtable desktopData)
109109
Tags = desktopPsData.GetValueAsStringList("Tags"),
110110
LicenseUri = new Uri(desktopPsData.GetValueAsString("LicenseUri")),
111111
ProjectUri = new Uri(desktopPsData.GetValueAsString("ProjectUri")),
112-
ReleaseNotes = String.Empty
112+
ReleaseNotes = String.Empty,
113+
Prerelease = desktopPsData.ContainsKey("Prerelease") ? desktopPsData.GetValueAsString("Prerelease") : null
113114
};
114115
}
115116

tools/NetCorePsd1Sync/NetCorePsd1Sync/Program.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ private static void ValidateDefinitionFiles(string rmPath)
5757

5858
var oldCmdletList = desktopHashtable.GetValueAsStringList("CmdletsToExport");
5959
var oldAliasesList = desktopHashtable.GetValueAsStringList("AliasesToExport");
60-
if (!File.Exists(netCorePath) || !(oldCmdletList.Any() || oldAliasesList.Any()))
60+
var oldFunctionsList = desktopHashtable.GetValueAsStringList("FunctionsToExport");
61+
if (!File.Exists(netCorePath) || !(oldCmdletList.Any() || oldAliasesList.Any() || oldFunctionsList.Any()))
6162
{
6263
var priorColor = Console.ForegroundColor;
6364
Console.ForegroundColor = ConsoleColor.Yellow;
@@ -75,12 +76,14 @@ private static void ValidateDefinitionFiles(string rmPath)
7576

7677
var newCmdletList = netCoreHashtable.GetValueAsStringList("CmdletsToExport");
7778
var newAliasesList = netCoreHashtable.GetValueAsStringList("AliasesToExport");
79+
var newFunctionsList = netCoreHashtable.GetValueAsStringList("FunctionsToExport");
7880

7981
var missingCmdlets = oldCmdletList.Where(oc => !newCmdletList.Contains(oc)).ToList();
8082
var missingAliases = oldAliasesList.Where(oa => !newAliasesList.Contains(oa)).ToList();
83+
var missingFunctions = oldFunctionsList.Where(of => !newFunctionsList.Contains(of)).ToList();
8184

8285
// ReSharper disable once InvertIf
83-
if (missingCmdlets.Any() || missingAliases.Any())
86+
if (missingCmdlets.Any() || missingAliases.Any() || missingFunctions.Any())
8487
{
8588
var priorColor = Console.ForegroundColor;
8689
Console.ForegroundColor = ConsoleColor.Red;
@@ -92,6 +95,10 @@ private static void ValidateDefinitionFiles(string rmPath)
9295
{
9396
Console.WriteLine($"Missing aliases: {String.Join(", ", missingAliases)} : {netCoreFileName}");
9497
}
98+
if (missingFunctions.Any())
99+
{
100+
Console.WriteLine($"Missing functions: {String.Join(", ", missingFunctions)} : {netCoreFileName}");
101+
}
95102
Console.ForegroundColor = priorColor;
96103
Environment.ExitCode = 1;
97104
}

tools/NetCorePsd1Sync/NetCorePsd1Sync/Utility/StringExtensions.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,39 +32,39 @@ private static bool GetDescription<TClass, TProp>(Expression<Func<TClass, TProp>
3232
return hasDescription;
3333
}
3434

35-
private static (TProp value, string firstLeader) GetValue<TClass, TProp>(TClass @class, Expression<Func<TClass, TProp>> propertySelector)
35+
private static (TProp value, string firstLeader) GetValue<TClass, TProp>(TClass targetClass, Expression<Func<TClass, TProp>> propertySelector)
3636
{
37-
var value = propertySelector.Compile()(@class);
37+
var value = propertySelector.Compile()(targetClass);
3838
// https://stackoverflow.com/a/7580347/294804
3939
var firstLeader = value != null ? String.Empty : CommentPrefix;
4040
var hasDisplayName = TryGetPropertyAttributeValue<TClass, TProp, DisplayNameAttribute, string>(propertySelector, attr => attr.DisplayName, out var displayName);
4141
return (value, $"{firstLeader}{(hasDisplayName ? $"{displayName}{NameValueDelimiter}" : String.Empty)}");
4242
}
4343

4444
// https://blogs.msdn.microsoft.com/csharpfaq/2010/03/11/how-can-i-get-objects-and-property-values-from-expression-trees/
45-
public static IEnumerable<string> ToDefinitionEntry<TClass, TProp>(this TClass @class, Expression<Func<TClass, TProp>> propertySelector)
45+
public static IEnumerable<string> ToDefinitionEntry<TClass, TProp>(this TClass targetClass, Expression<Func<TClass, TProp>> propertySelector)
4646
{
4747
if (GetDescription(propertySelector, out var description)) yield return description;
48-
(var value, var firstLeader) = GetValue(@class, propertySelector);
48+
(var value, var firstLeader) = GetValue(targetClass, propertySelector);
4949
yield return $"{firstLeader}{CreateValue(value, ElementPrefix, ElementPostfix)}";
5050
yield return String.Empty;
5151
}
5252

5353
private static string CreateValue<TProp>(TProp value, string valuePrefix, string valuePostfix) =>
5454
$"{valuePrefix}{(value == null ? String.Empty : value.ToString())}{valuePostfix}";
5555

56-
public static IEnumerable<string> ToDefinitionEntry<TClass>(this TClass @class, Expression<Func<TClass, bool?>> propertySelector)
56+
public static IEnumerable<string> ToDefinitionEntry<TClass>(this TClass targetClass, Expression<Func<TClass, bool?>> propertySelector)
5757
{
5858
if (GetDescription(propertySelector, out var description)) yield return description;
59-
(var value, var firstLeader) = GetValue(@class, propertySelector);
59+
(var value, var firstLeader) = GetValue(targetClass, propertySelector);
6060
var boolValue = value != null && value.Value;
6161
yield return $"{firstLeader}{(boolValue ? "$true" : "$false")}";
6262
yield return String.Empty;
6363
}
6464

65-
public static IEnumerable<string> ToDefinitionEntry<TClass>(this TClass @class, Expression<Func<TClass, PsDefinitionHeader>> propertySelector)
65+
public static IEnumerable<string> ToDefinitionEntry<TClass>(this TClass targetClass, Expression<Func<TClass, PsDefinitionHeader>> propertySelector)
6666
{
67-
(var header, var _) = GetValue(@class, propertySelector);
67+
(var header, var _) = GetValue(targetClass, propertySelector);
6868
if (header == null) yield break;
6969

7070
foreach (var headerLine in header.ToDefinitionEntry())
@@ -88,10 +88,10 @@ public static IEnumerable<string> ToDefinitionEntry(this PsDefinition psDefiniti
8888
yield return String.Empty;
8989
}
9090

91-
public static IEnumerable<string> ToDefinitionEntry<TClass, TList>(this TClass @class, Expression<Func<TClass, List<TList>>> propertySelector)
91+
public static IEnumerable<string> ToDefinitionEntry<TClass, TList>(this TClass targetClass, Expression<Func<TClass, List<TList>>> propertySelector)
9292
{
9393
if (GetDescription(propertySelector, out var description)) yield return description;
94-
(var values, var firstLeader) = GetValue(@class, propertySelector);
94+
(var values, var firstLeader) = GetValue(targetClass, propertySelector);
9595

9696
var isStringList = typeof(TList) == typeof(string);
9797
var listPrefix = isStringList ? String.Empty : ObjectListPrefix;

0 commit comments

Comments
 (0)