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

Switch to static local functions #73343

Merged
merged 2 commits into from
May 5, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ private static string[] GetSupportedDiagnosticIdsForCodeCleanupService(string la
var supportedDiagnostics = enabledDiagnostics.Diagnostics.SelectMany(x => x.DiagnosticIds).ToArray();
return supportedDiagnostics;

EditorTestWorkspace GetTestWorkspaceForLanguage(string language)
static EditorTestWorkspace GetTestWorkspaceForLanguage(string language)
{
if (language == LanguageNames.CSharp)
{
Expand Down
4 changes: 2 additions & 2 deletions src/EditorFeatures/Core.Wpf/Lightup/LightupHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ TResult FallbackAccessor(T instance)

private static Action<T> CreateFallbackAction<T>()
{
void FallbackAction(T instance)
static void FallbackAction(T instance)
{
if (instance == null)
{
Expand All @@ -392,7 +392,7 @@ void FallbackAction(T instance)

private static Action<T, TArg> CreateFallbackAction<T, TArg>()
{
void FallbackAction(T instance, TArg arg)
static void FallbackAction(T instance, TArg arg)
{
if (instance == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ private static void AddAnalyzerConfigDocumentWithOptions(EditorTestWorkspace wor
Assert.True(applied);
return;

string GenerateAnalyzerConfigText(OptionsCollectionAlias options)
static string GenerateAnalyzerConfigText(OptionsCollectionAlias options)
{
var textBuilder = new StringBuilder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ public void ShouldTryAgain_ObjectDisposedException()
[Fact]
public void ShouldTryAgain_RPC_E_DISCONNECTED()
{
IntPtr gmdbpf(AssemblyIdentity assemblyIdentity, out uint uSize)
static IntPtr gmdbpf(AssemblyIdentity assemblyIdentity, out uint uSize)
{
Marshal.ThrowExceptionForHR(unchecked((int)0x80010108));
throw ExceptionUtilities.Unreachable();
Expand All @@ -489,7 +489,7 @@ IntPtr gmdbpf(AssemblyIdentity assemblyIdentity, out uint uSize)
[Fact]
public void ShouldTryAgain_Exception()
{
IntPtr gmdbpf(AssemblyIdentity assemblyIdentity, out uint uSize)
static IntPtr gmdbpf(AssemblyIdentity assemblyIdentity, out uint uSize)
{
throw new Exception();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ internal static void VerifyResolutionRequests(EEMetadataReferenceResolver resolv
actual.Free();
expected.Free();

void sort(ArrayBuilder<(AssemblyIdentity, AssemblyIdentity, int)> builder)
static void sort(ArrayBuilder<(AssemblyIdentity, AssemblyIdentity, int)> builder)
{
builder.Sort((x, y) => AssemblyIdentityComparer.SimpleNameComparer.Compare(x.Item1.GetDisplayName(), y.Item1.GetDisplayName()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private static (PropertyPatternClauseSyntax?, ExpressionSyntax?) TryGetPropertyP

return default;

bool IsExtendedPropertyPattern(MemberAccessExpressionSyntax memberAccess, [NotNullWhen(true)] out PropertyPatternClauseSyntax? propertyPatternClause)
static bool IsExtendedPropertyPattern(MemberAccessExpressionSyntax memberAccess, [NotNullWhen(true)] out PropertyPatternClauseSyntax? propertyPatternClause)
{
while (memberAccess.Parent.IsKind(SyntaxKind.SimpleMemberAccessExpression))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ class C : IComparable<C>, IComparable<int>
[||]
}
""";
string GetFixedCode(string type)
static string GetFixedCode(string type)
=> $@"using System;

class C : IComparable<C>, IComparable<int>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ private static void AddAnalyzerConfigDocumentWithOptions(TestWorkspace workspace
Assert.True(applied);
return;

string GenerateAnalyzerConfigText(OptionsCollectionAlias options)
static string GenerateAnalyzerConfigText(OptionsCollectionAlias options)
{
var textBuilder = new StringBuilder();

Expand Down
2 changes: 1 addition & 1 deletion src/Tools/BuildBoss/SolutionCheckerUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private bool CheckDuplicate(TextWriter textWriter, out Dictionary<ProjectKey, So
/// </summary>
private bool CheckProjectSystemGuid(TextWriter textWriter, IEnumerable<SolutionProjectData> dataList)
{
Guid getExpectedGuid(ProjectData data)
static Guid getExpectedGuid(ProjectData data)
{
var util = data.ProjectUtil;
switch (ProjectEntryUtil.GetProjectFileType(data.FilePath))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public async Task VerifyTagsAsync<TTag>(int expectedCount, CancellationToken can

var view = await GetActiveTextViewAsync(cancellationToken);

bool filterTag(IMappingTagSpan<ITag> tag)
static bool filterTag(IMappingTagSpan<ITag> tag)
{
return tag.Tag.GetType().Equals(typeof(TTag));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ public override string ToString()
Guids={modules.Select(m => GetMetadataGuid(m).ToString()).Join(",")}
""";

ImmutableArray<ModuleMetadata> GetModules(Metadata? metadata)
static ImmutableArray<ModuleMetadata> GetModules(Metadata? metadata)
{
if (metadata is AssemblyMetadata assemblyMetadata)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Workspaces/CoreTest/ObjectSerializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ private static void TestRoundTripChar(Char ch)
[Fact]
public void TestRoundTripGuid()
{
void test(Guid guid)
static void test(Guid guid)
{
TestRoundTrip(guid, (w, v) => w.WriteGuid(v), r => r.ReadGuid());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public async Task WithReferencesMethodCorrectlyUpdatesWithEqualReferences(TestHo
// reference with another reference that's equal, we correctly update generators. We'll have the underlying generators
// be different since two AnalyzerFileReferences that are value equal but different instances would have their own generators as well.
const string SharedPath = "Z:\\Generator.dll";
ISourceGenerator CreateGenerator() => new SingleFileTestGenerator("// StaticContent", hintName: "generated");
static ISourceGenerator CreateGenerator() => new SingleFileTestGenerator("// StaticContent", hintName: "generated");

var analyzerReference1 = new TestGeneratorReferenceWithFilePathEquality(CreateGenerator(), SharedPath);
var analyzerReference2 = new TestGeneratorReferenceWithFilePathEquality(CreateGenerator(), SharedPath);
Expand Down
Loading