Skip to content

Commit a1443e0

Browse files
committed
included .net 9
1 parent ad694ff commit a1443e0

File tree

84 files changed

+1168
-1437
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1168
-1437
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@ Validação de documentos brasileiros
66

77
Os métodos de gerar documentos são disponibilizados somente para auxilio aos desenvolvedores durante o processo de desenvolvimento de suas aplicações.
88

9+
## Versão 1.4.0
10+
11+
- Inclusão de compatibilidade a .NET 9.0
12+
- Removido compatibilidade com .NET 7
13+
- Removido compatibilidade com .NET 6
14+
- Removido compatibilidade com .NET 5
15+
- Removido compatibilidade com .NET Core 3.1
16+
- Removido compatibilidade com NetStandard 2.1
17+
- Removido compatibilidade com NetStandard 2.0
18+
- Removido compatibilidade com .NET Framework 4.8
19+
- Removido compatibilidade com .NET Framework 4.7.2
20+
- Removido compatibilidade com .NET Framework 4.7.1
21+
- Removido compatibilidade com .NET Framework 4.7
22+
- Removido compatibilidade com .NET Framework 4.6.2
23+
- Removido compatibilidade com .NET Framework 4.6.1
24+
- Removido compatibilidade com .NET Framework 4.6
25+
926
## Versões 1.3.1
1027

1128
- Inclusão de compatibilidade a .NET 8.
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
using BenchmarkDotNet.Running;
1+
namespace Sirb.Validation.Benchmark;
22

3-
namespace Sirb.Validation.Benchmark
3+
internal static class Program
44
{
5-
internal static class Program
5+
public static void Main(string[] args)
66
{
7-
public static void Main(string[] args)
8-
{
9-
BenchmarkRunner.Run<StringBenchmark>();
10-
}
7+
BenchmarkRunner.Run<StringBenchmark>();
118
}
129
}

Sirb.Validation.Benchmark/Sirb.Validation.Benchmark.csproj

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net8.0</TargetFramework>
5+
<TargetFramework>net9.0</TargetFramework>
66
<LangVersion>default</LangVersion>
77
</PropertyGroup>
88

@@ -13,11 +13,23 @@
1313
</ItemGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="BenchmarkDotNet" Version="0.13.10"/>
16+
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
1717
</ItemGroup>
1818

1919
<ItemGroup>
2020
<ProjectReference Include="..\Sirb.Validation\Sirb.Validation.csproj"/>
2121
</ItemGroup>
22+
23+
<ItemGroup>
24+
<Using Include="BenchmarkDotNet.Attributes" />
25+
<Using Include="BenchmarkDotNet.Order" />
26+
<Using Include="BenchmarkDotNet.Running" />
27+
<Using Include="Sirb.Validation.Benchmark.TestLib" />
28+
<Using Include="Sirb.Validation.Documents.BR.Validation" />
29+
<Using Include="Sirb.Validation.Extensions" />
30+
<Using Include="System" />
31+
<Using Include="System.Text" />
32+
<Using Include="System.Text.RegularExpressions" />
33+
</ItemGroup>
2234

2335
</Project>
Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,39 @@
1-
using BenchmarkDotNet.Attributes;
2-
using BenchmarkDotNet.Order;
3-
using Sirb.Validation.Benchmark.TestLib;
4-
using Sirb.Validation.Documents.BR.Validation;
5-
using Sirb.Validation.Extensions;
1+
namespace Sirb.Validation.Benchmark;
62

