Skip to content

Commit 98d41b8

Browse files
Use file scoped namespaces. (#77854)
* Change files * Revert * Revert
1 parent 8c91452 commit 98d41b8

File tree

1,873 files changed

+226332
-228205
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,873 files changed

+226332
-228205
lines changed

src/CodeStyle/CSharp/Tests/AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest_OptionHelpers.cs

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,46 @@
88
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
99
using Microsoft.CodeAnalysis.Options;
1010

11-
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics
11+
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics;
12+
13+
public abstract partial class AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest_NoEditor
1214
{
13-
public abstract partial class AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest_NoEditor
14-
{
15-
internal static (OptionKey2, object) SingleOption<T>(Option2<T> option, T enabled)
16-
=> (new OptionKey2(option), enabled);
15+
internal static (OptionKey2, object) SingleOption<T>(Option2<T> option, T enabled)
16+
=> (new OptionKey2(option), enabled);
1717

18-
internal (OptionKey2, object) SingleOption<T>(PerLanguageOption2<T> option, T value)
19-
=> (new OptionKey2(option, this.GetLanguage()), value);
18+
internal (OptionKey2, object) SingleOption<T>(PerLanguageOption2<T> option, T value)
19+
=> (new OptionKey2(option, this.GetLanguage()), value);
2020

21-
internal static (OptionKey2, object) SingleOption<T>(Option2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification)
22-
=> SingleOption(option, new CodeStyleOption2<T>(enabled, notification));
21+
internal static (OptionKey2, object) SingleOption<T>(Option2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification)
22+
=> SingleOption(option, new CodeStyleOption2<T>(enabled, notification));
2323

24-
internal static (OptionKey2, object) SingleOption<T>(Option2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
25-
=> (new OptionKey2(option), codeStyle);
24+
internal static (OptionKey2, object) SingleOption<T>(Option2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
25+
=> (new OptionKey2(option), codeStyle);
2626

27-
internal (OptionKey2, object) SingleOption<T>(PerLanguageOption2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification)
28-
=> SingleOption(option, new CodeStyleOption2<T>(enabled, notification));
27+
internal (OptionKey2, object) SingleOption<T>(PerLanguageOption2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification)
28+
=> SingleOption(option, new CodeStyleOption2<T>(enabled, notification));
2929

30-
internal (OptionKey2, object) SingleOption<T>(PerLanguageOption2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
31-
=> SingleOption(option, codeStyle, language: GetLanguage());
30+
internal (OptionKey2, object) SingleOption<T>(PerLanguageOption2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
31+
=> SingleOption(option, codeStyle, language: GetLanguage());
3232

33-
internal static (OptionKey2, object) SingleOption<T>(PerLanguageOption2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle, string language)
34-
=> (new OptionKey2(option, language), codeStyle);
33+
internal static (OptionKey2, object) SingleOption<T>(PerLanguageOption2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle, string language)
34+
=> (new OptionKey2(option, language), codeStyle);
3535

36-
internal OptionsCollection Option<T>(Option2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification)
37-
=> new OptionsCollection(GetLanguage()) { { option, enabled, notification } };
36+
internal OptionsCollection Option<T>(Option2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification)
37+
=> new OptionsCollection(GetLanguage()) { { option, enabled, notification } };
3838

39-
internal OptionsCollection Option<T>(Option2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
40-
=> new OptionsCollection(GetLanguage()) { { option, codeStyle } };
39+
internal OptionsCollection Option<T>(Option2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
40+
=> new OptionsCollection(GetLanguage()) { { option, codeStyle } };
4141

42-
internal OptionsCollection Option<T>(PerLanguageOption2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification)
43-
=> new OptionsCollection(GetLanguage()) { { option, enabled, notification } };
42+
internal OptionsCollection Option<T>(PerLanguageOption2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification)
43+
=> new OptionsCollection(GetLanguage()) { { option, enabled, notification } };
4444

45-
internal OptionsCollection Option<T>(PerLanguageOption2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
46-
=> new OptionsCollection(GetLanguage()) { { option, codeStyle } };
45+
internal OptionsCollection Option<T>(PerLanguageOption2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
46+
=> new OptionsCollection(GetLanguage()) { { option, codeStyle } };
4747

48-
internal OptionsCollection Option<T>(Option2<T> option, T value)
49-
=> new OptionsCollection(GetLanguage()) { { option, value } };
48+
internal OptionsCollection Option<T>(Option2<T> option, T value)
49+
=> new OptionsCollection(GetLanguage()) { { option, value } };
5050

51-
internal OptionsCollection Option<T>(PerLanguageOption2<T> option, T value)
52-
=> new OptionsCollection(GetLanguage()) { { option, value } };
53-
}
51+
internal OptionsCollection Option<T>(PerLanguageOption2<T> option, T value)
52+
=> new OptionsCollection(GetLanguage()) { { option, value } };
5453
}

src/CodeStyle/Core/CodeFixes/Host/Mef/CodeStyleHostLanguageServices.MefHostExportProvider.cs

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,42 @@
66
using System.Runtime.CompilerServices;
77
using Microsoft.CodeAnalysis.Host.Mef;
88

9-
namespace Microsoft.CodeAnalysis.Host
9+
namespace Microsoft.CodeAnalysis.Host;
10+
11+
internal sealed partial class CodeStyleHostLanguageServices : HostLanguageServices
1012
{
11-
internal sealed partial class CodeStyleHostLanguageServices : HostLanguageServices
12-
{
13-
private static readonly ConditionalWeakTable<HostLanguageServices, CodeStyleHostLanguageServices> s_mappedLanguageServices =
14-
new ConditionalWeakTable<HostLanguageServices, CodeStyleHostLanguageServices>();
15-
private static readonly ConditionalWeakTable<string, MefHostExportProvider> s_exportProvidersByLanguageCache =
16-
new ConditionalWeakTable<string, MefHostExportProvider>();
13+
private static readonly ConditionalWeakTable<HostLanguageServices, CodeStyleHostLanguageServices> s_mappedLanguageServices =
14+
new ConditionalWeakTable<HostLanguageServices, CodeStyleHostLanguageServices>();
15+
private static readonly ConditionalWeakTable<string, MefHostExportProvider> s_exportProvidersByLanguageCache =
16+
new ConditionalWeakTable<string, MefHostExportProvider>();
1717

18-
private readonly HostLanguageServices _hostLanguageServices;
19-
private readonly HostLanguageServices _codeStyleLanguageServices;
18+
private readonly HostLanguageServices _hostLanguageServices;
19+
private readonly HostLanguageServices _codeStyleLanguageServices;
2020

21-
[SuppressMessage("ApiDesign", "RS0030:Do not used banned APIs", Justification = "This is the replacement API")]
22-
private CodeStyleHostLanguageServices(HostLanguageServices hostLanguageServices)
23-
{
24-
_hostLanguageServices = hostLanguageServices;
21+
[SuppressMessage("ApiDesign", "RS0030:Do not used banned APIs", Justification = "This is the replacement API")]
22+
private CodeStyleHostLanguageServices(HostLanguageServices hostLanguageServices)
23+
{
24+
_hostLanguageServices = hostLanguageServices;
2525

26-
var exportProvider = s_exportProvidersByLanguageCache.GetValue(hostLanguageServices.Language, MefHostExportProvider.Create);
27-
_codeStyleLanguageServices = new MefWorkspaceServices(exportProvider, hostLanguageServices.WorkspaceServices.Workspace)
28-
.GetLanguageServices(hostLanguageServices.Language);
29-
}
26+
var exportProvider = s_exportProvidersByLanguageCache.GetValue(hostLanguageServices.Language, MefHostExportProvider.Create);
27+
_codeStyleLanguageServices = new MefWorkspaceServices(exportProvider, hostLanguageServices.WorkspaceServices.Workspace)
28+
.GetLanguageServices(hostLanguageServices.Language);
29+
}
3030

31-
public static CodeStyleHostLanguageServices? GetMappedCodeStyleLanguageServices(HostLanguageServices? hostLanguageServices)
32-
=> hostLanguageServices != null ? s_mappedLanguageServices.GetValue(hostLanguageServices, Create) : null;
31+
public static CodeStyleHostLanguageServices? GetMappedCodeStyleLanguageServices(HostLanguageServices? hostLanguageServices)
32+
=> hostLanguageServices != null ? s_mappedLanguageServices.GetValue(hostLanguageServices, Create) : null;
3333

34-
public static CodeStyleHostLanguageServices GetRequiredMappedCodeStyleLanguageServices(HostLanguageServices hostLanguageServices)
35-
=> s_mappedLanguageServices.GetValue(hostLanguageServices, Create);
34+
public static CodeStyleHostLanguageServices GetRequiredMappedCodeStyleLanguageServices(HostLanguageServices hostLanguageServices)
35+
=> s_mappedLanguageServices.GetValue(hostLanguageServices, Create);
3636

37-
private static CodeStyleHostLanguageServices Create(HostLanguageServices hostLanguageServices)
38-
=> new CodeStyleHostLanguageServices(hostLanguageServices);
37+
private static CodeStyleHostLanguageServices Create(HostLanguageServices hostLanguageServices)
38+
=> new CodeStyleHostLanguageServices(hostLanguageServices);
3939

40-
public override HostWorkspaceServices WorkspaceServices => _hostLanguageServices.WorkspaceServices;
40+
public override HostWorkspaceServices WorkspaceServices => _hostLanguageServices.WorkspaceServices;
4141

42-
public override string Language => _hostLanguageServices.Language;
42+
public override string Language => _hostLanguageServices.Language;
4343

44-
public override TLanguageService? GetService<TLanguageService>()
45-
where TLanguageService : default
46-
=> _codeStyleLanguageServices.GetService<TLanguageService>() ?? _hostLanguageServices.GetService<TLanguageService>();
47-
}
44+
public override TLanguageService? GetService<TLanguageService>()
45+
where TLanguageService : default
46+
=> _codeStyleLanguageServices.GetService<TLanguageService>() ?? _hostLanguageServices.GetService<TLanguageService>();
4847
}

src/CodeStyle/Core/CodeFixes/Host/Mef/CodeStyleHostLanguageServices.cs

Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,59 +14,58 @@
1414
using Microsoft.CodeAnalysis.Host.Mef;
1515
using Microsoft.CodeAnalysis.PooledObjects;
1616

17-
namespace Microsoft.CodeAnalysis.Host
17+
namespace Microsoft.CodeAnalysis.Host;
18+
19+
internal sealed partial class CodeStyleHostLanguageServices : HostLanguageServices
1820
{
19-
internal sealed partial class CodeStyleHostLanguageServices : HostLanguageServices
21+
private sealed class MefHostExportProvider : IMefHostExportProvider
2022
{
21-
private sealed class MefHostExportProvider : IMefHostExportProvider
22-
{
23-
private readonly CompositionHost _compositionContext;
24-
25-
private MefHostExportProvider(CompositionHost compositionContext)
26-
=> _compositionContext = compositionContext;
23+
private readonly CompositionHost _compositionContext;
2724

28-
public static MefHostExportProvider Create(string languageName)
29-
{
30-
var assemblies = CreateAssemblies(languageName);
31-
var compositionConfiguration = new ContainerConfiguration().WithAssemblies(assemblies);
32-
return new MefHostExportProvider(compositionConfiguration.CreateContainer());
33-
}
25+
private MefHostExportProvider(CompositionHost compositionContext)
26+
=> _compositionContext = compositionContext;
3427

35-
private static ImmutableArray<Assembly> CreateAssemblies(string languageName)
36-
{
37-
using var disposer = ArrayBuilder<string>.GetInstance(out var assemblyNames);
28+
public static MefHostExportProvider Create(string languageName)
29+
{
30+
var assemblies = CreateAssemblies(languageName);
31+
var compositionConfiguration = new ContainerConfiguration().WithAssemblies(assemblies);
32+
return new MefHostExportProvider(compositionConfiguration.CreateContainer());
33+
}
3834

39-
assemblyNames.Add("Microsoft.CodeAnalysis.CodeStyle.Fixes");
40-
switch (languageName)
41-
{
42-
case LanguageNames.CSharp:
43-
assemblyNames.Add("Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes");
44-
break;
35+
private static ImmutableArray<Assembly> CreateAssemblies(string languageName)
36+
{
37+
using var disposer = ArrayBuilder<string>.GetInstance(out var assemblyNames);
4538

46-
case LanguageNames.VisualBasic:
47-
assemblyNames.Add("Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes");
48-
break;
49-
}
39+
assemblyNames.Add("Microsoft.CodeAnalysis.CodeStyle.Fixes");
40+
switch (languageName)
41+
{
42+
case LanguageNames.CSharp:
43+
assemblyNames.Add("Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes");
44+
break;
5045

51-
return MefHostServices.DefaultAssemblies.Concat(
52-
MefHostServicesHelpers.LoadNearbyAssemblies(assemblyNames));
46+
case LanguageNames.VisualBasic:
47+
assemblyNames.Add("Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes");
48+
break;
5349
}
5450

55-
IEnumerable<Lazy<TExtension>> IMefHostExportProvider.GetExports<TExtension>()
56-
=> _compositionContext.GetExports<TExtension>().Select(e => new Lazy<TExtension>(() => e));
51+
return MefHostServices.DefaultAssemblies.Concat(
52+
MefHostServicesHelpers.LoadNearbyAssemblies(assemblyNames));
53+
}
5754

58-
IEnumerable<Lazy<TExtension, TMetadata>> IMefHostExportProvider.GetExports<TExtension, TMetadata>()
59-
{
60-
var importer = new WithMetadataImporter<TExtension, TMetadata>();
61-
_compositionContext.SatisfyImports(importer);
62-
return importer.Exports;
63-
}
55+
IEnumerable<Lazy<TExtension>> IMefHostExportProvider.GetExports<TExtension>()
56+
=> _compositionContext.GetExports<TExtension>().Select(e => new Lazy<TExtension>(() => e));
6457

65-
private sealed class WithMetadataImporter<TExtension, TMetadata>
66-
{
67-
[ImportMany]
68-
public IEnumerable<Lazy<TExtension, TMetadata>> Exports { get; set; }
69-
}
58+
IEnumerable<Lazy<TExtension, TMetadata>> IMefHostExportProvider.GetExports<TExtension, TMetadata>()
59+
{
60+
var importer = new WithMetadataImporter<TExtension, TMetadata>();
61+
_compositionContext.SatisfyImports(importer);
62+
return importer.Exports;
63+
}
64+
65+
private sealed class WithMetadataImporter<TExtension, TMetadata>
66+
{
67+
[ImportMany]
68+
public IEnumerable<Lazy<TExtension, TMetadata>> Exports { get; set; }
7069
}
7170
}
7271
}

src/CodeStyle/Core/CodeFixes/LanguageServices/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.SemanticModelWorkspaceService.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,22 @@
77
using Microsoft.CodeAnalysis.Host.Mef;
88
using Microsoft.CodeAnalysis.Shared.Extensions;
99

10-
namespace Microsoft.CodeAnalysis.SemanticModelReuse
10+
namespace Microsoft.CodeAnalysis.SemanticModelReuse;
11+
12+
internal partial class SemanticModelReuseWorkspaceServiceFactory : IWorkspaceServiceFactory
1113
{
12-
internal partial class SemanticModelReuseWorkspaceServiceFactory : IWorkspaceServiceFactory
14+
private sealed class SemanticModelReuseWorkspaceService : ISemanticModelReuseWorkspaceService
1315
{
14-
private sealed class SemanticModelReuseWorkspaceService : ISemanticModelReuseWorkspaceService
16+
public SemanticModelReuseWorkspaceService(Workspace _)
1517
{
16-
public SemanticModelReuseWorkspaceService(Workspace _)
17-
{
18-
}
18+
}
1919

20-
public ValueTask<SemanticModel> ReuseExistingSpeculativeModelAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
21-
{
22-
// TODO: port the GetSemanticModelForNodeAsync implementation from Workspaces layer,
23-
// which currently relies on a bunch of internal APIs.
24-
// For now, we fall back to the public API to fetch document's SemanticModel.
25-
return document.GetRequiredSemanticModelAsync(cancellationToken);
26-
}
20+
public ValueTask<SemanticModel> ReuseExistingSpeculativeModelAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
21+
{
22+
// TODO: port the GetSemanticModelForNodeAsync implementation from Workspaces layer,
23+
// which currently relies on a bunch of internal APIs.
24+
// For now, we fall back to the public API to fetch document's SemanticModel.
25+
return document.GetRequiredSemanticModelAsync(cancellationToken);
2726
}
2827
}
2928
}

0 commit comments

Comments
 (0)