Skip to content

Commit 4ada935

Browse files
FormatPs1XmlGenerator upgraded to .Net Standard
1 parent 9f6a5f9 commit 4ada935

29 files changed

+305
-538
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
2+
<Import Project="$(MSBuildThisFileDirectory)..\..\..\Repo.props" />
3+
<Import Project="$(RepoTools)Common.Netcore.Dependencies.targets" />
4+
<PropertyGroup>
5+
<TargetFramework>netstandard2.0</TargetFramework>
6+
<AssemblyName>CmdletsForTest</AssemblyName>
7+
<RootNamespace>CmdletsForTest</RootNamespace>
8+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
9+
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
10+
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
11+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
12+
<WarningsAsErrors />
13+
<IsPackable>false</IsPackable>
14+
<DelaySign>false</DelaySign>
15+
</PropertyGroup>
16+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
17+
<DefineConstants>TRACE;DEBUG;NETSTANDARD</DefineConstants>
18+
</PropertyGroup>
19+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
20+
<DefineConstants>TRACE;RELEASE;NETSTANDARD</DefineConstants>
21+
</PropertyGroup>
22+
<ItemGroup>
23+
<None Update="Dummy.psd1">
24+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
25+
</None>
26+
</ItemGroup>
27+
</Project>

tools/RepoTasks/RepoTasks.Cmdlets.Tests/Dummy.psd1 renamed to tools/FormatPs1XmlGenerator/CmdletsForTest/Dummy.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ RequiredModules = @()
5555
#FormatsToProcess = ''
5656

5757
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
58-
NestedModules = @('.\RepoTasks.CmdletsForTest.dll')
58+
NestedModules = @('.\CmdletsForTest.dll')
5959

6060
# Functions to export from this module
6161
# FunctionsToExport = @()

tools/RepoTasks/RepoTasks.CmdletsForTest/Models/PsDummyOutput1.cs renamed to tools/FormatPs1XmlGenerator/CmdletsForTest/Models/PsDummyOutput1.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
// limitations under the License.
1212
// ----------------------------------------------------------------------------------
1313