7-
namespace Sirb.Validation.Benchmark
3+
[MemoryDiagnoser]
4+
[Orderer(SummaryOrderPolicy.FastestToSlowest)]
5+
public class StringBenchmark
86
{
9-
[MemoryDiagnoser]
10-
[Orderer(SummaryOrderPolicy.FastestToSlowest)]
11-
public class StringBenchmark
12-
{
13-
private const string CpfValidWithMask = "555.608.950-75";
14-
private const string CpfValidWithoutMask = "55560895075";
7+
private const string CpfValidWithMask = "555.608.950-75";
8+
private const string CpfValidWithoutMask = "55560895075";
159

16-
[Benchmark]
17-
public void LibRemoveMask()
18-
{
19-
_ = CpfValidWithMask.RemoveMask();
20-
}
10+
[Benchmark]
11+
public void LibRemoveMask()
12+
{
13+
_ = CpfValidWithMask.RemoveMask();
14+
}
2115

22-
[Benchmark]
23-
public void RemoveMaskWithReplace()
24-
{
25-
StringTest.RemoveMaskWithReplace(CpfValidWithMask);
26-
}
16+
[Benchmark]
17+
public void RemoveMaskWithReplace()
18+
{
19+
StringTest.RemoveMaskWithReplace(CpfValidWithMask);
20+
}
2721

28-
[Benchmark]
29-
public void RemoveMaskWithFor()
30-
{
31-
StringTest.RemoveMaskWithFor(CpfValidWithMask);
32-
}
22+
[Benchmark]
23+
public void RemoveMaskWithFor()
24+
{
25+
StringTest.RemoveMaskWithFor(CpfValidWithMask);
26+
}
3327

34-
[Benchmark]
35-
public void RemoveMaskWithRegex()
36-
{
37-
StringTest.RemoveMaskWithRegex(CpfValidWithMask);
38-
}
28+
[Benchmark]
29+
public void RemoveMaskWithRegex()
30+
{
31+
StringTest.RemoveMaskWithRegex(CpfValidWithMask);
32+
}
3933

40-
[Benchmark]
41-
public void LibPlaceMask()
42-
{
43-
_ = CpfValidation.PlaceMask(CpfValidWithoutMask);
44-
}
34+
[Benchmark]
35+
public void LibPlaceMask()
36+
{
37+
_ = CpfValidation.PlaceMask(CpfValidWithoutMask);
4538
}
4639
}
Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,56 @@
1-
using System;
2-
using System.Text;
3-
using System.Text.RegularExpressions;
1+
namespace Sirb.Validation.Benchmark.TestLib;
42

5-
namespace Sirb.Validation.Benchmark.TestLib
3+
static public class StringTest
64
{
7-
public static class StringTest
5+
static public string RemoveMaskWithReplace(string cpf)
86
{
9-
public static string RemoveMaskWithReplace(string cpf)
10-
{
11-
if (string.IsNullOrEmpty(cpf?.Trim()))
12-
return default;
13-
14-
return cpf.Trim().Replace(".", "").Replace("-", "");
15-
}
7+
if (string.IsNullOrEmpty(cpf?.Trim()))
8+
return null;
169

17-
public static string RemoveMaskWithFor(string cpf)
18-
{
19-
if (string.IsNullOrEmpty(cpf?.Trim()))
20-
return default;
10+
return cpf.Trim()
11+
.Replace(".", string.Empty)
12+
.Replace("-", string.Empty);
13+
}
2114

22-
for (int i = cpf.Length; i > 0; i--)
23-
{
24-
if (char.IsNumber(cpf[i - 1]))
25-
continue;
15+
static public string RemoveMaskWithFor(string cpf)
16+
{
17+
if (string.IsNullOrEmpty(cpf?.Trim()))
18+
return default;
2619

27-
cpf = cpf.Remove(i - 1);
28-
}
20+
for (var i = cpf.Length; i > 0; i--)
21+
{
22+
if (char.IsNumber(cpf[i - 1]))
23+
continue;
2924

30-
return cpf;
25+
cpf = cpf.Remove(i - 1);
3126
}
3227

33-
public static string RemoveMaskWithRegex(string cpf)
34-
{
35-
if (string.IsNullOrEmpty(cpf?.Trim()))
36-
return default;
28+
return cpf;
29+
}
3730

38-
return Regex.Replace(cpf, @"[^\d]", string.Empty);
39-
}
31+
static public string RemoveMaskWithRegex(string cpf)
32+
{
33+
if (string.IsNullOrEmpty(cpf?.Trim()))
34+
return default;
4035

41-
public static string Reverse1(string value)
42-
{
43-
char[] charArray = value.ToCharArray();
44-
Array.Reverse(charArray);
45-
return new string(charArray);
46-
}
36+
return Regex.Replace(cpf, @"[^\d]", string.Empty);
37+
}
4738

48-
public static string Reverse2(string value)
49-
{
50-
if (string.IsNullOrEmpty(value)) return value;
39+
static public string Reverse1(string value)
40+
{
41+
var charArray = value.ToCharArray();
42+
Array.Reverse(charArray);
43+
return new string(charArray);
44+
}
5145

52-
StringBuilder sb = new StringBuilder();
53-
for (int i = value.Length; i > 0; i--)
54-
{
55-
_ = sb.Append(value[i - 1]);
56-
}
46+
static public string Reverse2(string value)
47+
{
48+
if (string.IsNullOrEmpty(value)) return value;
5749

58-
return sb.ToString();
59-
}
50+
var sb = new StringBuilder();
51+
for (var i = value.Length; i > 0; i--)
52+
_ = sb.Append(value[i - 1]);
53+
54+
return sb.ToString();
6055
}
6156
}

Sirb.Validation.Test/Exceptions/StateNotFoundExceptionTest.cs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
using Sirb.Validation.Exceptions;
2-
using System;
3-
using System.IO;
4-
using System.Runtime.Serialization.Formatters.Binary;
5-
using Xunit;
6-
71
namespace Sirb.Validation.Test.Exceptions;
82

93
public class StateNotFoundExceptionTest
@@ -49,20 +43,4 @@ public void NotFoundException_When_Meets_Condition(bool condition, string messag
4943
StateNotFoundException.ThrowIf(condition, message);
5044
Assert.True(true);
5145
}
52-
53-
[Fact]
54-
public void NotFoundException_Serialization()
55-
{
56-
var e = new StateNotFoundException(ExpectedMessage);
57-
58-
using (Stream s = new MemoryStream())
59-
{
60-
var formatter = new BinaryFormatter();
61-
formatter.Serialize(s, e);
62-
s.Position = 0; // Reset stream position
63-
e = (StateNotFoundException)formatter.Deserialize(s);
64-
}
65-
66-
Assert.Equal(ExpectedMessage, e.Message);
67-
}
6846
}
Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
1-
using Sirb.Validation.Extensions;
2-
using Xunit;
1+
namespace Sirb.Validation.Test.Extensions;
32

4-
namespace Sirb.Validation.Test.Extensions
3+
public class AcreExtensionTest
54
{
6-
public class AcreExtensionTest
5+
[Theory]
6+
[InlineData("0100482300112", "01.004.823/001-12")]
7+
public void InscricaoEstadualMask_Valid(string value, string expected)
78
{
8-
[Theory]
9-
[InlineData("0100482300112", "01.004.823/001-12")]
10-
public void InscricaoEstadualMask_Valid(string value, string expected)
11-
{
12-
var maskedValue = value.InscricaoEstadualMaskAc();
13-
Assert.Equal(expected, maskedValue);
14-
}
9+
var maskedValue = value.InscricaoEstadualMaskAc();
10+
Assert.Equal(expected, maskedValue);
11+
}
1512

16-
[Theory]
17-
[InlineData("0100482300112", "01.004.823/001-12")]
18-
public void InscricaoEstadualMask_Invalid(string value, string expected)
19-
{
20-
var maskedValue = value.InscricaoEstadualMaskAl();
21-
Assert.NotEqual(expected, maskedValue);
22-
}
13+
[Theory]
14+
[InlineData("0100482300112", "01.004.823/001-12")]
15+
public void InscricaoEstadualMask_Invalid(string value, string expected)
16+
{
17+
var maskedValue = value.InscricaoEstadualMaskAl();
18+
Assert.NotEqual(expected, maskedValue);
2319
}
24-
}
20+
}
Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
1-
using Sirb.Validation.Extensions;
2-
using Xunit;
1+
namespace Sirb.Validation.Test.Extensions;
32

