---
title: "Source Context"
description: "Learn about setting up source bundles to show source code in stack traces on the Issue Details page."
url: https://docs.sentry.io/platforms/dotnet/guides/apple/data-management/debug-files/source-context/
---

# Source Context | Sentry for .NET for iOS, macOS, and Mac Catalyst

If Sentry has access to your application's source code, it can show snippets of code (*source context*) around the location of stack frames, which helps to quickly pinpoint problematic code.

For example, here's a stack trace from a .NET application. The source context contains the original C# source code of the application, with the location of the frame highlighted.

### [Source Bundles](https://docs.sentry.io/platforms/dotnet/guides/apple/data-management/debug-files/source-context.md#source-bundles)

Certain SDKs, such as the Python SDK, can resolve this source context automatically, because they have access to unobfuscated source code at runtime. By contrast, to get source context for compiled applications, the source code needs to be uploaded alongside the debug information files. The recommended way to do this is by using `sentry-cli`. See [Creating Source Bundles](https://docs.sentry.io/cli/dif.md#creating-source-bundles) for more information.

For .NET projects, you can [configure MSBuild](https://docs.sentry.io/platforms/dotnet/guides/apple/configuration/msbuild.md) to call `sentry-cli` automatically. Enable the `SentryUploadSources` property to create and upload source bundles automatically while uploading symbols.

Alternatively, you can embedded source code directly into .NET Portable PDB files by using the [`EmbedAllSources`](https://github.com/dotnet/sourcelink/blob/main/docs/README.md#embedallsources) property in your project file. After the PDBs have been uploaded to Sentry, the sources will be extracted from them automatically.

Also note that the similar `EmbedUntrackedSources` option is not yet supported, but may be added in the future. Referer to [this issue](https://github.com/getsentry/symbolic/issues/735) for details.

After they've been uploaded you can review and manage source bundles the same as any other debug information file. See [Managing Debug Information Files](https://docs.sentry.io/platforms/dotnet/guides/apple/data-management/debug-files.md#managing-debug-information-files). Source bundles will be tagged with `sources`, and will carry the same filename as the respective debug information file they were created from.
