Microsoft.Extensions.AuditReports
10.5.0
Prefix Reserved
dotnet add package Microsoft.Extensions.AuditReports --version 10.5.0
NuGet\Install-Package Microsoft.Extensions.AuditReports -Version 10.5.0
<PackageReference Include="Microsoft.Extensions.AuditReports" Version="10.5.0" />
<PackageVersion Include="Microsoft.Extensions.AuditReports" Version="10.5.0" />
<PackageReference Include="Microsoft.Extensions.AuditReports" />
paket add Microsoft.Extensions.AuditReports --version 10.5.0
#r "nuget: Microsoft.Extensions.AuditReports, 10.5.0"
#:package Microsoft.Extensions.AuditReports@10.5.0
#addin nuget:?package=Microsoft.Extensions.AuditReports&version=10.5.0
#tool nuget:?package=Microsoft.Extensions.AuditReports&version=10.5.0
Microsoft.Extensions.AuditReports
Produces reports about the code being compiled which are useful during privacy and telemetry audits.
Install the package
From the command-line:
dotnet add package Microsoft.Extensions.AuditReports
Or directly in the C# project file:
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.AuditReports" Version="[CURRENTVERSION]" />
</ItemGroup>
Available reports
The following reports are available in this package:
- Metrics: Reports on the use of source-generated metric definitions in the code.
- Compliance: Reports on the use of privacy-sensitive data in the code, including source-generated logging methods.
- Metadata : Is a Combination of both reports above.
The table below shows various MSBuild properties that you can use to control the behavior of the reports generation:
| Metrics report generator | Compliance report generator | Metadata report generator | Description |
|---|---|---|---|
<GenerateMetricsReport> |
<GenerateComplianceReport> |
<GenerateMetadataReport> |
Controls whether the report is generated. |
<MetricsReportOutputPath> |
<ComplianceReportOutputPath> |
<MetadataReportOutputPath> |
The path to the directory where the report will be generated. |
The file names of the reports are defined by the corresponding report generator.
The metrics report will be generated in a file named MetricsReport.json.
The compliance report will be generated in a file named ComplianceReport.json.
For example, to generate a compliance report, you can add the following to your project file:
<PropertyGroup>
<GenerateComplianceReport>true</GenerateComplianceReport>
<ComplianceReportOutputPath>C:\AuditReports</ComplianceReportOutputPath>
</PropertyGroup>
Both report generators follow the same strategy if you don't provide a value for the property with the output path (ComplianceReportOutputPath or MetricsReportOutputPath).
In that case, the report path will be determined via the following strategy:
- If the
$(OutputPath)property is defined and it's an absolute path, the report will be generated in that directory. - If both
$(OutputPath)and$(ProjectDir)properties are defined and the$(OutputPath)property contains a relative path, the report will be generated in the$(ProjectDir)\$(OutputPath)directory.
If none of the above conditions are met, the report will not be generated and the diagnostic message will be emitted.
Example of a compliance report
Let's assume we have a project with a class that contains privacy-sensitive data:
namespace ComplianceTesting
{
internal sealed class User
{
internal User(string name, DateTimeOffset registeredAt)
{
Name = name;
RegisteredAt = registeredAt;
}
[PrivateData]
public string Name { get; }
public DateTimeOffset RegisteredAt { get; }
}
}
Microsoft.Extensions.Compliance.Testing package contains a definition for [PrivateData] attribute, we use it here for demonstration purposes only.
A compliance report for the code listed above might look like this:
{
"Name": "MyAssembly",
"Types": [
{
"Name": "ComplianceTesting.User",
"Members": [
{
"Name": "Name",
"Type": "string",
"File": "C:\\source\\samples\\src\\MyAssembly\\User.cs",
"Line": "12",
"Classifications": [
{
"Name": "PrivateData"
}
]
}
]
}
]
}
Example of a metrics report
Let's assume we have a project with a class that contains a source-generated metric definition:
internal sealed partial class Metric
{
internal static class Tags
{
/// <summary>
/// The target of the metric, e.g. the name of the service or the name of the method.
/// </summary>
public const string Target = nameof(Target);
/// <summary>
/// The reason for the failure, e.g. the exception message or the HTTP status code.
/// </summary>
public const string FailureReason = nameof(FailureReason);
}
/// <summary>
/// The counter metric for the number of failed requests.
/// </summary>
[Counter(Tags.Target, Tags.FailureReason)]
public static partial FailedRequestCounter CreateFailedRequestCounter(Meter meter);
}
A metrics report for the code listed above might look like this:
[
{
"MyAssembly":
[
{
"MetricName": "FailedRequestCounter",
"MetricDescription": "The counter metric for the number of failed requests.",
"InstrumentName": "Counter",
"Dimensions": {
"Target": "The target of the metric, e.g. the name of the service or the name of the method.",
"FailureReason": "The reason for the failure, e.g. the exception message or the HTTP status code."
}
}
]
}
]
Example of a metadata report
Let's assume we have a project with a class that contains a metric definition:
internal sealed partial class Metric
{
internal static class Tags
{
/// <summary>
/// The target of the metric, e.g. the name of the service or the name of the method.
/// </summary>
public const string Target = nameof(Target);
/// <summary>
/// The reason for the failure, e.g. the exception message or the HTTP status code.
/// </summary>
public const string FailureReason = nameof(FailureReason);
}
/// <summary>
/// The counter metric for the number of failed requests.
/// </summary>
[Counter(Tags.Target, Tags.FailureReason)]
public static partial FailedRequestCounter CreateFailedRequestCounter(Meter meter);
}
and let's also assume we have a project with a class that contains privacy-sensitive data:
namespace ComplianceTesting
{
internal sealed class User
{
internal User(string name, DateTimeOffset registeredAt)
{
Name = name;
RegisteredAt = registeredAt;
}
[PrivateData]
public string Name { get; }
public DateTimeOffset RegisteredAt { get; }
}
}
Microsoft.Extensions.Compliance.Testing package contains a definition for [PrivateData] attribute, we use it here for demonstration purposes only.
A metadata report for the code listed above might look like this:
{ "Name": "MyAssembly", "ComplianceReport":
{
"Types": [
{
"Name": "ComplianceTesting.User",
"Members": [
{
"Name": "Name",
"Type": "string",
"File": "C:\\source\\samples\\src\\MyAssembly\\User.cs",
"Line": "12",
"Classifications": [
{
"Name": "PrivateData"
}
]
}
]
}
]
} , "MetricReport": [
{
"MetricName": "FailedRequestCounter",
"MetricDescription": "The counter metric for the number of failed requests.",
"InstrumentName": "Counter",
"Dimensions": {
"Target": "The target of the metric, e.g. the name of the service or the name of the method.",
"FailureReason": "The reason for the failure, e.g. the exception message or the HTTP status code."
}
}
] }
Feedback & Contributing
We welcome feedback and contributions in our GitHub repo.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.5.0 | 106 | 4/15/2026 |
| 10.4.0 | 269 | 3/10/2026 |
| 10.3.0 | 630 | 2/10/2026 |
| 10.2.0 | 849 | 1/13/2026 |
| 10.1.0 | 589 | 12/9/2025 |
| 10.0.0 | 386 | 11/11/2025 |
| 9.10.0 | 631 | 10/14/2025 |
| 9.9.0 | 278 | 9/9/2025 |
| 9.8.0 | 246 | 8/12/2025 |
| 9.7.0 | 242 | 7/8/2025 |
| 9.6.0 | 456 | 6/10/2025 |
| 9.5.0 | 489 | 5/13/2025 |
| 9.4.0 | 318 | 4/8/2025 |
| 9.3.0 | 316 | 3/11/2025 |
| 9.2.0 | 300 | 2/11/2025 |
| 9.1.0 | 1,307 | 1/14/2025 |
| 9.0.0 | 499 | 11/12/2024 |
| 9.0.0-preview.9.24507.7 | 195 | 10/8/2024 |
| 9.0.0-preview.8.24460.1 | 112 | 9/10/2024 |
| 8.10.0 | 1,063 | 10/8/2024 |