{"id":20414571,"url":"https://github.com/codecov/example-csharp","last_synced_at":"2025-08-20T14:32:28.056Z","repository":{"id":30854109,"uuid":"34411629","full_name":"codecov/example-csharp","owner":"codecov","description":"Codecov: C# example repository","archived":false,"fork":false,"pushed_at":"2024-01-22T20:34:32.000Z","size":43,"stargazers_count":116,"open_issues_count":4,"forks_count":67,"subscribers_count":33,"default_branch":"master","last_synced_at":"2024-12-12T19:07:05.687Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://codecov.io","language":"C#","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codecov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-04-22T19:38:00.000Z","updated_at":"2024-09-25T02:46:03.000Z","dependencies_parsed_at":"2024-11-15T12:16:46.215Z","dependency_job_id":null,"html_url":"https://github.com/codecov/example-csharp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codecov%2Fexample-csharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codecov%2Fexample-csharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codecov%2Fexample-csharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codecov%2Fexample-csharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codecov","download_url":"https://codeload.github.com/codecov/example-csharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230431103,"owners_count":18224655,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T06:11:12.102Z","updated_at":"2024-12-19T12:11:22.439Z","avatar_url":"https://github.com/codecov.png","language":"C#","readme":"# [Codecov](https://codecov.io) C# Example\n\n[![codecov](https://codecov.io/gh/codecov/example-csharp/branch/master/graph/badge.svg)](https://codecov.io/gh/codecov/example-csharp)\n[![AppVeyor](https://img.shields.io/appveyor/ci/stevepeak/example-csharp.svg)](https://ci.appveyor.com/project/stevepeak/example-csharp/branch/master)\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-csharp.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-csharp?ref=badge_shield)\n\n## Guide\n### AppVeyor Setup\nAdd to your `appveyor.yml` file.\n```yml\nimage: Visual Studio 2015\n\nbefore_build:\n- nuget restore\n- choco install opencover.portable\n- choco install codecov\n\nbuild:\n  project: CodecovProject.sln\n  verbosity: minimal\n\ntest_script:\n- OpenCover.Console.exe -register:user -target:\"%xunit20%\\xunit.console.x86.exe\" -targetargs:\".\\MyUnitTests\\bin\\Debug\\MyUnitTests.dll -noshadow\" -filter:\"+[UnitTestTargetProject*]* -[MyUnitTests*]*\" -output:\".\\MyProject_coverage.xml\"\n- codecov -f \"MyProject_coverage.xml\n```\n### Producing Coverage Reports\nCoverage is generated using [OpenCover](https://github.com/OpenCover/opencover). You can obtain it from [NuGet](https://www.nuget.org/packages/opencover) or [Chocolatey](https://chocolatey.org/packages/opencover.portable). If we run the following command in PowerShell to install OpenCover via Chocolatey, \n\n```powershell\nchoco install opencover.portable\n```\n\nthe OpenCover commandline will become available.\n\nGeneration of coverage report is slighly different depending on the .NET platform of your test projects.\n\n#### .NET Framework project\n\n##### xUnit\n\nFirst install the xUnit console runner via [Nuget](https://www.nuget.org/packages/xunit.runner.console/2.3.0-beta1-build3642) or [Chocolatey](https://chocolatey.org/packages/XUnit). If we run the following in PowerShell to install xUnit via Chocolatey\n\n```powershell\nchoco install xunit\n```\n\nand execute the following in your solution's root,\n\n```powershell\nOpenCover.Console.exe -register:user -target:\"xunit.console.x86.exe\" -targetargs:\".\\MyUnitTests\\bin\\Debug\\MyUnitTests.dll -noshadow\" -filter:\"+[UnitTestTargetProject*]* -[MyUnitTests*]*\" -output:\".\\MyProject_coverage.xml\"\n```\n\nThen a coverage report will be generated.\n\n##### MSTest\n\nExecute the following in your solution's root,\n\n```powershell\nOpenCover.Console.exe -register:user -target:\"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\MSTest.exe\" -targetargs:\"/testcontainer:\"\".\\MyUnitTests\\bin\\Debug\\MyUnitTests.dll\" -filter:\"+[UnitTestTargetProject*]* -[MyUnitTests*]*\" -output:\".\\MyProject_coverage.xml\"\n```\n\nwhere you may need to change the `-target` flag to point to the correct version of MSTest.\n\n\n#### .NET Core project\n\nIf you don't yet have .NET Core SDK installed, install it\n\n```powershell\nchoco install dotnetcore-sdk\n```\n\nIn case of .NET Core projects, there is no difference between `MSTest` and `xUnit` for coverage report generation.\n\nMake sure all covered projects generate full pdb file (not only test projects), either through `\u003cDebugType\u003efull\u003c/DebugType\u003e` in the `.csproj` file or by using a Visual Studio: Project Properties \u003e Build \u003e Advanced \u003e Debugging information. By default, projects created by `dotnet` or by Visual Studio use a portable format for pdb files. Support for portable pdb format [hasn't been released in OpenCover yet](https://github.com/OpenCover/opencover/issues/610). If you fail to set full pdb, the `OpenCover` will print out a message notifying you that it has no results along with common causes.\n\nThe .NET Core test assembly can't be run by a `xunit.console.x86.exe`, because that tool works only with .NET Framework assemblies. The tests are run by `dotnet test` (possibly `dotnet xunit` if you [add dotnet-xunit](https://xunit.github.io/docs/getting-started-dotnet-core.html#create-project) CLI tool to your project).\n\nExecute the following command in your solution's root:\n\n```powershell\nOpenCover.Console.exe -register:user -target:\"C:/Program Files/dotnet/dotnet.exe\" -targetargs:test -filter:\"+[UnitTestTargetProject*]* -[MyUnitTests*]*\" -output:\".\\MyProject_coverage.xml\" -oldstyle\n```\n\nwhere `-oldstyle` switch is necessary, because .NET Core uses `System.Private.CoreLib` instead of `mscorlib` and thus `OpenCover` can't use  `mscorlib` for code instrumentation. You may also need to change the location of `dotnet.exe` to depending on the installed location.\n\n### Bash\nIn bash run the following to upload the report\n\n```bash\ncurl -s https://codecov.io/bash \u003e codecov\nchmod +x codecov\n./codecov -f \"MyProject_coverage.xml\" -t \u003cyour upload token\u003e\n```\n\n### Continous Integration\n\nThe previous examples assumed local development. More commonly, you'll use a CI service like [AppVeyor](https://www.appveyor.com/) or [TeamCity](https://www.jetbrains.com/teamcity/). For TeamCity builds please see the [documentation](https://github.com/codecov/codecov-exe#teamcity). For AppVeyor builds using xUnit, your yaml file would look something like\n\n#### Codecov-exe using Chocolatey\n\n```yaml\nimage: Visual Studio 2015\n\nbefore_build:\n- nuget restore\n- choco install opencover.portable\n- choco install codecov\n\nbuild:\n  project: CodecovProject.sln\n  verbosity: minimal\n\ntest_script:\n- OpenCover.Console.exe -register:user -target:\"%xunit20%\\xunit.console.x86.exe\" -targetargs:\".\\MyUnitTests\\bin\\Debug\\MyUnitTests.dll -noshadow\" -filter:\"+[UnitTestTargetProject*]* -[MyUnitTests*]*\" -output:\".\\MyProject_coverage.xml\"\n- codecov -f \"MyProject_coverage.xml\"\n```\n\n#### Codecov-exe using NuGet\n\nUsing this method you can cache your packages.config file.\n\n```yaml\nimage: Visual Studio 2015\n\nbefore_build:\n- nuget restore\n\nbuild:\n  project: CodecovProject.sln\n  verbosity: minimal\n\ntest_script:\n- .\\packages\\\u003cADD PATH\u003e\\OpenCover.Console.exe -register:user -target:\"%xunit20%\\xunit.console.x86.exe\" -targetargs:\".\\MyUnitTests\\bin\\Debug\\MyUnitTests.dll -noshadow\" -filter:\"+[UnitTestTargetProject*]* -[MyUnitTests*]*\" -output:\".\\MyProject_coverage.xml\"\n- .\\packages\\\u003cADD PATH\u003e\\codecov.exe -f \"MyProject_coverage.xml\"\n```\n\n## Caveats\n### Private Repo\nRepository tokens are required for (a) all private repos, (b) public repos not using Travis-CI, CircleCI, GitHub Actions, or AppVeyor. Find your repository token at Codecov and provide via appending `-t \u003cyour upload token\u003e` to you where you upload reports e.g. `.\\codecov -f \"MyProject_coverage.xml\" -t \u003cyour upload token\u003e`\n\n## Links\n- [Community Boards](https://community.codecov.io)\n- [Support](https://codecov.io/support)\n- [Documentation](https://docs.codecov.io)\n\n\n## License\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-csharp.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-csharp?ref=badge_large)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodecov%2Fexample-csharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodecov%2Fexample-csharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodecov%2Fexample-csharp/lists"}