From f3692580e63c243639ab5bfb5198efbc3fa894bd Mon Sep 17 00:00:00 2001 From: Guilherme Branco Stracini Date: Fri, 27 Mar 2020 22:09:23 -0300 Subject: [PATCH 1/5] Fix pattern --- README.md | 39 +++++++--- {ViaCEP => Src/ViaCEP}/VIaCEPResult.cs | 0 {ViaCEP => Src/ViaCEP}/ViaCEP.csproj | 0 {ViaCEP => Src/ViaCEP}/ViaCEPClient.cs | 0 .../ViaCEP.Tests}/AddressTests.cs | 1 - .../ViaCEP.Tests}/ViaCEP.Tests.csproj | 0 .../ViaCEP.Tests}/ZipCodeTests.cs | 0 ViaCEP.sln | 76 +++++++++++-------- appveyor.yml | 51 +++++++------ 9 files changed, 98 insertions(+), 69 deletions(-) rename {ViaCEP => Src/ViaCEP}/VIaCEPResult.cs (100%) rename {ViaCEP => Src/ViaCEP}/ViaCEP.csproj (100%) rename {ViaCEP => Src/ViaCEP}/ViaCEPClient.cs (100%) rename {ViaCEP.Tests => Tests/ViaCEP.Tests}/AddressTests.cs (99%) rename {ViaCEP.Tests => Tests/ViaCEP.Tests}/ViaCEP.Tests.csproj (100%) rename {ViaCEP.Tests => Tests/ViaCEP.Tests}/ZipCodeTests.cs (100%) diff --git a/README.md b/README.md index f12f56c..54da888 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,48 @@ # ViaCEP -The [ViaCEP](https://viacep.com.br) web service client for .NET projects -[![Build status](https://ci.appveyor.com/api/projects/status/9jnsy1e08jhyxl7j?svg=true)](https://ci.appveyor.com/project/guibranco/viacep) -[![ViaCEP NuGet Version](https://img.shields.io/nuget/v/ViaCEP.svg?style=flat)](https://www.nuget.org/packages/ViaCEP/) -[![ViaCEP NuGet Downloads](https://img.shields.io/nuget/dt/ViaCEP.svg?style=flat)](https://www.nuget.org/packages/ViaCEP/) +A .NET client wrapper for both .NET Core & .NET Framework projects of [Via CEP API](https://viacep.com.br) + +![Via CEP](https://raw.githubusercontent.com/guibranco/viacep/master/logo.png) + +## CI/CD + +[![Build status](https://ci.appveyor.com/api/projects/status/9jnsy1e08jhyxl7j?svg=true)](https://ci.appveyor.com/project/guibranco/9jnsy1e08jhyxl7j) +[![SMSDev NuGet Version](https://img.shields.io/nuget/v/ViaCEP.svg?style=flat)](https://www.nuget.org/packages/ViaCEP/) +[![SMSDev NuGet Downloads](https://img.shields.io/nuget/dt/ViaCEP.svg?style=flat)](https://www.nuget.org/packages/ViaCEP/) [![Github All Releases](https://img.shields.io/github/downloads/guibranco/ViaCEP/total.svg?style=flat)](https://github.com/guibranco/ViaCEP) -![Last release](https://img.shields.io/github/release-date/guibranco/viacep.svg?style=flat) +[![Last release](https://img.shields.io/github/release-date/guibranco/ViaCEP.svg?style=flat)](https://github.com/guibranco/ViaCEP) + +## Code Quality -[![codecov](https://codecov.io/gh/guibranco/viacep/branch/master/graph/badge.svg)](https://codecov.io/gh/guibranco/viacep) +[![codecov](https://codecov.io/gh/guibranco/SMSDev/branch/master/graph/badge.svg)](https://codecov.io/gh/guibranco/SMSDev) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=alert_status)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP) +[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=coverage)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP) + +[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP) [![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=ncloc)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP) [![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=sqale_index)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP) -[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP) -[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=security_rating)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP) +[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP) -ViaCEP - -The ViaCEP service is exclusive for Brazil! No zipcode data available for other countries (Feb/2019)! +[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP) +[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=security_rating)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP) +[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=code_smells)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP) +[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=bugs)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP) +[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP) --- + NuGet package: https://www.nuget.org/packages/ViaCEP -``` +```ps Install-Package ViaCEP ``` --- + ## Usage The package has two classes: + - [ViaCEPClient](https://github.com/guibranco/ViaCEP/blob/master/ViaCEP/ViaCEPClient.cs) - The main class (methods) - [ViaCEPResult](https://github.com/guibranco/ViaCEP/blob/master/ViaCEP/VIaCEPResult.cs) - The result class (data) @@ -42,6 +56,7 @@ var address = result.Address; var neighborhood = result.Neighborhood //do what you need with 'result' instance of ViaCEPResult. ``` + ## Querying by address (list result) ```cs diff --git a/ViaCEP/VIaCEPResult.cs b/Src/ViaCEP/VIaCEPResult.cs similarity index 100% rename from ViaCEP/VIaCEPResult.cs rename to Src/ViaCEP/VIaCEPResult.cs diff --git a/ViaCEP/ViaCEP.csproj b/Src/ViaCEP/ViaCEP.csproj similarity index 100% rename from ViaCEP/ViaCEP.csproj rename to Src/ViaCEP/ViaCEP.csproj diff --git a/ViaCEP/ViaCEPClient.cs b/Src/ViaCEP/ViaCEPClient.cs similarity index 100% rename from ViaCEP/ViaCEPClient.cs rename to Src/ViaCEP/ViaCEPClient.cs diff --git a/ViaCEP.Tests/AddressTests.cs b/Tests/ViaCEP.Tests/AddressTests.cs similarity index 99% rename from ViaCEP.Tests/AddressTests.cs rename to Tests/ViaCEP.Tests/AddressTests.cs index 6e3b2f4..ce58873 100644 --- a/ViaCEP.Tests/AddressTests.cs +++ b/Tests/ViaCEP.Tests/AddressTests.cs @@ -24,7 +24,6 @@ public void ValidateSearchByFullAddress() var first = list.First(); Assert.Equal("SP", first.StateInitials); Assert.Equal("São Paulo", first.City); - } } } \ No newline at end of file diff --git a/ViaCEP.Tests/ViaCEP.Tests.csproj b/Tests/ViaCEP.Tests/ViaCEP.Tests.csproj similarity index 100% rename from ViaCEP.Tests/ViaCEP.Tests.csproj rename to Tests/ViaCEP.Tests/ViaCEP.Tests.csproj diff --git a/ViaCEP.Tests/ZipCodeTests.cs b/Tests/ViaCEP.Tests/ZipCodeTests.cs similarity index 100% rename from ViaCEP.Tests/ZipCodeTests.cs rename to Tests/ViaCEP.Tests/ZipCodeTests.cs diff --git a/ViaCEP.sln b/ViaCEP.sln index 79ba416..30c7f23 100644 --- a/ViaCEP.sln +++ b/ViaCEP.sln @@ -1,31 +1,45 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.421 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ViaCEP", "ViaCEP\ViaCEP.csproj", "{A251D320-410E-48F1-889D-9F59EB8CFEB9}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ViaCEP.Tests", "ViaCEP.Tests\ViaCEP.Tests.csproj", "{D9FD0AA7-A4C5-43A2-820F-827BD503B52B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A251D320-410E-48F1-889D-9F59EB8CFEB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A251D320-410E-48F1-889D-9F59EB8CFEB9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A251D320-410E-48F1-889D-9F59EB8CFEB9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A251D320-410E-48F1-889D-9F59EB8CFEB9}.Release|Any CPU.Build.0 = Release|Any CPU - {D9FD0AA7-A4C5-43A2-820F-827BD503B52B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D9FD0AA7-A4C5-43A2-820F-827BD503B52B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D9FD0AA7-A4C5-43A2-820F-827BD503B52B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D9FD0AA7-A4C5-43A2-820F-827BD503B52B}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {AC1987AC-4E78-4CCD-84BC-543F3D7426B4} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29920.165 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Src", "Src", "{A8E8D875-2058-4E15-B179-37FD1D408F66}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{474F8215-8B66-4E36-927C-E078635C7996}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ViaCEP", "Src\ViaCEP\ViaCEP.csproj", "{A251D320-410E-48F1-889D-9F59EB8CFEB9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ViaCEP.Tests", "Tests\ViaCEP.Tests\ViaCEP.Tests.csproj", "{D9FD0AA7-A4C5-43A2-820F-827BD503B52B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5A1303EA-8DFA-48C6-A96D-EC71AE4EC0E8}" + ProjectSection(SolutionItems) = preProject + appveyor.yml = appveyor.yml + README.md = README.md + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A251D320-410E-48F1-889D-9F59EB8CFEB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A251D320-410E-48F1-889D-9F59EB8CFEB9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A251D320-410E-48F1-889D-9F59EB8CFEB9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A251D320-410E-48F1-889D-9F59EB8CFEB9}.Release|Any CPU.Build.0 = Release|Any CPU + {D9FD0AA7-A4C5-43A2-820F-827BD503B52B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D9FD0AA7-A4C5-43A2-820F-827BD503B52B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D9FD0AA7-A4C5-43A2-820F-827BD503B52B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D9FD0AA7-A4C5-43A2-820F-827BD503B52B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {A251D320-410E-48F1-889D-9F59EB8CFEB9} = {A8E8D875-2058-4E15-B179-37FD1D408F66} + {D9FD0AA7-A4C5-43A2-820F-827BD503B52B} = {474F8215-8B66-4E36-927C-E078635C7996} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {AC1987AC-4E78-4CCD-84BC-543F3D7426B4} + EndGlobalSection +EndGlobal diff --git a/appveyor.yml b/appveyor.yml index 26c3bd6..d760677 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,15 +1,17 @@ version: 2.0.{build} -branches: - only: - - master skip_tags: true -image: Visual Studio 2017 +image: Visual Studio 2019 configuration: Release skip_commits: - message: /(Created|Update).*\.(png|jpg|jpeg|bmp|gif|md)/ + message: /(Create|Update).*\.(png|jpg|jpeg|bmp|gif|md)/ environment: - SONAR_TOKEN: - secure: b45J8d8RnM19gldF3sJX6UGacdYRXvyTYpubf1YUrGdHXZi+90NOtstyftjLXMSO + SOLUTION_NAME: ViaCEP + SONAR_PROJECT: guibranco_ViaCEP + SONAR_ORGANIZATION: guibranco-github + SONAR_TOKEN: + secure: b45J8d8RnM19gldF3sJX6UGacdYRXvyTYpubf1YUrGdHXZi+90NOtstyftjLXMSO + GITHUB_TOKEN: + secure: IEDiCuYBM8BnfdT90PGnvnKGEfHHHgzziGqfoZUUqTi1FgSkBXoMrAGbdLP6jNok dotnet_csproj: patch: true file: '**\*.csproj' @@ -29,30 +31,30 @@ build: verbosity: normal build_script: - dotnet tool install --global dotnet-sonarscanner - - ps: 'if (-Not $env:APPVEYOR_PULL_REQUEST_NUMBER) { & dotnet - sonarscanner begin - /k:"guibranco_ViaCEP" - /o:"guibranco-github" + - ps: 'if (-Not $env:APPVEYOR_PULL_REQUEST_NUMBER) { & + dotnet sonarscanner begin + /k:"$env:SONAR_PROJECT" + /o:"$env:SONAR_ORGANIZATION" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.login="$env:SONAR_TOKEN" /v:"$env:APPVEYOR_BUILD_NUMBER" /d:sonar.exclusions="**/bin/**/*,**/obj/**/*" - /d:sonar.coverage.exclusions="ViaCEP.Tests/**,**/*Tests.cs" - /d:sonar.cs.opencover.reportsPaths="$env:CD\ViaCEP.Tests\coverage.opencover.xml" }' - - dotnet build - - ps: dotnet test .\ViaCEP.Tests\ViaCEP.Tests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat="opencover" + /d:sonar.coverage.exclusions="**/$env:SOLUTION_NAME.Tests/**,**/*Tests.cs" + /d:sonar.cs.opencover.reportsPaths="$env:CD\Tests\$env:SOLUTION_NAME.Tests\coverage.opencover.xml" }' + - dotnet build %SOLUTION_NAME%.sln + - ps: dotnet test .\Tests\$env:SOLUTION_NAME.Tests\$env:SOLUTION_NAME.Tests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat="opencover" - ps: 'if (-Not $env:APPVEYOR_PULL_REQUEST_NUMBER) { & dotnet sonarscanner end /d:sonar.login="$env:SONAR_TOKEN" }' - - codecov -f "ViaCEP.Tests\coverage.opencover.xml" + - codecov -f "Tests\$env:SOLUTION_NAME.Tests\coverage.opencover.xml" after_build: -- xcopy %CD%\ViaCEP\bin\Release\netstandard2.0\*.* %CD%\Build\ -- copy %CD%\ViaCEP\bin\Release\ViaCEP.%APPVEYOR_BUILD_VERSION%.nupkg ViaCEP.%APPVEYOR_BUILD_VERSION%.nupkg -- rd /s /q %CD%\ViaCEP\bin\Release\ +- xcopy %CD%\Src\%SOLUTION_NAME%\bin\Release\netstandard2.0\*.* %CD%\Build\ +- copy %CD%\Src\%SOLUTION_NAME%\bin\Release\%SOLUTION_NAME%.%APPVEYOR_BUILD_VERSION%.nupkg %SOLUTION_NAME%.%APPVEYOR_BUILD_VERSION%.nupkg +- rd /s /q %CD%\Src\%SOLUTION_NAME%\bin\Release\ - cd %CD% -- 7z a -tzip -mx9 "ViaCEP.%APPVEYOR_BUILD_VERSION%.zip" Build +- 7z a -tzip -mx9 "%SOLUTION_NAME%.%APPVEYOR_BUILD_VERSION%.zip" Build artifacts: -- path: ViaCEP.%APPVEYOR_BUILD_VERSION%.zip +- path: $(SOLUTION_NAME).%APPVEYOR_BUILD_VERSION%.zip name: ZipFile -- path: ViaCEP.%APPVEYOR_BUILD_VERSION%.nupkg +- path: $(SOLUTION_NAME).%APPVEYOR_BUILD_VERSION%.nupkg name: Package deploy: - provider: Environment @@ -64,7 +66,6 @@ deploy: on: branch: master tag: $(appveyor_build_version) - auth_token: - secure: VgYYJdvNLy/n9/uxxlaF0bMpIIrVxCb+dGr66U9nWfPWSN2ySdfuilO8klAw0uvF + auth_token: $(GITHUB_TOKEN) force_update: true - artifact: ZipFile \ No newline at end of file + artifact: ZipFile From 6a7c89f1c3c24f9d177ed84d69228f09e5bd12ed Mon Sep 17 00:00:00 2001 From: Guilherme Branco Stracini Date: Fri, 27 Mar 2020 22:11:26 -0300 Subject: [PATCH 2/5] Removed ISSUE_TEMPLATE --- .github/ISSUE_TEMPLATE/bug_report.md | 38 ----------------------- .github/ISSUE_TEMPLATE/feature_request.md | 20 ------------ 2 files changed, 58 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index dd84ea7..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] - -**Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index bbcbbe7..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. From 5d9f6a0469696435145c9ec8e0be39648a28d25a Mon Sep 17 00:00:00 2001 From: Guilherme Branco Stracini Date: Fri, 27 Mar 2020 22:14:31 -0300 Subject: [PATCH 3/5] Fix test references --- Src/ViaCEP/VIaCEPResult.cs | 19 +++++++++---------- Src/ViaCEP/ViaCEPClient.cs | 15 +++++++-------- Tests/ViaCEP.Tests/ViaCEP.Tests.csproj | 2 +- Tests/ViaCEP.Tests/ZipCodeTests.cs | 5 ++--- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Src/ViaCEP/VIaCEPResult.cs b/Src/ViaCEP/VIaCEPResult.cs index c630006..63b8c9a 100644 --- a/Src/ViaCEP/VIaCEPResult.cs +++ b/Src/ViaCEP/VIaCEPResult.cs @@ -1,7 +1,6 @@ namespace ViaCEP { using Newtonsoft.Json; - using System; /// /// The Via CEP result class. @@ -15,7 +14,7 @@ public sealed class ViaCEPResult /// The zip code. /// [JsonProperty("cep")] - public String ZipCode { get; set; } + public string ZipCode { get; set; } /// /// Gets or sets the street. @@ -24,7 +23,7 @@ public sealed class ViaCEPResult /// The street. /// [JsonProperty("logradouro")] - public String Street { get; set; } + public string Street { get; set; } /// /// Gets or sets the complement. @@ -33,7 +32,7 @@ public sealed class ViaCEPResult /// The complement. /// [JsonProperty("complemento")] - public String Complement { get; set; } + public string Complement { get; set; } /// /// Gets or sets the neighborhood. @@ -42,7 +41,7 @@ public sealed class ViaCEPResult /// The neighborhood. /// [JsonProperty("bairro")] - public String Neighborhood { get; set; } + public string Neighborhood { get; set; } /// /// Gets or sets the city. @@ -51,7 +50,7 @@ public sealed class ViaCEPResult /// The city. /// [JsonProperty("localidade")] - public String City { get; set; } + public string City { get; set; } /// /// Gets or sets the state initials. @@ -60,7 +59,7 @@ public sealed class ViaCEPResult /// The state initials. /// [JsonProperty("uf")] - public String StateInitials { get; set; } + public string StateInitials { get; set; } /// /// Gets or sets the unit. @@ -69,7 +68,7 @@ public sealed class ViaCEPResult /// The unit. /// [JsonProperty("unidade")] - public String Unit { get; set; } + public string Unit { get; set; } /// /// Gets or sets the ibge code. @@ -78,7 +77,7 @@ public sealed class ViaCEPResult /// The ibge code. /// [JsonProperty("ibge")] - public Int32 IBGECode { get; set; } + public int IBGECode { get; set; } /// /// Gets or sets the gia code. @@ -87,6 +86,6 @@ public sealed class ViaCEPResult /// The gia code. /// [JsonProperty("gia")] - public Int32? GIACode { get; set; } + public int? GIACode { get; set; } } } diff --git a/Src/ViaCEP/ViaCEPClient.cs b/Src/ViaCEP/ViaCEPClient.cs index 2674929..5eaef69 100644 --- a/Src/ViaCEP/ViaCEPClient.cs +++ b/Src/ViaCEP/ViaCEPClient.cs @@ -16,11 +16,10 @@ public static class ViaCEPClient /// /// The base URL /// - private const String BaseUrl = "https://viacep.com.br"; + private const string BaseUrl = "https://viacep.com.br"; #endregion - #region Public methods /// @@ -28,7 +27,7 @@ public static class ViaCEPClient /// /// The zip code. /// - public static ViaCEPResult Search(String zipCode) + public static ViaCEPResult Search(string zipCode) { return SearchAsync(zipCode, CancellationToken.None).Result; } @@ -39,7 +38,7 @@ public static ViaCEPResult Search(String zipCode) /// The zip code. /// The token. /// - public static async Task SearchAsync(String zipCode, CancellationToken token) + public static async Task SearchAsync(string zipCode, CancellationToken token) { using (var client = new HttpClient()) { @@ -57,7 +56,7 @@ public static async Task SearchAsync(String zipCode, CancellationT /// The city. /// The address. /// - public static IEnumerable Search(String stateInitials, String city, String address) + public static IEnumerable Search(string stateInitials, string city, string address) { return SearchAsync(stateInitials, city, address, CancellationToken.None).Result; } @@ -71,9 +70,9 @@ public static IEnumerable Search(String stateInitials, String city /// The token. /// public static async Task> SearchAsync( - String stateInitials, - String city, - String address, + string stateInitials, + string city, + string address, CancellationToken token) { using (var client = new HttpClient()) diff --git a/Tests/ViaCEP.Tests/ViaCEP.Tests.csproj b/Tests/ViaCEP.Tests/ViaCEP.Tests.csproj index 7bbe90b..78f2931 100644 --- a/Tests/ViaCEP.Tests/ViaCEP.Tests.csproj +++ b/Tests/ViaCEP.Tests/ViaCEP.Tests.csproj @@ -17,7 +17,7 @@ - + diff --git a/Tests/ViaCEP.Tests/ZipCodeTests.cs b/Tests/ViaCEP.Tests/ZipCodeTests.cs index d4226de..710700a 100644 --- a/Tests/ViaCEP.Tests/ZipCodeTests.cs +++ b/Tests/ViaCEP.Tests/ZipCodeTests.cs @@ -19,9 +19,8 @@ public void ValidateSearchByZipCode() Assert.Equal("Quarta Parada", result.Neighborhood); Assert.Equal("São Paulo", result.City); Assert.Equal("SP", result.StateInitials); - } - - + } + /// /// Validates if the search by zip code don't throw a exception if the address doesn't have a gia code /// From 3d404e1729a4c9f560f67ff120361c2de8434c5e Mon Sep 17 00:00:00 2001 From: Guilherme Branco Stracini Date: Fri, 27 Mar 2020 22:20:54 -0300 Subject: [PATCH 4/5] Update test --- Tests/ViaCEP.Tests/AddressTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/ViaCEP.Tests/AddressTests.cs b/Tests/ViaCEP.Tests/AddressTests.cs index ce58873..88175e8 100644 --- a/Tests/ViaCEP.Tests/AddressTests.cs +++ b/Tests/ViaCEP.Tests/AddressTests.cs @@ -20,7 +20,7 @@ public void ValidateSearchByFullAddress() var list = result.ToList(); Assert.True(list.Any()); Assert.Contains(list, r => r.ZipCode.Equals("01310-905", StringComparison.InvariantCultureIgnoreCase)); - Assert.Contains(list, r => r.ZipCode.Equals("01310-923", StringComparison.InvariantCultureIgnoreCase)); + Assert.Contains(list, r => r.ZipCode.Equals("01311-941", StringComparison.InvariantCultureIgnoreCase)); var first = list.First(); Assert.Equal("SP", first.StateInitials); Assert.Equal("São Paulo", first.City); From 539d21d958090c172ef7c960af95a36066387c0d Mon Sep 17 00:00:00 2001 From: Guilherme Branco Stracini Date: Fri, 27 Mar 2020 22:24:48 -0300 Subject: [PATCH 5/5] Update nuget packages --- Src/ViaCEP/ViaCEP.csproj | 2 +- Tests/ViaCEP.Tests/ViaCEP.Tests.csproj | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Src/ViaCEP/ViaCEP.csproj b/Src/ViaCEP/ViaCEP.csproj index 908760e..7cbd9f7 100644 --- a/Src/ViaCEP/ViaCEP.csproj +++ b/Src/ViaCEP/ViaCEP.csproj @@ -19,6 +19,6 @@ - + diff --git a/Tests/ViaCEP.Tests/ViaCEP.Tests.csproj b/Tests/ViaCEP.Tests/ViaCEP.Tests.csproj index 78f2931..98e3657 100644 --- a/Tests/ViaCEP.Tests/ViaCEP.Tests.csproj +++ b/Tests/ViaCEP.Tests/ViaCEP.Tests.csproj @@ -7,13 +7,16 @@ - + runtime; build; native; contentfiles; analyzers all - - - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive +