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

Move Options and CodeStyle APIs to shared layer #42323

Merged
59 commits merged into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
6692e76
Move common Options and CodeStyle related public and internal types i…
mavasani Mar 10, 2020
cd860f7
Add API overloads for new shared layer options types to options servi…
mavasani Mar 10, 2020
a2c78bd
Make similar changes to FormattingOptions and C# FormattingOptions - …
mavasani Mar 10, 2020
762c09c
Some more follow-up changes in CodeStyle related files
mavasani Mar 10, 2020
2848a31
Updating formatting rules and engine to use the shared layer formatti…
mavasani Mar 10, 2020
70b4089
VB CodeStyle related changes. We still haven't moved VB CodeStyle opt…
mavasani Mar 10, 2020
3ba9025
Move bunch of options in Workspaces and Features layers to use the ne…
mavasani Mar 10, 2020
7077431
Move the base CodeStyle and naming analyzer to the new options relate…
mavasani Mar 10, 2020
30b4e99
Some cleanup
mavasani Mar 10, 2020
e96fd8f
VB formatting engine and rules moved to new formatting options API in…
mavasani Mar 10, 2020
e182acd
Move all the shared layer analyzers to use the new options and code s…
mavasani Mar 10, 2020
2143656
Move all the IDE (Features layer) analyzer to the new options and cod…
mavasani Mar 10, 2020
a9da22c
Add BannedSymbols.txt for Features layer to prevent accidental use of…
mavasani Mar 10, 2020
b9cf84d
Changes to CodeStyle layer to delete linked files and trim public APIs
mavasani Mar 10, 2020
00b3593
Move EditorFeatures layer to new options types
mavasani Mar 10, 2020
6e1e5dd
Move VS layer and some of the options it depends on to the new intern…
mavasani Mar 10, 2020
74b90a8
Move part of EditorConfigFileGenerator that can serialize naming opti…
mavasani Mar 10, 2020
f1b4348
Split the CodeStyle test utilities project into separate projects for…
mavasani Mar 10, 2020
cbead33
Fix some build and test failures
mavasani Mar 10, 2020
e4c7e8e
Cleanup the conditional directives in analyzer/fixer tests in shared …
mavasani Mar 10, 2020
7e3c47e
Tons of test changes to move them to the new Options APIs.
mavasani Mar 10, 2020
c765e1f
Commit for all project file, resx moves and xlf file changes.
mavasani Mar 10, 2020
11d03e1
Fix nullable warning
mavasani Mar 11, 2020
80a215d
Merge remote-tracking branch 'upstream/master' into OptionsRefactor
mavasani Mar 11, 2020
d6bc6f6
Merge remote-tracking branch 'upstream/master' into OptionsRefactor
mavasani Mar 16, 2020
193ac53
Use OptionDefinition to ensure options are equtable - this is needed …
mavasani Mar 17, 2020
8b547f4
Merge remote-tracking branch 'upstream/master' into OptionsRefactor
mavasani Mar 17, 2020
b704f66
Fix merge conflict
mavasani Mar 17, 2020
c45db4c
Override equality operators
mavasani Mar 17, 2020
fb10c5e
Retain the exception checks from public APIs - these are guarded by u…
mavasani Mar 17, 2020
04056c0
Switch to explicit conversion operators between option types
mavasani Mar 18, 2020
de4d5d9
Merge remote-tracking branch 'upstream/master' into OptionsRefactor
mavasani Mar 18, 2020
7301aa3
Fix merge conflicts
mavasani Mar 18, 2020
0ff090f
Add inheritdoc documentation comments for public Options API. I will …
mavasani Mar 18, 2020
f47f6d1
Fix test failures caused by prior commit
mavasani Mar 18, 2020
50287de
Switch back to implicit operators for conversions to and from CodeSty…
mavasani Mar 18, 2020
4985a18
Address feedback
mavasani Mar 19, 2020
0066c5c
Merge remote-tracking branch 'upstream/master' into OptionsRefactor
mavasani Mar 19, 2020
f52f4fe
Revert unintentional commit
mavasani Mar 19, 2020
736ba89
Address more feedback
mavasani Mar 19, 2020
0f22449
Merge remote-tracking branch 'upstream/master' into OptionsRefactor
mavasani Mar 19, 2020
9793b0b
Fix build break from the refactoring in the prior commit
mavasani Mar 19, 2020
6192d8e
Revert changes to PythiaOptions in ExternalAccessLayer
mavasani Mar 19, 2020
759dc07
Fix RS0038 (use null instead of default) in test code
mavasani Mar 19, 2020
e8464de
Merge remote-tracking branch 'upstream/master' into OptionsRefactor
mavasani Mar 19, 2020
8961e3b
Revert API changes to options used by internal partners through IVT
mavasani Mar 19, 2020
d02be0c
Revert changes to EditorComponentOnOffOptions - these are actually no…
mavasani Mar 20, 2020
02f40aa
Add back cref to PreferBracesPreference.WhenMultiline
mavasani Mar 20, 2020
a56b5a7
Enable nullable reference types for operators
sharwell Mar 20, 2020
717c508
Unwrap CodeStyleOption<T> without allocating
sharwell Mar 20, 2020
17ce912
Improve accuracy of TestHostAnalyzers
sharwell Mar 20, 2020
c533f82
Use explicit operators, since they are no longer used implicitly
sharwell Mar 20, 2020
6878054
Ensure that we use "CodeStyleOption" as the serialization element nam…
mavasani Mar 20, 2020
f139867
Address feedback
mavasani Mar 20, 2020
6aa9798
Add matrix of tests for Get/Set option APIs on OptionSet and OptionSe…
mavasani Mar 20, 2020
81ff9eb
Address feedback
mavasani Mar 20, 2020
17fbad5
Merge remote-tracking branch 'upstream/master' into OptionsRefactor
mavasani Mar 20, 2020
4c01f51
Merge remote-tracking branch 'upstream/master' into OptionsRefactor
mavasani Mar 23, 2020
950b3b6
Fix conflicts
mavasani Mar 23, 2020
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 @@ -162,7 +162,7 @@ private static bool TryReduceMemberAccessExpression(

replacementNode = replacementNode
.WithAdditionalAnnotations<TypeSyntax>(new SyntaxAnnotation(
nameof(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess)));
nameof(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess)));