14-
15-
namespace RepoTasks.CmdletsForTest.Models
14+
namespace CmdletsForTest.Models
1615
{
1716
using Microsoft.WindowsAzure.Commands.Common.Attributes;
1817

tools/RepoTasks/RepoTasks.CmdletsForTest/Models/PsDummyOutput2.cs renamed to tools/FormatPs1XmlGenerator/CmdletsForTest/Models/PsDummyOutput2.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// ----------------------------------------------------------------------------------
1313

1414

15-
namespace RepoTasks.CmdletsForTest.Models
15+
namespace CmdletsForTest.Models
1616
{
1717
using Microsoft.WindowsAzure.Commands.Common.Attributes;
1818

tools/RepoTasks/RepoTasks.CmdletsForTest/Models/PsDummyOutputTwo.cs renamed to tools/FormatPs1XmlGenerator/CmdletsForTest/Models/PsDummyOutputTwo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// limitations under the License.
1212
// ----------------------------------------------------------------------------------
1313

14-
namespace RepoTasks.CmdletsForTest.Models
14+
namespace CmdletsForTest.Models
1515
{
1616
public class PsDummyOutputTwo
1717
{

tools/RepoTasks/RepoTasks.CmdletsForTest/Models/PsOperation.cs renamed to tools/FormatPs1XmlGenerator/CmdletsForTest/Models/PsOperation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
using Microsoft.WindowsAzure.Commands.Common.Attributes;
1515

16-
namespace RepoTasks.CmdletsForTest.Models
16+
namespace CmdletsForTest.Models
1717
{
1818
using System.Net;
1919
public class PsOperation

tools/RepoTasks/RepoTasks.CmdletsForTest/TestDummyCommand.cs renamed to tools/FormatPs1XmlGenerator/CmdletsForTest/TestDummyCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// ----------------------------------------------------------------------------------
1313

1414

15-
namespace RepoTasks.CmdletsForTest
15+
namespace CmdletsForTest
1616
{
1717
using Models;
1818
using System;

tools/RepoTasks/RepoTasks.CmdletsForTest/TestDummyCommand1.cs renamed to tools/FormatPs1XmlGenerator/CmdletsForTest/TestDummyCommand1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// limitations under the License.
1212
// ----------------------------------------------------------------------------------
1313

14-
namespace RepoTasks.CmdletsForTest
14+
namespace CmdletsForTest
1515
{
1616
using System.Management.Automation;
1717
using Models;

tools/RepoTasks/RepoTasks.RemoteWorker/IReflectionWorker.cs renamed to tools/FormatPs1XmlGenerator/FormatPs1XmlGenerator.Test/Constants.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@
1111
// limitations under the License.
1212
// ----------------------------------------------------------------------------------
1313

14-
using System;
15-
using System.Collections.Generic;
16-
17-
namespace RepoTasks.RemoteWorker
14+
namespace FormatPs1XmlGenerator.Test
1815
{
19-
public interface IReflectionWorker
16+
internal class Category
2017
{
21-
Tuple<string, List<string>> BuildFormatPs1Xml(string assemblyPath, string[] cmdlet, bool onlyMarkedProperties);
22-
void Serialize(string filepath);
18+
public const string AcceptanceType = "AcceptanceType";
19+
public const string CheckIn = "CheckIn";
2320
}
2421
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<Import Project="$(MSBuildThisFileDirectory)..\..\Common.Netcore.Dependencies.Test.targets" />
3+
4+
<PropertyGroup>
5+
<TargetFramework>netcoreapp2.1</TargetFramework>
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<ProjectReference Include="..\CmdletsForTest\CmdletsForTest.csproj" />
11+
<ProjectReference Include="..\FormatPs1XmlGenerator\FormatPs1XmlGenerator.csproj" />
12+
</ItemGroup>
13+
14+
</Project>

tools/RepoTasks/RepoTasks.Cmdlets.Tests/NewFormatPs1XmlCommandShould.cs renamed to tools/FormatPs1XmlGenerator/FormatPs1XmlGenerator.Test/NewFormatPs1XmlCommandShould.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// limitations under the License.
1212
// ----------------------------------------------------------------------------------
1313

14-
namespace RepoTasks.Cmdlets.Tests
14+
namespace FormatPs1XmlGenerator.Test
1515
{
1616
using System;
1717
using System.Linq;
@@ -21,12 +21,11 @@ namespace RepoTasks.Cmdlets.Tests
2121
using System.IO;
2222
using System.Collections.Generic;
2323
using System.Xml.Linq;
24-
using RemoteWorker;
2524

2625
public class NewFormatPs1XmlCommandShould
2726
{
2827
private const string CmdletName = "New-FormatPs1Xml";
29-
private const string ExpectedAssemblyName = "RepoTasks.CmdletsForTest";
28+
private const string ExpectedAssemblyName = "CmdletsForTest";
3029

3130
[Fact]
3231
[Trait(Category.AcceptanceType, Category.CheckIn)]

tools/RepoTasks/RepoTasks.Cmdlets.Tests/AppDomainWorkerShould.cs renamed to tools/FormatPs1XmlGenerator/FormatPs1XmlGenerator.Test/ReflectorShould.cs

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,17 @@
1111
// limitations under the License.
1212
// ----------------------------------------------------------------------------------
1313

14-
namespace RepoTasks.Cmdlets.Tests
15-
{
16-
using CmdletsForTest;
17-
using System;
18-
using System.Collections.Generic;
19-
using RemoteWorker;
20-
using Xunit;
21-
using System.IO;
14+
using CmdletsForTest;
15+
using System;
16+
using System.Collections.Generic;
17+
using Xunit;
18+
using System.IO;
2219

23-
public class AppDomainWorkerShould : IDisposable
20+
namespace FormatPs1XmlGenerator.Test
21+
{
22+
public class ReflectorShould
2423
{
25-
private readonly AppDomain _domain;
26-
private readonly IReflectionWorker _reflectionWorker;
27-
private const string ExpectedAssemblyName = "RepoTasks.CmdletsForTest";
28-
29-
// Setup
30-
public AppDomainWorkerShould()
31-
{
32-
var setup = new AppDomainSetup
33-
{
34-
ApplicationBase = AppDomain.CurrentDomain.BaseDirectory,
35-
};
36-
37-
_domain = AppDomain.CreateDomain("AppDomainIsolation: " + Guid.NewGuid(), null, setup);
38-
var type = typeof(AppDomainWorker);
39-
Assert.NotNull(type.FullName);
40-
41-
_reflectionWorker = (IReflectionWorker)_domain.CreateInstanceFromAndUnwrap(type.Assembly.Location, type.FullName);
42-
}
43-
44-
// TearDown
45-
public void Dispose()
46-
{
47-
if (_domain != null) AppDomain.Unload(_domain);
48-
}
24+
private const string ExpectedAssemblyName = "CmdletsForTest";
4925

5026
[Fact]
5127
[Trait(Category.AcceptanceType, Category.CheckIn)]
@@ -76,8 +52,7 @@ public void BuildConfiguration()
7652
{
7753
var cmdlets = new[] { "Test-Dummy" };
7854
var types = ReturnCmdletTypesAndAssemblyName(cmdlets);
79-
var warnings = new List<string>();
80-
var conf = new AppDomainWorker().BuildXmlConfiguration(types, warnings);
55+
var conf = new Reflector().BuildXmlConfiguration(types);
8156
Assert.Equal(4, conf.ViewDefinitions.Views.Length);
8257

8358
var view0 = conf.ViewDefinitions.Views[0];
@@ -95,21 +70,20 @@ public void BuildConfiguration()
9570

9671
[Fact]
9772
[Trait(Category.AcceptanceType, Category.CheckIn)]
98-
public void DoWorkRemotelyAndReturnFilname()
73+
public void ReturnFilname()
9974
{
10075
var assemblyFileName = Path.GetFileName(typeof(TestDummyCommand).Assembly.Location);
10176
var assemblyPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, assemblyFileName);
10277
var cmdlets = new[] { "Test-Dummy" };
103-
var filename =_reflectionWorker.BuildFormatPs1Xml(assemblyPath, cmdlets, false).Item1;
78+
var filename = new Reflector().BuildFormatPs1Xml(assemblyPath, cmdlets, false);
10479
Assert.NotNull(filename);
10580
Assert.Equal($"{ExpectedAssemblyName}.generated.format.ps1xml", filename);
10681
}
10782

10883
private static IList<Type> ReturnCmdletTypesAndAssemblyName(string[] cmdlets)
10984
{
11085
var assemblyPath = typeof(TestDummyCommand).Assembly.Location;
111-
string assembyName;
112-
var types = AppDomainWorker.GetCmdletTypes(assemblyPath, cmdlets, out assembyName);
86+
var types = new Reflector().GetCmdletTypes(assemblyPath, cmdlets, out var assembyName);
11387
Assert.Equal($"{ExpectedAssemblyName}", assembyName);
11488
Assert.True(types.Count >= 1);
11589
Assert.Contains(types, t => t.FullName == $"{ExpectedAssemblyName}.TestDummyCommand");
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.28307.271
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FormatPs1XmlGenerator", "FormatPs1XmlGenerator\FormatPs1XmlGenerator.csproj", "{1C1B5100-90AD-4E19-B21A-13079CBE79ED}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CmdletsForTest", "CmdletsForTest\CmdletsForTest.csproj", "{B2B56D35-8E6A-4891-983C-B10005DB9B69}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormatPs1XmlGenerator.Test", "FormatPs1XmlGenerator.Test\FormatPs1XmlGenerator.Test.csproj", "{5A949496-0912-4E0B-8B82-3E467E531E87}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Release|Any CPU = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{1C1B5100-90AD-4E19-B21A-13079CBE79ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{1C1B5100-90AD-4E19-B21A-13079CBE79ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{1C1B5100-90AD-4E19-B21A-13079CBE79ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{1C1B5100-90AD-4E19-B21A-13079CBE79ED}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{B2B56D35-8E6A-4891-983C-B10005DB9B69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{B2B56D35-8E6A-4891-983C-B10005DB9B69}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{B2B56D35-8E6A-4891-983C-B10005DB9B69}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{B2B56D35-8E6A-4891-983C-B10005DB9B69}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{5A949496-0912-4E0B-8B82-3E467E531E87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{5A949496-0912-4E0B-8B82-3E467E531E87}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{5A949496-0912-4E0B-8B82-3E467E531E87}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{5A949496-0912-4E0B-8B82-3E467E531E87}.Release|Any CPU.Build.0 = Release|Any CPU
30+
EndGlobalSection
31+
GlobalSection(SolutionProperties) = preSolution
32+
HideSolutionNode = FALSE
33+
EndGlobalSection
34+
GlobalSection(ExtensibilityGlobals) = postSolution
35+
SolutionGuid = {D000DAFE-481D-4DAB-8CD2-C5E0310208E1}
36+
EndGlobalSection
37+
EndGlobal
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
2+
<Import Project="$(MSBuildThisFileDirectory)..\..\..\Repo.props" />
3+
<Import Project="$(RepoTools)Common.Netcore.Dependencies.targets" />
4+
<PropertyGroup>
5+
<TargetFramework>netstandard2.0</TargetFramework>
6+
<AssemblyName>FormatPs1XmlGenerator</AssemblyName>
7+
<RootNamespace>FormatPs1XmlGenerator</RootNamespace>
8+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
9+
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
10+
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
11+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
12+
<WarningsAsErrors />
13+
<IsPackable>false</IsPackable>
14+
<DelaySign>false</DelaySign>
15+
</PropertyGroup>
16+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
17+
<DefineConstants>TRACE;DEBUG;NETSTANDARD</DefineConstants>
18+
</PropertyGroup>
19+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
20+
<DefineConstants>TRACE;RELEASE;NETSTANDARD</DefineConstants>
21+
</PropertyGroup>
22+
<ItemGroup>
23+
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
24+
</ItemGroup>
25+
<ItemGroup>
26+
<None Update="FormatPs1XmlGenerator.psd1">
27+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
28+
</None>
29+
</ItemGroup>
30+
</Project>
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
@{
2+
3+
# Script module or binary module file associated with this manifest.
4+
RootModule = ''
5+
6+
# Version number of this module.
7+
ModuleVersion = '0.0.1'
8+
9+
# ID used to uniquely identify this module
10+
GUID = 'E29254E7-76F8-470E-A8CB-F180EA25DF60'
11+
12+
# Author of this module
13+
Author = 'Microsoft Corporation'
14+
15+
# Company or vendor of this module
16+
CompanyName = 'Microsoft Corporation'
17+
18+
# Copyright statement for this module
19+
Copyright = 'Microsoft Corporation. All rights reserved.'
20+
21+
# Description of the functionality provided by this module
22+
Description = 'Generates format.ps1xml files for a provided module'
23+
24+
# Minimum version of the Windows PowerShell engine required by this module
25+
PowerShellVersion = '3.0'
26+
27+
# Name of the Windows PowerShell host required by this module
28+
# PowerShellHostName = ''
29+
30+
# Minimum version of the Windows PowerShell host required by this module
31+
# PowerShellHostVersion = ''
32+
33+
# Minimum version of Microsoft .NET Framework required by this module
34+
DotNetFrameworkVersion = '4.5.2'
35+
36+
# Minimum version of the common language runtime (CLR) required by this module
37+
CLRVersion = '4.0'
38+
39+
# Processor architecture (None, X86, Amd64) required by this module
40+
# ProcessorArchitecture = ''
41+
42+
# Modules that must be imported into the global environment prior to importing this module
43+
RequiredModules = @()
44+
45+
# Assemblies that must be loaded prior to importing this module
46+
# RequiredAssemblies = @()
47+
48+
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
49+
# ScriptsToProcess = @()
50+
51+
# Type files (.ps1xml) to be loaded when importing this module
52+
#TypesToProcess = 'Dummy.Types.ps1xml'
53+
54+
# Format files (.ps1xml) to be loaded when importing this module
55+
#FormatsToProcess = ''
56+
57+
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
58+
NestedModules = @('.\FormatPs1XmlGenerator.dll')
59+
60+
# Functions to export from this module
61+
# FunctionsToExport = @()
62+
63+
# Cmdlets to export from this module
64+
CmdletsToExport = '*'
65+
66+
# Variables to export from this module
67+
# VariablesToExport = @()
68+
69+
# Aliases to export from this module
70+
AliasesToExport = ''
71+
72+
# DSC resources to export from this module
73+
# DscResourcesToExport = @()
74+
75+
# List of all modules packaged with this module
76+
# ModuleList = @()
77+
78+
# List of all files packaged with this module
79+
# FileList = @()
80+
81+
# HelpInfo URI of this module
82+
# HelpInfoURI = ''
83+
84+
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
85+
# DefaultCommandPrefix = ''
86+
87+
}

0 commit comments

Comments
 (0)