Skip to content

Commit 4017871

Browse files
UsuarioUsuario
Usuario
authored and
Usuario
committed
Move Validation namespace to a separate project
1 parent bcc65dd commit 4017871

15 files changed

+52
-29
lines changed

BaseXml.Tests/BaseXml.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<PackageReference Include="XMLUnit.Core" Version="2.9.2" />
1313
</ItemGroup>
1414
<ItemGroup>
15+
<ProjectReference Include="..\BaseXml.Validation\BaseXml.Validation.csproj" />
1516
<ProjectReference Include="..\BaseXml\BaseXml.csproj" />
1617
</ItemGroup>
1718
</Project>
File renamed without changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<PackageReference Include="FluentValidation" Version="11.9.2" />
8+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net461" Version="1.0.3">
9+
<PrivateAssets>all</PrivateAssets>
10+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
11+
</PackageReference>
12+
</ItemGroup>
13+
<ItemGroup>
14+
<ProjectReference Include="..\BaseXml\BaseXml.csproj" />
15+
</ItemGroup>
16+
17+
</Project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

BaseXml.sln

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
21
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27703.2042
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.10.35013.160
54
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BaseXml", "BaseXml\BaseXml.csproj", "{003977B7-6E1D-48AF-A998-A54EFEBA800C}"
5+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BaseXml", "BaseXml\BaseXml.csproj", "{003977B7-6E1D-48AF-A998-A54EFEBA800C}"
76
EndProject
87
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BaseXml.Tests", "BaseXml.Tests\BaseXml.Tests.csproj", "{F7CFABEB-972D-431E-97DA-5F2482A2D147}"
98
EndProject
109
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BaseXml.Sample", "BaseXml.Sample\BaseXml.Sample.csproj", "{CB385706-0ACC-4110-99AF-2F9564031679}"
1110
EndProject
11+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BaseXml.Validation", "BaseXml.Validation\BaseXml.Validation.csproj", "{D4D39EA0-1F60-4F6F-A49D-F55F22732440}"
12+
EndProject
1213
Global
1314
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1415
Debug|Any CPU = Debug|Any CPU
@@ -27,6 +28,10 @@ Global
2728
{CB385706-0ACC-4110-99AF-2F9564031679}.Debug|Any CPU.Build.0 = Debug|Any CPU
2829
{CB385706-0ACC-4110-99AF-2F9564031679}.Release|Any CPU.ActiveCfg = Release|Any CPU
2930
{CB385706-0ACC-4110-99AF-2F9564031679}.Release|Any CPU.Build.0 = Release|Any CPU
31+
{D4D39EA0-1F60-4F6F-A49D-F55F22732440}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32+
{D4D39EA0-1F60-4F6F-A49D-F55F22732440}.Debug|Any CPU.Build.0 = Debug|Any CPU
33+
{D4D39EA0-1F60-4F6F-A49D-F55F22732440}.Release|Any CPU.ActiveCfg = Release|Any CPU
34+
{D4D39EA0-1F60-4F6F-A49D-F55F22732440}.Release|Any CPU.Build.0 = Release|Any CPU
3035
EndGlobalSection
3136
GlobalSection(SolutionProperties) = preSolution
3237
HideSolutionNode = FALSE

BaseXml/BaseXml.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1010
</PropertyGroup>
1111
<ItemGroup>
12-
<PackageReference Include="FluentValidation" Version="11.9.2" />
1312
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net461" Version="1.0.3">
1413
<PrivateAssets>all</PrivateAssets>
1514
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

Directory.Build.props

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<Project>
2-
<ItemGroup Condition="'$(MSBuildProjectFile)'!='BaseXml.csproj'">
2+
<ItemGroup Condition="'$(MSBuildProjectFile)'=='BaseXml.Tests.csproj' Or '$(MSBuildProjectFile)'=='BaseXml.Sample.csproj'">
33
<Using Include="NUnit.Framework.Legacy.ClassicAssert" Alias="Assert" />
4-
<Using Include="NUnit.Framework.Legacy.CollectionAssert" Alias="CollectionAssert" />
54
<Using Include="NUnit.Framework.Legacy.StringAssert" Alias="StringAssert" />
6-
<Using Include="NUnit.Framework.Legacy.DirectoryAssert" Alias="DirectoryAssert" />
7-
<Using Include="NUnit.Framework.Legacy.FileAssert" Alias="FileAssert" />
85
</ItemGroup>
96
</Project>

README.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,23 @@ Also, BaseXML offers a set of validators to check the nodes of XML documents.
1313
To use BaseXML, create a class inheriting from `BaseDocument` to define mutable custom operations.
1414

1515
```csharp
16+
using BaseXml;
17+
1618
class Note: BaseDocument
1719
{
18-
public Note(string xml)
19-
: base(xml)
20-
{
21-
}
22-
23-
public string Body
24-
=> Evaluate(new XPath("/note/body"));
25-
26-
public void AddPS(string ps)
27-
{
28-
var psNode = $"<ps>{ps}</ps>";
29-
AddSiblingNodeAfterFirstOf(psNode, new XPath("/note/body"));
30-
}
20+
public Note(string xml)
21+
: base(xml)
22+
{
23+
}
24+
25+
public string Body
26+
=> Evaluate(new XPath("/note/body"));
27+
28+
public void AddPS(string ps)
29+
{
30+
var psNode = $"<ps>{ps}</ps>";
31+
AddSiblingNodeAfterFirstOf(psNode, new XPath("/note/body"));
32+
}
3133
}
3234
```
3335

@@ -52,7 +54,6 @@ string xml = @"<?xml version=""1.0"" encoding=""utf-8""?>
5254
<subject>Subject</subject>
5355
<body>A Body</body>
5456
</note>";
55-
5657
var note = new Note(xml);
5758

5859
var body = note.Body;
@@ -75,19 +76,22 @@ Please, look at the [Sample project](https://github.com/canro91/BaseXml/tree/mas
7576
BaseXml provides some per-node validations on top of a [FluentValidation](https://github.com/FluentValidation/FluentValidation) validator.
7677

7778
```csharp
79+
using BaseXml;
80+
using BaseXml.Validation;
81+
7882
string xml = @"<?xml version=""1.0"" encoding=""utf-8""?>
7983
<note>
80-
<from>Bob</from>
81-
<to>Alice</to>
82-
<subject>Subject</subject>
83-
<body>A Body</body>
84+
<from>Bob</from>
85+
<to>Alice</to>
86+
<subject>Subject</subject>
87+
<body>A Body</body>
8488
</note>";
8589
var note = new Note(xml);
8690

8791
var validator = new CheckDocument(new Dictionary<XPath, IEnumerable<IValidateNode>>
8892
{
89-
{ new XPath("/note/subject"), new List<IValidateNode> { new Length(min: 1, max: 10) } },
90-
{ new XPath("/note/body"), new List<IValidateNode> { new Required() } }
93+
{ new XPath("/note/subject"), new List<IValidateNode> { new Length(min: 1, max: 10) } },
94+
{ new XPath("/note/body"), new List<IValidateNode> { new Required() } }
9195
});
9296

9397
ValidationResult results = validator.Validate(note);

0 commit comments

Comments
 (0)