MemoryCache.Analyzers 0.1.0-alpha

This is a prerelease version of MemoryCache.Analyzers.
dotnet add package MemoryCache.Analyzers --version 0.1.0-alpha
                    
NuGet\Install-Package MemoryCache.Analyzers -Version 0.1.0-alpha
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MemoryCache.Analyzers" Version="0.1.0-alpha">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MemoryCache.Analyzers" Version="0.1.0-alpha" />
                    
Directory.Packages.props
<PackageReference Include="MemoryCache.Analyzers">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MemoryCache.Analyzers --version 0.1.0-alpha
                    
#r "nuget: MemoryCache.Analyzers, 0.1.0-alpha"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MemoryCache.Analyzers@0.1.0-alpha
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MemoryCache.Analyzers&version=0.1.0-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=MemoryCache.Analyzers&version=0.1.0-alpha&prerelease
                    
Install as a Cake Tool

MemoryCache.Analyzers Rules

This document provides details about the rules included in the MemoryCache.Analyzers package.

Purpose

MemoryCache.Analyzers is a collection of Roslyn analyzers that help developers identify and fix issues related to caching APIs in .NET applications. The analyzers focus on ensuring proper usage of caching APIs and promoting best practices for performance, maintainability, and compatibility.

Rule Categories

Rules are organized into the following categories:

  • Compatibility: Rules that identify code that may have compatibility issues between different .NET versions

Rule Severity

Each rule has a default severity level:

  • Error: Indicates code that is likely to cause a significant issue
  • Warning: Indicates code that may cause issues but might be intentional in some cases
  • Info: Indicates code that could be improved but isn't likely to cause issues
  • Hidden: Informational rules that aren't shown by default

Rules

ID Title Category Severity Description
SRC1000 Avoid System.Runtime.Caching.MemoryCache in .NET Core+ Compatibility Warning System.Runtime.Caching.MemoryCache is a compatibility bridge for porting from .NET Framework. Prefer Microsoft.Extensions.Caching.Memory in .NET Core+.

Using the Analyzers

Installation

Install the analyzers via NuGet:

dotnet add package MemoryCache.Analyzers

Configuration

You can configure the severity of analyzer rules in your project using an .editorconfig file. For example:

# Increase the severity of SRC1000 from a warning to an error
dotnet_diagnostic.SRC1000.severity = error

# Disable SRC1000
dotnet_diagnostic.SRC1000.severity = none

Building and Testing

To build the analyzers:

dotnet build

To run the tests:

dotnet test

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has 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
0.1.0-alpha 60 6/20/2025