4-
namespace Sirb.Validation.Test.Extensions
3+
public class AlagoasExtensionTest
54
{
6-
public class AlagoasExtensionTest
5+
[Theory]
6+
[InlineData("123456789", "12345678-9")]
7+
public void InscricaoEstadualMask_Valid(string value, string expected)
78
{
8-
[Theory]
9-
[InlineData("123456789", "12345678-9")]
10-
public void InscricaoEstadualMask_Valid(string value, string expected)
11-
{
12-
var maskedValue = value.InscricaoEstadualMaskAl();
13-
Assert.Equal(expected, maskedValue);
14-
}
9+
var maskedValue = value.InscricaoEstadualMaskAl();
10+
Assert.Equal(expected, maskedValue);
11+
}
1512

16-
[Theory]
17-
[InlineData("123456789", "12345678-9")]
18-
public void InscricaoEstadualMask_Invalid(string value, string expected)
19-
{
20-
var maskedValue = value.InscricaoEstadualMaskAp();
21-
Assert.NotEqual(expected, maskedValue);
22-
}
13+
[Theory]
14+
[InlineData("123456789", "12345678-9")]
15+
public void InscricaoEstadualMask_Invalid(string value, string expected)
16+
{
17+
var maskedValue = value.InscricaoEstadualMaskAp();
18+
Assert.NotEqual(expected, maskedValue);
2319
}
24-
}
20+
}

0 commit comments

Comments
 (0)