issueSpan = memberAccess.Span; // we want to show the whole expression as unnecessary

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ public override bool TrySimplify(
// If not, we'll still fall through and see if we can convert it to Int32.

var codeStyleOptionName = inDeclarationContext
? nameof(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration)
: nameof(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess);
? nameof(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration)
: nameof(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess);

var type = semanticModel.GetTypeInfo(name, cancellationToken).Type;
if (type != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public override bool TrySimplify(

private static TypeCrefSyntax CreateReplacement(QualifiedCrefSyntax crefSyntax, SyntaxKind keywordKind)
{
var annotation = new SyntaxAnnotation(nameof(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess));
var annotation = new SyntaxAnnotation(nameof(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess));
var token = Token(crefSyntax.GetLeadingTrivia(), keywordKind, crefSyntax.GetTrailingTrivia());
return TypeCref(PredefinedType(token)).WithAdditionalAnnotations(annotation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.GeneratedCodeRecognition;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.CodeFixes
Expand Down
26 changes: 0 additions & 26 deletions src/Workspaces/Core/Portable/Diagnostics/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.PooledObjects;
Expand Down Expand Up @@ -176,30 +175,5 @@ public static ImmutableDictionary<DiagnosticAnalyzer, DiagnosticAnalysisResultBu

return builder.ToImmutable();
}

public static NotificationOption ToNotificationOption(this ReportDiagnostic reportDiagnostic, DiagnosticSeverity defaultSeverity)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to shared layer.

{
switch (reportDiagnostic.WithDefaultSeverity(defaultSeverity))
{
case ReportDiagnostic.Error:
return NotificationOption.Error;

case ReportDiagnostic.Warn:
return NotificationOption.Warning;

case ReportDiagnostic.Info:
return NotificationOption.Suggestion;

case ReportDiagnostic.Hidden:
return NotificationOption.Silent;

case ReportDiagnostic.Suppress:
return NotificationOption.None;

case ReportDiagnostic.Default:
default:
throw ExceptionUtilities.UnexpectedValue(reportDiagnostic);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@

#nullable enable

using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.PooledObjects;
using Roslyn.Utilities;

#pragma warning disable RS0005 // Do not use generic CodeAction.Create to create CodeAction

namespace Microsoft.CodeAnalysis.CodeStyle
namespace Microsoft.CodeAnalysis.CodeFixes
{
/// <summary>
/// Provides a base class to write a <see cref="FixAllProvider"/> that fixes documents independently.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Concurrent;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Utilities;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.CodeStyle
namespace Microsoft.CodeAnalysis.CodeFixes
{
internal static class FixAllContextHelper
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.GeneratedCodeRecognition;
using Microsoft.CodeAnalysis.Shared.Extensions;

namespace Microsoft.CodeAnalysis.CodeFixes
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
// See the LICENSE file in the project root for more information.

using System.Linq;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Roslyn.Utilities;

#if CODE_STYLE
using Microsoft.CodeAnalysis.Internal.Options;
using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions;
#else
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Options;
using OptionSet = Microsoft.CodeAnalysis.Options.OptionSet;
#endif

namespace Microsoft.CodeAnalysis.Simplification
Expand Down Expand Up @@ -118,10 +117,10 @@ internal static bool ShouldSimplifyThisOrMeMemberAccessExpression(
if (symbol.IsStatic)
return true;

if ((symbol.IsKind(SymbolKind.Field) && optionSet.GetOption(CodeStyleOptions.QualifyFieldAccess, semanticModel.Language).Value ||
(symbol.IsKind(SymbolKind.Property) && optionSet.GetOption(CodeStyleOptions.QualifyPropertyAccess, semanticModel.Language).Value) ||
(symbol.IsKind(SymbolKind.Method) && optionSet.GetOption(CodeStyleOptions.QualifyMethodAccess, semanticModel.Language).Value) ||
(symbol.IsKind(SymbolKind.Event) && optionSet.GetOption(CodeStyleOptions.QualifyEventAccess, semanticModel.Language).Value)))
if ((symbol.IsKind(SymbolKind.Field) && optionSet.GetOption(CodeStyleOptions2.QualifyFieldAccess, semanticModel.Language).Value ||
(symbol.IsKind(SymbolKind.Property) && optionSet.GetOption(CodeStyleOptions2.QualifyPropertyAccess, semanticModel.Language).Value) ||
(symbol.IsKind(SymbolKind.Method) && optionSet.GetOption(CodeStyleOptions2.QualifyMethodAccess, semanticModel.Language).Value) ||
(symbol.IsKind(SymbolKind.Event) && optionSet.GetOption(CodeStyleOptions2.QualifyEventAccess, semanticModel.Language).Value)))
{
return false;
}
Expand All @@ -131,12 +130,12 @@ internal static bool ShouldSimplifyThisOrMeMemberAccessExpression(

internal static bool PreferPredefinedTypeKeywordInDeclarations(OptionSet optionSet, string language)
{
return optionSet.GetOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, language).Value;
return optionSet.GetOption(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration, language).Value;
}

internal static bool PreferPredefinedTypeKeywordInMemberAccess(OptionSet optionSet, string language)
{
return optionSet.GetOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, language).Value;
return optionSet.GetOption(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, language).Value;
}
}
}