Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove allocations in ErorrFacts #75234

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
.nuget/
.complog/
/MSBuild_Logs/
BenchmarkDotNet.Artifacts/

# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
!packages/*/build/
Expand Down
3 changes: 2 additions & 1 deletion Compilers.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"src\\Compilers\\Core\\Portable\\Microsoft.CodeAnalysis.csproj",
"src\\Compilers\\Core\\RebuildTest\\Microsoft.CodeAnalysis.Rebuild.UnitTests.csproj",
"src\\Compilers\\Core\\Rebuild\\Microsoft.CodeAnalysis.Rebuild.csproj",
"src\\Compilers\\Core\\CompilerBenchmarks\\CompilerBenchmarks.csproj",
"src\\Compilers\\Extension\\Roslyn.Compilers.Extension.csproj",
"src\\Compilers\\Server\\VBCSCompilerTests\\VBCSCompiler.UnitTests.csproj",
"src\\Compilers\\Server\\VBCSCompiler\\AnyCpu\\VBCSCompiler.csproj",
Expand Down Expand Up @@ -84,4 +85,4 @@
"src\\Workspaces\\VisualBasic\\Portable\\Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj"
]
}
}
}
8 changes: 8 additions & 0 deletions Roslyn.sln
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31319.15
Expand Down Expand Up @@ -571,6 +572,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ExternalAccess", "ExternalA
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.LanguageServer.Protocol.Test.Utilities", "src\LanguageServer\Protocol.TestUtilities\Microsoft.CodeAnalysis.LanguageServer.Protocol.Test.Utilities.csproj", "{7465CE63-A7B7-475F-8C57-48D2F8BC665A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompilerBenchmarks", "src\Compilers\Core\CompilerBenchmarks\CompilerBenchmarks.csproj", "{1B336627-94DA-4B93-98CB-49CD133D2CB3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1405,6 +1408,10 @@ Global
{7465CE63-A7B7-475F-8C57-48D2F8BC665A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7465CE63-A7B7-475F-8C57-48D2F8BC665A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7465CE63-A7B7-475F-8C57-48D2F8BC665A}.Release|Any CPU.Build.0 = Release|Any CPU
{1B336627-94DA-4B93-98CB-49CD133D2CB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B336627-94DA-4B93-98CB-49CD133D2CB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B336627-94DA-4B93-98CB-49CD133D2CB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B336627-94DA-4B93-98CB-49CD133D2CB3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1668,6 +1675,7 @@ Global
{1AE9182D-B03E-4B00-B32E-37AE01715F57} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6}
{806F0C6F-3640-4C92-8D55-6767B1535467} = {D449D505-CC6A-4E0B-AF1B-976E2D0AE67A}
{7465CE63-A7B7-475F-8C57-48D2F8BC665A} = {D449D505-CC6A-4E0B-AF1B-976E2D0AE67A}
{1B336627-94DA-4B93-98CB-49CD133D2CB3} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {604E6B91-7BC0-4126-AE07-D4D2FEFC3D29}
Expand Down
4 changes: 2 additions & 2 deletions eng/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@
<!--
Testing.
-->
<PackageVersion Include="BenchmarkDotNet" Version="0.13.0" />
<PackageVersion Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.0" />
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.14.0" />
<PackageVersion Include="BasicUndo" Version="0.9.3" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" Version="$(MicrosoftCodeAnalysisTestingVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="$(MicrosoftCodeAnalysisTestingVersion)" />
Expand Down
10 changes: 4 additions & 6 deletions src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ namespace Microsoft.CodeAnalysis.CSharp
{
internal static partial class ErrorFacts
{
private const string s_titleSuffix = "_Title";
private const string s_descriptionSuffix = "_Description";
private static readonly Lazy<ImmutableDictionary<ErrorCode, string>> s_categoriesMap = new Lazy<ImmutableDictionary<ErrorCode, string>>(CreateCategoriesMap);
public static readonly ImmutableHashSet<string> NullableWarnings;

Expand Down Expand Up @@ -140,24 +138,24 @@ public static string GetMessage(MessageID code, CultureInfo culture)
/// <remarks>Don't call this during a parse--it loads resources</remarks>
public static string GetMessage(ErrorCode code, CultureInfo culture)
{
string message = ResourceManager.GetString(code.ToString(), culture);
string message = ResourceManager.GetString(ToString(code), culture);
RoslynDebug.Assert(!string.IsNullOrEmpty(message), $"{code}");
return message;
}

public static LocalizableResourceString GetMessageFormat(ErrorCode code)
{
return new LocalizableResourceString(code.ToString(), ResourceManager, typeof(ErrorFacts));
return new LocalizableResourceString(ToString(code), ResourceManager, typeof(ErrorFacts));
}

public static LocalizableResourceString GetTitle(ErrorCode code)
{
return new LocalizableResourceString(code.ToString() + s_titleSuffix, ResourceManager, typeof(ErrorFacts));
return new LocalizableResourceString(ToStringWithTitle(code), ResourceManager, typeof(ErrorFacts));
}

public static LocalizableResourceString GetDescription(ErrorCode code)
{
return new LocalizableResourceString(code.ToString() + s_descriptionSuffix, ResourceManager, typeof(ErrorFacts));
return new LocalizableResourceString(ToStringWithDescription(code), ResourceManager, typeof(ErrorFacts));
}

public static string GetHelpLink(ErrorCode code)
Expand Down
Loading
Loading