diff --git a/PowerShellGitHubDev.psm1 b/PowerShellGitHubDev.psm1
index 1b6605fcd1..02fbfb3e5c 100644
--- a/PowerShellGitHubDev.psm1
+++ b/PowerShellGitHubDev.psm1
@@ -506,6 +506,26 @@ function Send-GitDiffToSd {
}
}
+function Start-ResGen
+{
+ @("Microsoft.PowerShell.Commands.Management",
+"Microsoft.PowerShell.Commands.Utility",
+"Microsoft.PowerShell.ConsoleHost",
+"Microsoft.PowerShell.CoreCLR.Eventing",
+"Microsoft.PowerShell.Security",
+"System.Management.Automation") | % {
+ $module = $_
+ ls "$PSScriptRoot/src/$module/resources" | % {
+ $className = $_.Name.Replace('.resx', '')
+ $xml = [xml](cat -raw $_.FullName)
+ $genSource = Get-StronglyTypeCsFileForResx -xml $xml -ModuleName $module -ClassName $className
+ $outPath = "$PSScriptRoot/src/windows-build/gen/$module/$className.cs"
+ log "ResGen for $outPath"
+ Set-Content -Encoding Ascii -Path "$PSScriptRoot/src/windows-build/gen/$module/$className.cs" -Value $genSource
+ }
+ }
+}
+
function script:log([string]$message) {
Write-Host -Foreground Green $message
@@ -570,3 +590,91 @@ function script:Convert-PSObjectToHashtable {
}
}
}
+
+
+function script:Get-StronglyTypeCsFileForResx
+{
+ param($xml, $ModuleName, $ClassName)
+$body = @'
+//------------------------------------------------------------------------------
+//
+// This code was generated by a Start-ResGen funciton from PowerShellGitHubDev.psm1.
+// To add or remove a member, edit your .ResX file then rerun Start-ResGen.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+using System;
+using System.Reflection;
+
+///
+/// A strongly-typed resource class, for looking up localized strings, etc.
+///
+[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+
+internal class {0} {{
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal {0}() {{
+ }}
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {{
+ get {{
+ if (object.ReferenceEquals(resourceMan, null)) {{
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("{1}.resources.{0}", typeof({0}).GetTypeInfo().Assembly);
+ resourceMan = temp;
+ }}
+ return resourceMan;
+ }}
+ }}
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {{
+ get {{
+ return resourceCulture;
+ }}
+ set {{
+ resourceCulture = value;
+ }}
+ }}
+ {2}
+}}
+'@
+
+ $entry = @'
+
+ ///
+ /// Looks up a localized string similar to {1}
+ ///
+ internal static string {0} {{
+ get {{
+ return ResourceManager.GetString("{0}", resourceCulture);
+ }}
+ }}
+'@
+ $entries = $xml.root.data | % {
+ if ($_) {
+ $val = $_.value.Replace("`n", "`n ///")
+ $name = $_.name.Replace(' ', '_')
+ $entry -f $name,$val
+ }
+ } | Out-String
+ $body -f $ClassName,$ModuleName,$entries
+}
+
diff --git a/mapping.json b/mapping.json
index 2f4ed00680..b6a47c2c86 100644
--- a/mapping.json
+++ b/mapping.json
@@ -1137,10 +1137,10 @@
"src/monad/monad/src/engine/resources/Logging.resx": "src/System.Management.Automation/resources/Logging.resx",
"src/monad/monad/src/engine/resources/Metadata.resx": "src/System.Management.Automation/resources/Metadata.resx",
"src/monad/monad/src/engine/resources/MiniShellErrors.resx": "src/System.Management.Automation/resources/MiniShellErrors.resx",
- "src/monad/monad/src/engine/resources/modules.resx": "src/System.Management.Automation/resources/modules.resx",
+ "src/monad/monad/src/engine/resources/modules.resx": "src/System.Management.Automation/resources/Modules.resx",
"src/monad/monad/src/engine/resources/MshHostRawUserInterfaceStrings.resx": "src/System.Management.Automation/resources/MshHostRawUserInterfaceStrings.resx",
"src/monad/monad/src/engine/resources/MshSignature.resx": "src/System.Management.Automation/resources/MshSignature.resx",
- "src/monad/monad/src/engine/resources/MshSnapinCmdletResources.resx": "src/System.Management.Automation/resources/MshSnapinCmdletResources.resx",
+ "src/monad/monad/src/engine/resources/MshSnapinCmdletResources.resx": "src/System.Management.Automation/resources/MshSnapInCmdletResources.resx",
"src/monad/monad/src/engine/resources/MshSnapinInfo.resx": "src/System.Management.Automation/resources/MshSnapinInfo.resx",
"src/monad/monad/src/engine/resources/NativeCP.resx": "src/System.Management.Automation/resources/NativeCP.resx",
"src/monad/monad/src/engine/resources/ParameterBinderStrings.resx": "src/System.Management.Automation/resources/ParameterBinderStrings.resx",
@@ -1155,7 +1155,7 @@
"src/monad/monad/src/engine/resources/PSDataBufferStrings.resx": "src/System.Management.Automation/resources/PSDataBufferStrings.resx",
"src/monad/monad/src/engine/resources/PSListModifierStrings.resx": "src/System.Management.Automation/resources/PSListModifierStrings.resx",
"src/monad/monad/src/engine/resources/RegistryProviderStrings.resx": "src/System.Management.Automation/resources/RegistryProviderStrings.resx",
- "src/monad/monad/src/engine/resources/remotingerroridstrings.resx": "src/System.Management.Automation/resources/remotingerroridstrings.resx",
+ "src/monad/monad/src/engine/resources/remotingerroridstrings.resx": "src/System.Management.Automation/resources/RemotingErrorIdStrings.resx",
"src/monad/monad/src/engine/resources/RunspaceInit.resx": "src/System.Management.Automation/resources/RunspaceInit.resx",
"src/monad/monad/src/engine/resources/RunspacePoolStrings.resx": "src/System.Management.Automation/resources/RunspacePoolStrings.resx",
"src/monad/monad/src/engine/resources/RunspaceStrings.resx": "src/System.Management.Automation/resources/RunspaceStrings.resx",
diff --git a/src/Microsoft.PowerShell.Commands.Management/project.json b/src/Microsoft.PowerShell.Commands.Management/project.json
index 7e20c7dbe2..c2b5201acd 100644
--- a/src/Microsoft.PowerShell.Commands.Management/project.json
+++ b/src/Microsoft.PowerShell.Commands.Management/project.json
@@ -36,5 +36,5 @@
}
},
- "compile": [ "../windows-build/gen/COMMANDS_MANAGEMENT/*.cs" ]
+ "compile": [ "../windows-build/gen/Microsoft.PowerShell.Commands.Management/*.cs" ]
}
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs
index 59107f1a8d..d24ce82ecc 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs
@@ -2507,21 +2507,25 @@ function Get-PSImplicitRemotingSession
// index 0 - "-VMId " (VMId is used instead of VMName due to its uniqueness)
// index 1 - VM credential
+ // index 2 - "-ConfigurationName " or empty string
private const string NewVMRunspaceTemplate = @"
$(
& $script:NewPSSession `
{0} `
{1} `
+ {2} `
)
";
// index 0 - "-ContainerId " (ContainerId is used instead of ContainerName due to its uniqueness)
// index 1 - "-RunAsAdministrator" or empty string
+ // index 2 - "-ConfigurationName " or empty string
private const string NewContainerRunspaceTemplate = @"
$(
& $script:NewPSSession `
{0} `
{1} `
+ {2} `
)
";
@@ -2530,22 +2534,26 @@ function Get-PSImplicitRemotingSession
VMConnectionInfo vmConnectionInfo = this.remoteRunspaceInfo.Runspace.ConnectionInfo as VMConnectionInfo;
if (vmConnectionInfo != null)
{
+ string vmConfigurationName = vmConnectionInfo.ConfigurationName;
return string.Format(
CultureInfo.InvariantCulture,
NewVMRunspaceTemplate,
/* 0 */ this.GenerateConnectionStringForNewRunspace(),
- /* 1 */ this.GenerateCredentialParameter());
+ /* 1 */ this.GenerateCredentialParameter(),
+ /* 2 */ String.IsNullOrEmpty(vmConfigurationName) ? String.Empty : String.Concat("-ConfigurationName ", vmConfigurationName));
}
else
{
ContainerConnectionInfo containerConnectionInfo = this.remoteRunspaceInfo.Runspace.ConnectionInfo as ContainerConnectionInfo;
if (containerConnectionInfo != null)
{
+ string containerConfigurationName = containerConnectionInfo.ContainerProc.ConfigurationName;
return string.Format(
CultureInfo.InvariantCulture,
NewContainerRunspaceTemplate,
/* 0 */ this.GenerateConnectionStringForNewRunspace(),
- /* 1 */ containerConnectionInfo.ContainerProc.RunAsAdmin ? "-RunAsAdministrator" : string.Empty);
+ /* 1 */ containerConnectionInfo.ContainerProc.RunAsAdmin ? "-RunAsAdministrator" : string.Empty,
+ /* 2 */ String.IsNullOrEmpty(containerConfigurationName) ? String.Empty : String.Concat("-ConfigurationName ", containerConfigurationName));
}
else
{
diff --git a/src/Microsoft.PowerShell.Commands.Utility/project.json b/src/Microsoft.PowerShell.Commands.Utility/project.json
index 4de41175b9..77e6525e14 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/project.json
+++ b/src/Microsoft.PowerShell.Commands.Utility/project.json
@@ -44,5 +44,5 @@
}
},
- "compile": [ "../windows-build/gen/COMMANDS_UTILITY/*.cs" ]
+ "compile": [ "../windows-build/gen/Microsoft.PowerShell.Commands.Utility/*.cs" ]
}
diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
index a96e11cc33..44e5801972 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
+++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
@@ -239,7 +239,7 @@ namespace Microsoft.PowerShell
else if (cpp.NamedPipeServerMode)
{
ClrFacade.StartProfileOptimization("StartupProfileData-NamedPipeServerMode");
- System.Management.Automation.Remoting.RemoteSessionNamedPipeServer.RunServerMode();
+ System.Management.Automation.Remoting.RemoteSessionNamedPipeServer.RunServerMode(cpp.ConfigurationName);
exitCode = 0;
}
else if (cpp.SocketServerMode)
diff --git a/src/Microsoft.PowerShell.ConsoleHost/project.json b/src/Microsoft.PowerShell.ConsoleHost/project.json
index 999371d722..76a1494a5d 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/project.json
+++ b/src/Microsoft.PowerShell.ConsoleHost/project.json
@@ -26,6 +26,6 @@
},
"compile": [
- "../windows-build/gen/CONSOLE_HOST/*.cs"
+ "../windows-build/gen/Microsoft.PowerShell.ConsoleHost/*.cs"
]
}
diff --git a/src/Microsoft.PowerShell.CoreCLR.Eventing/project.json b/src/Microsoft.PowerShell.CoreCLR.Eventing/project.json
index 8d2b9d3595..5948cbf144 100644
--- a/src/Microsoft.PowerShell.CoreCLR.Eventing/project.json
+++ b/src/Microsoft.PowerShell.CoreCLR.Eventing/project.json
@@ -31,5 +31,5 @@
}
},
- "compile": [ "../windows-build/gen/CORECLR_EVENTING/*.cs" ]
+ "compile": [ "../windows-build/gen/Microsoft.PowerShell.CoreCLR.Eventing/*.cs" ]
}
diff --git a/src/Microsoft.PowerShell.Security/project.json b/src/Microsoft.PowerShell.Security/project.json
index eac75ae00d..bf6fd2486b 100644
--- a/src/Microsoft.PowerShell.Security/project.json
+++ b/src/Microsoft.PowerShell.Security/project.json
@@ -23,5 +23,5 @@
}
},
- "compile": [ "../windows-build/gen/SECURITY/*.cs" ]
+ "compile": [ "../windows-build/gen/Microsoft.PowerShell.Security/*.cs" ]
}
diff --git a/src/System.Management.Automation/DscSupport/CimDSCParser.cs b/src/System.Management.Automation/DscSupport/CimDSCParser.cs
index b781215aed..84700b601d 100644
--- a/src/System.Management.Automation/DscSupport/CimDSCParser.cs
+++ b/src/System.Management.Automation/DscSupport/CimDSCParser.cs
@@ -999,6 +999,25 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal
return ClassCache.Values.ToList();
}
+ ///
+ /// Find cached cim classes defined under specified module
+ ///
+ ///
+ /// List of cached cim classes
+ public static List GetCachedClassesForModule(PSModuleInfo module)
+ {
+ List cachedClasses = new List();
+ var moduleQualifiedName = String.Format(CultureInfo.InvariantCulture, "{0}\\{1}", module.Name, module.Version.ToString());
+ foreach (var pair in ClassCache)
+ {
+ if(pair.Key.StartsWith(moduleQualifiedName, StringComparison.OrdinalIgnoreCase))
+ {
+ cachedClasses.Add(pair.Value.Item2);
+ }
+ }
+ return cachedClasses;
+ }
+
///
/// Get the file that defined this class.
///
@@ -1189,7 +1208,8 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal
if (!CacheResourcesFromMultipleModuleVersions && DynamicKeyword.ContainsKeyword(keyword.Keyword))
{
var oldKeyword = DynamicKeyword.GetKeyword(keyword.Keyword);
- if (!oldKeyword.ImplementingModule.Equals(moduleName, StringComparison.OrdinalIgnoreCase) || oldKeyword.ImplementingModuleVersion != moduleVersion)
+ if (oldKeyword.ImplementingModule == null ||
+ !oldKeyword.ImplementingModule.Equals(moduleName, StringComparison.OrdinalIgnoreCase) || oldKeyword.ImplementingModuleVersion != moduleVersion)
{
var e = PSTraceSource.NewInvalidOperationException(ParserStrings.DuplicateKeywordDefinition, keyword.Keyword);
e.SetErrorId("DuplicateKeywordDefinition");
@@ -2258,6 +2278,96 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal
sb.Append("};");
}
+ ///
+ /// Gets the line no for DSC Class Resource Get/Set/Test methods
+ ///
+ ///
+ ///
+ private static bool GetResourceMethodsLineNumber(TypeDefinitionAst typeDefinitionAst, out Dictionary methodsLinePosition)
+ {
+ const string getMethodName = "Get";
+ const string setMethodName = "Set";
+ const string testMethodName = "Test";
+
+ methodsLinePosition = new Dictionary(); ;
+ foreach (var member in typeDefinitionAst.Members)
+ {
+ var functionMemberAst = member as FunctionMemberAst;
+ if (functionMemberAst != null)
+ {
+ if (functionMemberAst.Name.Equals(getMethodName, StringComparison.OrdinalIgnoreCase))
+ {
+ methodsLinePosition[getMethodName] = functionMemberAst.NameExtent.StartLineNumber;
+ }
+ else if (functionMemberAst.Name.Equals(setMethodName, StringComparison.OrdinalIgnoreCase))
+ {
+ methodsLinePosition[setMethodName] = functionMemberAst.NameExtent.StartLineNumber;
+ }
+ else if (functionMemberAst.Name.Equals(testMethodName, StringComparison.OrdinalIgnoreCase))
+ {
+ methodsLinePosition[testMethodName] = functionMemberAst.NameExtent.StartLineNumber;
+ }
+ }
+ }
+
+ // All 3 methods (Get/Set/Test) position should be found.
+ return (methodsLinePosition.Count == 3);
+ }
+
+ ///
+ /// Gets the line no for DSC Class Resource Get/Set/Test methods
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static bool GetResourceMethodsLinePosition(PSModuleInfo moduleInfo, string resourceName, out Dictionary resourceMethodsLinePosition, out string resourceFilePath)
+ {
+ resourceMethodsLinePosition = null;
+ resourceFilePath = string.Empty;
+ if (moduleInfo == null || string.IsNullOrEmpty(resourceName))
+ {
+ return false;
+ }
+
+ IEnumerable resourceDefinitions;
+ List moduleFiles = new List();
+ if (moduleInfo.RootModule != null)
+ {
+ moduleFiles.Add(moduleInfo.Path);
+ }
+ if (moduleInfo.NestedModules != null)
+ {
+ foreach (var nestedModule in moduleInfo.NestedModules.Where(m => !string.IsNullOrEmpty(m.Path)))
+ {
+ moduleFiles.Add(nestedModule.Path);
+ }
+ }
+
+ foreach (string moduleFile in moduleFiles)
+ {
+ if (GetResourceDefinitionsFromModule(moduleFile, out resourceDefinitions, null, null))
+ {
+ foreach (var r in resourceDefinitions)
+ {
+ var resourceDefnAst = (TypeDefinitionAst)r;
+ if (!resourceName.Equals(resourceDefnAst.Name, StringComparison.OrdinalIgnoreCase))
+ {
+ continue;
+ }
+
+ if (GetResourceMethodsLineNumber(resourceDefnAst, out resourceMethodsLinePosition))
+ {
+ resourceFilePath = moduleFile;
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
private static void ProcessMembers(StringBuilder sb, List