Skip to content

Commit 6048cd6

Browse files
BernieWhitevors
authored andcommitted
.NET Core and xUnit cleanup for v0.9 (#332)
* Usings cleanup * Fix xunit warnings and cleanup * Expose internals to xunit tests * Remove nuget solution folder
1 parent c437f1d commit 6048cd6

35 files changed

+160
-237
lines changed

CONTRIBUTING.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Contributing to platyPS
2+
13
## Get the code
24

35
```
@@ -6,7 +8,7 @@ git clone https://github.com/PowerShell/platyPS
68

79
## Understand code layout
810

9-
There are two parts:
11+
There are two parts:
1012

1113
- `Markdown.MAML.dll`, a .NET library written in C#.
1214
It does the heavy lifting, like parsing Markdown, transforming it into XML, and so on.
@@ -19,7 +21,7 @@ There are two parts:
1921
To build the whole project, use the `build.ps1` helper script.
2022
It depends on the [dotnet cli](https://docs.microsoft.com/en-us/dotnet/core/tools/) build tool.
2123

22-
```
24+
```powershell
2325
.\build.ps1
2426
```
2527
As part of the build, platyPS generates help for itself.
@@ -48,9 +50,9 @@ If you have ideas or concerns about the Markdown schema, feel free to open a Git
4850

4951
## Repo structure
5052

51-
- **src\platyPS** - sources to create the final PowerShell module.
52-
- **src\Markdown.MAML, Markdown.MAML.sln** - source code for C# Markdown to MAML converter.
53-
- **[platyPS.schema.md](platyPS.schema.md)** - description of Markdown that platyPS expects.
53+
- **src\platyPS** - sources to create the final PowerShell module.
54+
- **src\Markdown.MAML, Markdown.MAML.sln** - source code for C# Markdown to MAML converter.
55+
- **[platyPS.schema.md](platyPS.schema.md)** - description of Markdown that platyPS expects.
5456

5557
## Data transformations
5658

@@ -92,11 +94,11 @@ This chart describes these simple transformations:
9294
+----------------------+ +---------------------------+
9395
```
9496

95-
##### Example `New-MarkdownHelp`
97+
### Example `New-MarkdownHelp`
9698

97-
A user creates a platyPS Markdown for the first time with `New-MarkdownHelp`:
99+
A user creates a platyPS Markdown for the first time with `New-MarkdownHelp`:
98100

99-
```
101+
```powershell
100102
New-MarkdownHelp -Command New-MyCommandHelp
101103
```
102104

Markdown.MAML.sln

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Markdown.MAML", "src\Markdo
1111
EndProject
1212
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Markdown.MAML.Test", "test\Markdown.MAML.Test\Markdown.MAML.Test.csproj", "{317CCB63-9AFA-4647-8838-DD8E20C8716F}"
1313
EndProject
14-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{E30960A6-764E-4E50-A337-F79F992C6F96}"
15-
ProjectSection(SolutionItems) = preProject
16-
.nuget\NuGet.Config = .nuget\NuGet.Config
17-
.nuget\NuGet.exe = .nuget\NuGet.exe
18-
.nuget\NuGet.targets = .nuget\NuGet.targets
19-
EndProjectSection
20-
EndProject
2114
Global
2215
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2316
Debug|Any CPU = Debug|Any CPU

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
# PlatyPS
77

8-
PlatyPS provides a way to
8+
PlatyPS provides a way to:
99

1010
* Write PowerShell External Help in Markdown
1111
* Generate markdown help ([example](docs/Update-MarkdownHelp.md)) for your existing modules
1212
* Keep markdown help up-to-date with your code
1313

14-
Markdown help docs can be generated from old external help files (also known as MAML-xml help), the command objects (reflection), or both.
14+
Markdown help docs can be generated from old external help files (also known as MAML-xml help), the command objects (reflection), or both.
1515

1616
PlatyPS can also generate cab files for [`Update-Help`](https://technet.microsoft.com/en-us/library/hh849720.aspx).
1717

@@ -25,7 +25,6 @@ An additional challange PlatyPS tackles, is to handle PowerShell documentation f
2525
Markdown is designed to be human-readable, without rendering. This makes writing and editing easy and efficient.
2626
Many editors support it ([Visual Studio Code](https://code.visualstudio.com/), [Sublime Text](http://www.sublimetext.com/), etc), and many tools and collaboration platforms (GitHub, Visual Studio Online) render the Markdown nicely.
2727

28-
2928
## Quick start
3029

3130
* Install platyPS module from the [PowerShell Gallery](https://powershellgallery.com):
@@ -100,4 +99,4 @@ Supported scenarios:
10099

101100
## Build
102101

103-
For information about building from sources and contributing see [contributing guidelines](CONTRIBUTING.md).
102+
For information about building from sources and contributing see [contributing guidelines](CONTRIBUTING.md).

src/Markdown.MAML/Markdown.MAML.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
32
<PropertyGroup>
43
<TargetFrameworks>netstandard1.6;net451</TargetFrameworks>
54
</PropertyGroup>
5+
<PropertyGroup>
6+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
7+
<WarningsAsErrors />
8+
</PropertyGroup>
69
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
710
<PackageReference Include="System.Collections.NonGeneric" Version="4.3.0" />
811
</ItemGroup>

src/Markdown.MAML/Model/MAML/MamlCodeBlock.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
7-
namespace Markdown.MAML.Model.MAML
1+
namespace Markdown.MAML.Model.MAML
82
{
93
/// <summary>
104
/// A section of code such as PowerShell commands or command output.

src/Markdown.MAML/Model/MAML/MamlExample.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
using Markdown.MAML.Model.Markdown;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
72

83
namespace Markdown.MAML.Model.MAML
94
{

src/Markdown.MAML/Model/MAML/MamlInputOutput.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
using Markdown.MAML.Model.Markdown;
22
using System;
3-
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
73

84
namespace Markdown.MAML.Model.MAML
95
{

src/Markdown.MAML/Model/MAML/MamlSyntax.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
1+
using System.Collections.Generic;
62

73
namespace Markdown.MAML.Model.MAML
84
{

src/Markdown.MAML/Model/Markdown/HyperlinkSpan.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Markdown.MAML.Parser;
2-
using System;
32

43
namespace Markdown.MAML.Model.Markdown
54
{

src/Markdown.MAML/Model/Markdown/MarkdownNodeType.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-

2-
namespace Markdown.MAML.Model.Markdown
1+
namespace Markdown.MAML.Model.Markdown
32
{
43
public enum MarkdownNodeType
54
{

src/Markdown.MAML/Model/Markdown/ParagraphSpan.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-

2-
using Markdown.MAML.Parser;
3-
using System.Text.RegularExpressions;
1+
using Markdown.MAML.Parser;
42

53
namespace Markdown.MAML.Model.Markdown
64
{

src/Markdown.MAML/Model/Markdown/SectionBody.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
7-
namespace Markdown.MAML.Model.Markdown
1+
namespace Markdown.MAML.Model.Markdown
82
{
93
/// <summary>
104
/// A section of text with formatting options.

src/Markdown.MAML/Model/Markdown/SectionFormatOption.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
62

73
namespace Markdown.MAML.Model.Markdown
84
{

src/Markdown.MAML/Model/Markdown/SourceExtent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-

2-
using System.Diagnostics;
1+
using System.Diagnostics;
2+
33
namespace Markdown.MAML.Model.Markdown
44
{
55
public class SourceRange

src/Markdown.MAML/Model/YAML/YamlCommand.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
1+
using System.Collections.Generic;
62

73
namespace Markdown.MAML.Model.YAML
84
{

src/Markdown.MAML/Parser/MarkdownParser.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public MarkdownParser(Action<int, int> progressCallback) : this(progressCallback
5858
public MarkdownParser(Action<int, int> progressCallback, int reportByteCount)
5959
{
6060
_progressCallback = progressCallback;
61+
_reportByteCount = reportByteCount;
6162
}
6263

6364
public DocumentNode ParseString(string[] markdownStrings)

src/Markdown.MAML/Parser/MarkdownPattern.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
using Markdown.MAML.Model.Markdown;
22
using System;
3-
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Text;
63
using System.Text.RegularExpressions;
7-
using System.Threading.Tasks;
84

95
namespace Markdown.MAML.Parser
106
{
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
using System.Runtime.CompilerServices;
2+
3+
[assembly: InternalsVisibleToAttribute("Markdown.MAML.Test")]

src/Markdown.MAML/Renderer/RenderCleaner.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using System.Text.RegularExpressions;
1+
using System.Text.RegularExpressions;
72

83
namespace Markdown.MAML.Renderer
94
{
10-
static public class RenderCleaner
5+
internal static class RenderCleaner
116
{
127
/// <summary>
138
/// This method runs all of the normalization tools in the cleaner. This allows full normalization without needing to call

src/Markdown.MAML/Renderer/YamlRenderer.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using Markdown.MAML.Model.MAML;
2+
using Markdown.MAML.Model.YAML;
33
using System.IO;
44
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
7-
using Markdown.MAML.Model.MAML;
8-
using Markdown.MAML.Model.YAML;
95
using YamlDotNet.Serialization;
106
using YamlDotNet.Serialization.NamingConventions;
117

src/Markdown.MAML/Transformer/MamlComparer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
using System;
1+
using Markdown.MAML.Model.MAML;
22
using System.Collections.Generic;
3-
using Markdown.MAML.Model.MAML;
43

54
namespace Markdown.MAML.Transformer
65
{

src/Markdown.MAML/Transformer/MamlModelMerger.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
using Markdown.MAML.Model.MAML;
2-
using Markdown.MAML.Model.Markdown;
32
using System;
43
using System.Collections.Generic;
54
using System.Linq;
6-
using System.Text;
7-
using System.Text.RegularExpressions;
8-
using System.Threading.Tasks;
95

106
namespace Markdown.MAML.Transformer
117
{

src/Markdown.MAML/Transformer/MamlMultiModelMerger.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
using Markdown.MAML.Model.MAML;
22
using Markdown.MAML.Model.Markdown;
33
using System;
4-
using System.Collections;
54
using System.Collections.Generic;
65
using System.Linq;
76
using System.Text;
8-
using System.Text.RegularExpressions;
97

108
namespace Markdown.MAML.Transformer
119
{

src/Markdown.MAML/Transformer/ModelTransformerBase.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
using System;
2-
using System.Linq;
3-
using System.Collections.Generic;
4-
using System.Text;
1+
using Markdown.MAML.Model.MAML;
52
using Markdown.MAML.Model.Markdown;
6-
using Markdown.MAML.Model.MAML;
73
using Markdown.MAML.Parser;
8-
using System.Text.RegularExpressions;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Text;
98

109
namespace Markdown.MAML.Transformer
1110
{

src/Markdown.MAML/Transformer/ModelTransformerVersion2.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ private Dictionary<string, string> ParseYamlKeyValuePairs(CodeBlockNode yamlSnip
292292
{
293293
result = MarkdownParser.ParseYamlKeyValuePairs(yamlSnippet.Text);
294294
}
295-
catch (ArgumentException e)
295+
catch (ArgumentException)
296296
{
297297
throw new HelpSchemaException(yamlSnippet.SourceExtent, "Invalid yaml: expected simple key-value pairs");
298298
}

src/Markdown.MAML/packages.config

Lines changed: 0 additions & 4 deletions
This file was deleted.

test/Markdown.MAML.Test/App.config

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/Markdown.MAML.Test/EndToEnd/EndToEndTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ This is an example description.
3636
This is example 2 remark.
3737
");
3838
string[] name = GetXmlContent(maml, "/msh:helpItems/command:command/command:details/command:name");
39-
Assert.Equal(1, name.Length);
39+
Assert.Single(name);
4040
Assert.Equal("Get-Foo", name[0]);
4141

4242
string[] synopsis = GetXmlContent(maml, "/msh:helpItems/command:command/command:details/maml:description/maml:para");
43-
Assert.Equal(1, synopsis.Length);
43+
Assert.Single(synopsis);
4444
Assert.Equal("This is Synopsis", synopsis[0]);
4545

4646
// Check that example title is reproduced with dash (-) padding
@@ -204,11 +204,11 @@ This is Synopsis #hashtagNotAHeader.
204204
");
205205

206206
string[] description = GetXmlContent(maml, "/msh:helpItems/command:command/maml:description/maml:para");
207-
Assert.Equal(1, description.Length);
207+
Assert.Single(description);
208208
Assert.Equal("I'm description", description[0]);
209209

210210
string[] synopsis = GetXmlContent(maml, "/msh:helpItems/command:command/command:details/maml:description/maml:para");
211-
Assert.Equal(1, synopsis.Length);
211+
Assert.Single(synopsis);
212212
Assert.Equal("This is Synopsis #hashtagNotAHeader.", synopsis[0]);
213213
}
214214

test/Markdown.MAML.Test/Markdown.MAML.Test.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
<TargetFramework>netcoreapp2.0</TargetFramework>
44
<IsPackable>false</IsPackable>
55
</PropertyGroup>
6+
<PropertyGroup>
7+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
8+
<WarningsAsErrors />
9+
</PropertyGroup>
610
<ItemGroup>
711
<PackageReference Include="System.Xml.XPath" Version="4.3.0" />
812
<PackageReference Include="System.Xml.XmlDocument" Version="4.3.0" />
@@ -13,7 +17,6 @@
1317
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
1418
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
1519
</ItemGroup>
16-
1720
<ItemGroup>
1821
<ProjectReference Include="..\..\src\Markdown.MAML\Markdown.MAML.csproj" />
1922
</ItemGroup>

0 commit comments

Comments
 (0)