From 2c20279fefb53c5e0863e4148af13ce433ffaf67 Mon Sep 17 00:00:00 2001 From: GrahamTheCoder Date: Mon, 20 Jan 2020 10:33:22 +0000 Subject: [PATCH] Explicit accessibility --- CodeConverter.Web/ConverterController.cs | 4 +-- .../MethodBodyExecutableStatementVisitor.cs | 6 ++-- ICSharpCode.CodeConverter/CodeConverter.cs | 4 +-- .../Shared/ProjectConversion.cs | 5 +-- ICSharpCode.CodeConverter/Util/CSharpUtil.cs | 4 +-- .../Util/EnumerableExtensions.cs | 2 +- .../Util/ExpressionSyntaxExtensions.cs | 2 +- .../Util/IAssemblySymbolExtensions.cs | 2 +- .../Util/INamespaceOrTypeSymbolExtensions.cs | 2 +- .../Util/ISymbolExtensions.cs | 2 +- .../Util/ITypeParameterSymbolExtensions.cs | 2 +- .../Util/ITypeSymbolExtensions.cs | 4 +-- ICSharpCode.CodeConverter/Util/Matcher.cs | 4 +-- .../Util/NameGenerator.cs | 2 +- .../Util/ObjectExtensions.cs | 2 +- .../Util/SpecializedCollections.cs | 2 +- .../Util/StringExtensions.cs | 2 +- .../Util/SymbolExtensions.cs | 2 +- .../Util/SyntaxExtensions.cs | 2 +- .../Util/SyntaxNodeExtensions.cs | 2 +- .../Util/SyntaxTokenExtensions.cs | 2 +- .../Util/SyntaxTriviaExtensions.cs | 2 +- .../Util/TypeExtensions.cs | 2 +- ICSharpCode.CodeConverter/Util/VBUtil.cs | 2 +- .../VB/ConversionExtensions.cs | 2 +- .../MethodBodyExecutableStatementVisitor.cs | 34 +++++++++---------- ICSharpCode.CodeConverter/VB/NodesVisitor.cs | 24 ++++++------- Tests/UnicodeNewline.cs | 4 +-- Tests/Utils.cs | 2 +- Vsix/CodeConversion.cs | 2 +- Vsix/ConvertCSToVBCommand.cs | 4 +-- Vsix/ConvertVBToCSCommand.cs | 4 +-- Vsix/VsDocument.cs | 2 +- 33 files changed, 72 insertions(+), 71 deletions(-) diff --git a/CodeConverter.Web/ConverterController.cs b/CodeConverter.Web/ConverterController.cs index cb32458ac..b84347ab2 100644 --- a/CodeConverter.Web/ConverterController.cs +++ b/CodeConverter.Web/ConverterController.cs @@ -45,7 +45,7 @@ public async Task Post([FromBody]ConvertRequest todo) return Ok(response); } - string ParseLanguage(string language) + private string ParseLanguage(string language) { if (language == null) throw new ArgumentNullException(nameof(language)); @@ -56,7 +56,7 @@ string ParseLanguage(string language) throw new ArgumentException($"{language} not supported!"); } - int GetDefaultVersionForLanguage(string language) + private int GetDefaultVersionForLanguage(string language) { if (language == null) throw new ArgumentNullException(nameof(language)); diff --git a/ICSharpCode.CodeConverter/CSharp/MethodBodyExecutableStatementVisitor.cs b/ICSharpCode.CodeConverter/CSharp/MethodBodyExecutableStatementVisitor.cs index 4f32d4cba..9be46c583 100644 --- a/ICSharpCode.CodeConverter/CSharp/MethodBodyExecutableStatementVisitor.cs +++ b/ICSharpCode.CodeConverter/CSharp/MethodBodyExecutableStatementVisitor.cs @@ -759,18 +759,18 @@ public override async Task> VisitCallStatement(VBSyn return SingleStatement((ExpressionSyntax) await node.Invocation.AcceptAsync(_expressionVisitor)); } - SyntaxList SingleStatement(StatementSyntax statement) + private SyntaxList SingleStatement(StatementSyntax statement) { return SyntaxFactory.SingletonList(statement); } - SyntaxList SingleStatement(ExpressionSyntax expression) + private SyntaxList SingleStatement(ExpressionSyntax expression) { return SyntaxFactory.SingletonList(SyntaxFactory.ExpressionStatement(expression)); } } - static class Extensions + internal static class Extensions { /// /// Returns the single statement in a block if it has no nested statements. diff --git a/ICSharpCode.CodeConverter/CodeConverter.cs b/ICSharpCode.CodeConverter/CodeConverter.cs index 0daa17c16..779e9024e 100644 --- a/ICSharpCode.CodeConverter/CodeConverter.cs +++ b/ICSharpCode.CodeConverter/CodeConverter.cs @@ -35,12 +35,12 @@ public static async Task Convert(CodeWithOptions code) return new ConversionResult(new NotSupportedException($"Converting from {code.FromLanguage} {code.FromLanguageVersion} to {code.ToLanguage} {code.ToLanguageVersion} is not supported!")); } - static bool IsSupportedTarget(string toLanguage, int toLanguageVersion) + private static bool IsSupportedTarget(string toLanguage, int toLanguageVersion) { return (toLanguage == "Visual Basic" && toLanguageVersion == 14) || (toLanguage == "C#" && toLanguageVersion == 6); } - static bool IsSupportedSource(string fromLanguage, int fromLanguageVersion) + private static bool IsSupportedSource(string fromLanguage, int fromLanguageVersion) { return (fromLanguage == "C#" && fromLanguageVersion == 6) || (fromLanguage == "Visual Basic" && fromLanguageVersion == 14); } diff --git a/ICSharpCode.CodeConverter/Shared/ProjectConversion.cs b/ICSharpCode.CodeConverter/Shared/ProjectConversion.cs index 4b14db30c..d65b20d77 100644 --- a/ICSharpCode.CodeConverter/Shared/ProjectConversion.cs +++ b/ICSharpCode.CodeConverter/Shared/ProjectConversion.cs @@ -99,12 +99,13 @@ public static async Task> ConvertProject(Project p ); } - static (string Find, string Replace, bool FirstOnly) ChangeLanguageVersionRegex(string languageVersion) { + private static (string Find, string Replace, bool FirstOnly) ChangeLanguageVersionRegex(string languageVersion) { return (Find: new Regex(@"<\s*LangVersion>(\d|\D)*").ToString(), Replace: $"{languageVersion}", FirstOnly: true); } - static (string Find, string Replace, bool FirstOnly) ChangeRootNamespaceRegex(string rootNamespace) { + private static (string Find, string Replace, bool FirstOnly) ChangeRootNamespaceRegex(string rootNamespace) { return (Find: new Regex(@"<\s*RootNamespace>(\d|\D)*").ToString(), Replace: $"{rootNamespace}", FirstOnly: true); } + private static (string Find, string Replace, bool FirstOnly) AddCompiledItemsRegexFromRelativePaths( string[] relativeFilePathsToAdd) { diff --git a/ICSharpCode.CodeConverter/Util/CSharpUtil.cs b/ICSharpCode.CodeConverter/Util/CSharpUtil.cs index ae216b69a..67c3eee8f 100644 --- a/ICSharpCode.CodeConverter/Util/CSharpUtil.cs +++ b/ICSharpCode.CodeConverter/Util/CSharpUtil.cs @@ -8,7 +8,7 @@ namespace ICSharpCode.CodeConverter.Util { - static class CSharpUtil + internal static class CSharpUtil { /// /// Inverts a boolean condition. Note: The condition object can be frozen (from AST) it's cloned internally. @@ -19,7 +19,7 @@ public static ExpressionSyntax InvertCondition(this ExpressionSyntax condition) return InvertConditionInternal(condition); } - static ExpressionSyntax InvertConditionInternal(ExpressionSyntax condition) + private static ExpressionSyntax InvertConditionInternal(ExpressionSyntax condition) { if (condition is ParenthesizedExpressionSyntax) { return SyntaxFactory.ParenthesizedExpression(InvertCondition(((ParenthesizedExpressionSyntax)condition).Expression)); diff --git a/ICSharpCode.CodeConverter/Util/EnumerableExtensions.cs b/ICSharpCode.CodeConverter/Util/EnumerableExtensions.cs index ed7f6352c..23ae9b419 100644 --- a/ICSharpCode.CodeConverter/Util/EnumerableExtensions.cs +++ b/ICSharpCode.CodeConverter/Util/EnumerableExtensions.cs @@ -10,7 +10,7 @@ namespace ICSharpCode.CodeConverter.Util #if NR6 public #endif - static partial class EnumerableExtensions + internal static partial class EnumerableExtensions { public static IEnumerable Do(this IEnumerable source, Action action) { diff --git a/ICSharpCode.CodeConverter/Util/ExpressionSyntaxExtensions.cs b/ICSharpCode.CodeConverter/Util/ExpressionSyntaxExtensions.cs index d3dd52c11..970975985 100644 --- a/ICSharpCode.CodeConverter/Util/ExpressionSyntaxExtensions.cs +++ b/ICSharpCode.CodeConverter/Util/ExpressionSyntaxExtensions.cs @@ -16,7 +16,7 @@ namespace ICSharpCode.CodeConverter.Util #if NR6 public #endif - static class ExpressionSyntaxExtensions + internal static class ExpressionSyntaxExtensions { /// diff --git a/ICSharpCode.CodeConverter/Util/IAssemblySymbolExtensions.cs b/ICSharpCode.CodeConverter/Util/IAssemblySymbolExtensions.cs index 262856458..0788940d4 100644 --- a/ICSharpCode.CodeConverter/Util/IAssemblySymbolExtensions.cs +++ b/ICSharpCode.CodeConverter/Util/IAssemblySymbolExtensions.cs @@ -6,7 +6,7 @@ namespace ICSharpCode.CodeConverter.Util #if NR6 public #endif - static class IAssemblySymbolExtensions + internal static class IAssemblySymbolExtensions { private const string AttributeSuffix = "Attribute"; diff --git a/ICSharpCode.CodeConverter/Util/INamespaceOrTypeSymbolExtensions.cs b/ICSharpCode.CodeConverter/Util/INamespaceOrTypeSymbolExtensions.cs index a5db0a008..efcf6e05a 100644 --- a/ICSharpCode.CodeConverter/Util/INamespaceOrTypeSymbolExtensions.cs +++ b/ICSharpCode.CodeConverter/Util/INamespaceOrTypeSymbolExtensions.cs @@ -9,7 +9,7 @@ namespace ICSharpCode.CodeConverter.Util #if NR6 public #endif - static partial class INamespaceOrTypeSymbolExtensions + internal static partial class INamespaceOrTypeSymbolExtensions { private static readonly ConditionalWeakTable> s_namespaceOrTypeToNameMap = new ConditionalWeakTable>(); diff --git a/ICSharpCode.CodeConverter/Util/ISymbolExtensions.cs b/ICSharpCode.CodeConverter/Util/ISymbolExtensions.cs index a49865d2c..61973da3b 100644 --- a/ICSharpCode.CodeConverter/Util/ISymbolExtensions.cs +++ b/ICSharpCode.CodeConverter/Util/ISymbolExtensions.cs @@ -12,7 +12,7 @@ namespace ICSharpCode.CodeConverter.Util #if NR6 public #endif - static class ISymbolExtensions + internal static class ISymbolExtensions { // A lot of symbols in DateAndTime do not exist in DateTime, eg. DateSerial(), // and some have different names/arguments, eg. DateAdd(). This needs to be handled properly diff --git a/ICSharpCode.CodeConverter/Util/ITypeParameterSymbolExtensions.cs b/ICSharpCode.CodeConverter/Util/ITypeParameterSymbolExtensions.cs index 34882736d..25a24cb78 100644 --- a/ICSharpCode.CodeConverter/Util/ITypeParameterSymbolExtensions.cs +++ b/ICSharpCode.CodeConverter/Util/ITypeParameterSymbolExtensions.cs @@ -6,7 +6,7 @@ namespace ICSharpCode.CodeConverter.Util #if NR6 public #endif - static class ITypeParameterSymbolExtensions + internal static class ITypeParameterSymbolExtensions { public static INamedTypeSymbol GetNamedTypeSymbolConstraint(this ITypeParameterSymbol typeParameter) { diff --git a/ICSharpCode.CodeConverter/Util/ITypeSymbolExtensions.cs b/ICSharpCode.CodeConverter/Util/ITypeSymbolExtensions.cs index 5b6bb2383..22eecacbb 100644 --- a/ICSharpCode.CodeConverter/Util/ITypeSymbolExtensions.cs +++ b/ICSharpCode.CodeConverter/Util/ITypeSymbolExtensions.cs @@ -12,7 +12,7 @@ namespace ICSharpCode.CodeConverter.Util #if NR6 public #endif - static class ITypeSymbolExtensions + internal static class ITypeSymbolExtensions { public static bool ImplementsSpecialTypeInterface(this ITypeSymbol symbol, SpecialType type) { @@ -363,7 +363,7 @@ public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol) return false; } - static bool HasAddMethod(ITypeSymbol typeSymbol) + private static bool HasAddMethod(ITypeSymbol typeSymbol) { return typeSymbol .GetMembers(WellKnownMemberNames.CollectionInitializerAddMethodName) diff --git a/ICSharpCode.CodeConverter/Util/Matcher.cs b/ICSharpCode.CodeConverter/Util/Matcher.cs index 064ce2129..046ed3a0b 100644 --- a/ICSharpCode.CodeConverter/Util/Matcher.cs +++ b/ICSharpCode.CodeConverter/Util/Matcher.cs @@ -6,7 +6,7 @@ namespace ICSharpCode.CodeConverter.Util #if NR6 public #endif - abstract class Matcher + internal abstract class Matcher { // Tries to match this matcher against the provided sequence at the given index. If the // match succeeds, 'true' is returned, and 'index' points to the location after the match @@ -142,7 +142,7 @@ public override string ToString() #if NR6 public #endif - class Matcher + internal class Matcher { /// /// Matcher equivalent to (m*) diff --git a/ICSharpCode.CodeConverter/Util/NameGenerator.cs b/ICSharpCode.CodeConverter/Util/NameGenerator.cs index 3fd2b7845..4f7f32bbb 100644 --- a/ICSharpCode.CodeConverter/Util/NameGenerator.cs +++ b/ICSharpCode.CodeConverter/Util/NameGenerator.cs @@ -11,7 +11,7 @@ namespace ICSharpCode.CodeConverter.Util { - static class NameGenerator + internal static class NameGenerator { public static IList EnsureUniqueness( IList names, diff --git a/ICSharpCode.CodeConverter/Util/ObjectExtensions.cs b/ICSharpCode.CodeConverter/Util/ObjectExtensions.cs index e12ada2fa..f774205c2 100644 --- a/ICSharpCode.CodeConverter/Util/ObjectExtensions.cs +++ b/ICSharpCode.CodeConverter/Util/ObjectExtensions.cs @@ -5,7 +5,7 @@ namespace ICSharpCode.CodeConverter.Util #if NR6 public #endif - static partial class ObjectExtensions + internal static partial class ObjectExtensions { #region TypeSwitch on Action diff --git a/ICSharpCode.CodeConverter/Util/SpecializedCollections.cs b/ICSharpCode.CodeConverter/Util/SpecializedCollections.cs index d0fc9faf6..55a7eecb2 100644 --- a/ICSharpCode.CodeConverter/Util/SpecializedCollections.cs +++ b/ICSharpCode.CodeConverter/Util/SpecializedCollections.cs @@ -7,7 +7,7 @@ namespace ICSharpCode.CodeConverter.Util #if NR6 public #endif - static partial class SpecializedCollections + internal static partial class SpecializedCollections { public static readonly byte[] EmptyBytes = EmptyArray(); public static readonly object[] EmptyObjects = EmptyArray(); diff --git a/ICSharpCode.CodeConverter/Util/StringExtensions.cs b/ICSharpCode.CodeConverter/Util/StringExtensions.cs index 836b61b5d..92b36ab0b 100644 --- a/ICSharpCode.CodeConverter/Util/StringExtensions.cs +++ b/ICSharpCode.CodeConverter/Util/StringExtensions.cs @@ -13,7 +13,7 @@ namespace ICSharpCode.CodeConverter.Util #if NR6 public #endif - static class StringExtensions + internal static class StringExtensions { public static int? GetFirstNonWhitespaceOffset(this string line) { diff --git a/ICSharpCode.CodeConverter/Util/SymbolExtensions.cs b/ICSharpCode.CodeConverter/Util/SymbolExtensions.cs index ff80ae1b4..13c081b89 100644 --- a/ICSharpCode.CodeConverter/Util/SymbolExtensions.cs +++ b/ICSharpCode.CodeConverter/Util/SymbolExtensions.cs @@ -9,7 +9,7 @@ namespace ICSharpCode.CodeConverter.Util #if NR6 public #endif - static class SymbolExtensions + internal static class SymbolExtensions { /// /// Returns true if the symbol wasn't tagged with diff --git a/ICSharpCode.CodeConverter/Util/SyntaxExtensions.cs b/ICSharpCode.CodeConverter/Util/SyntaxExtensions.cs index 4dbf48e7f..001bf6b34 100644 --- a/ICSharpCode.CodeConverter/Util/SyntaxExtensions.cs +++ b/ICSharpCode.CodeConverter/Util/SyntaxExtensions.cs @@ -11,7 +11,7 @@ namespace ICSharpCode.CodeConverter.Util #if NR6 public #endif - static class SyntaxExtensions + internal static class SyntaxExtensions { /// /// Look inside a trivia list for a skipped token that contains the given position. diff --git a/ICSharpCode.CodeConverter/Util/SyntaxNodeExtensions.cs b/ICSharpCode.CodeConverter/Util/SyntaxNodeExtensions.cs index ee0a0bc68..a7bd2beb4 100644 --- a/ICSharpCode.CodeConverter/Util/SyntaxNodeExtensions.cs +++ b/ICSharpCode.CodeConverter/Util/SyntaxNodeExtensions.cs @@ -46,7 +46,7 @@ namespace ICSharpCode.CodeConverter.Util #if NR6 public #endif - static partial class SyntaxNodeExtensions + internal static partial class SyntaxNodeExtensions { public static IEnumerable GetAncestors(this SyntaxNode node) { diff --git a/ICSharpCode.CodeConverter/Util/SyntaxTokenExtensions.cs b/ICSharpCode.CodeConverter/Util/SyntaxTokenExtensions.cs index e3b1bde98..ad15fd4b2 100644 --- a/ICSharpCode.CodeConverter/Util/SyntaxTokenExtensions.cs +++ b/ICSharpCode.CodeConverter/Util/SyntaxTokenExtensions.cs @@ -16,7 +16,7 @@ namespace ICSharpCode.CodeConverter.Util #if NR6 public #endif - static class SyntaxTokenExtensions + internal static class SyntaxTokenExtensions { public static SyntaxNode GetAncestor(this SyntaxToken token, Func predicate) { diff --git a/ICSharpCode.CodeConverter/Util/SyntaxTriviaExtensions.cs b/ICSharpCode.CodeConverter/Util/SyntaxTriviaExtensions.cs index 30bbe1d86..3b445be8b 100644 --- a/ICSharpCode.CodeConverter/Util/SyntaxTriviaExtensions.cs +++ b/ICSharpCode.CodeConverter/Util/SyntaxTriviaExtensions.cs @@ -14,7 +14,7 @@ namespace ICSharpCode.CodeConverter.Util #if NR6 public #endif - static class SyntaxTriviaExtensions + internal static class SyntaxTriviaExtensions { /// /// Look inside a trivia list for a skipped token that contains the given position. diff --git a/ICSharpCode.CodeConverter/Util/TypeExtensions.cs b/ICSharpCode.CodeConverter/Util/TypeExtensions.cs index b4bedcb5e..eb6484c29 100644 --- a/ICSharpCode.CodeConverter/Util/TypeExtensions.cs +++ b/ICSharpCode.CodeConverter/Util/TypeExtensions.cs @@ -9,7 +9,7 @@ namespace ICSharpCode.CodeConverter.Util #if NR6 public #endif - static class TypeExtensions + internal static class TypeExtensions { #region GetDelegateInvokeMethod /// diff --git a/ICSharpCode.CodeConverter/Util/VBUtil.cs b/ICSharpCode.CodeConverter/Util/VBUtil.cs index 041132a9e..670b48d17 100644 --- a/ICSharpCode.CodeConverter/Util/VBUtil.cs +++ b/ICSharpCode.CodeConverter/Util/VBUtil.cs @@ -6,7 +6,7 @@ namespace ICSharpCode.CodeConverter.Util { - static class VBUtil + internal static class VBUtil { /// /// Inverts a boolean condition. Note: The condition object can be frozen (from AST) it's cloned internally. diff --git a/ICSharpCode.CodeConverter/VB/ConversionExtensions.cs b/ICSharpCode.CodeConverter/VB/ConversionExtensions.cs index 41eca8047..129aa1f3c 100644 --- a/ICSharpCode.CodeConverter/VB/ConversionExtensions.cs +++ b/ICSharpCode.CodeConverter/VB/ConversionExtensions.cs @@ -6,7 +6,7 @@ namespace ICSharpCode.CodeConverter.VB { - static class ConversionExtensions + internal static class ConversionExtensions { public static bool HasUsingDirective(this CS.CSharpSyntaxTree tree, string fullName) { diff --git a/ICSharpCode.CodeConverter/VB/MethodBodyExecutableStatementVisitor.cs b/ICSharpCode.CodeConverter/VB/MethodBodyExecutableStatementVisitor.cs index 47b578271..edfdf01a3 100644 --- a/ICSharpCode.CodeConverter/VB/MethodBodyExecutableStatementVisitor.cs +++ b/ICSharpCode.CodeConverter/VB/MethodBodyExecutableStatementVisitor.cs @@ -28,14 +28,14 @@ namespace ICSharpCode.CodeConverter.VB { internal class MethodBodyExecutableStatementVisitor : CS.CSharpSyntaxVisitor> { - SemanticModel _semanticModel; - readonly CS.CSharpSyntaxVisitor _nodesVisitor; + private SemanticModel _semanticModel; + private readonly CS.CSharpSyntaxVisitor _nodesVisitor; private readonly CommonConversions _commonConversions; - readonly Stack _blockInfo = new Stack(); // currently only works with switch blocks - int _switchCount = 0; + private readonly Stack _blockInfo = new Stack(); // currently only works with switch blocks + private int _switchCount = 0; public bool IsIterator { get; private set; } - class BlockInfo + private class BlockInfo { public readonly List GotoCaseExpressions = new List(); } @@ -69,7 +69,7 @@ public override SyntaxList VisitLocalDeclarationStatement(CSS.L ); } - StatementSyntax ConvertSingleExpression(CSS.ExpressionSyntax node) + private StatementSyntax ConvertSingleExpression(CSS.ExpressionSyntax node) { var exprNode = node.Accept(_nodesVisitor); if (!(exprNode is StatementSyntax)) @@ -118,7 +118,7 @@ public override SyntaxList VisitIfStatement(CSS.IfStatementSynt return SyntaxFactory.SingletonList(stmt); } - bool IsSimpleStatement(CSS.StatementSyntax statement) + private bool IsSimpleStatement(CSS.StatementSyntax statement) { return statement is CSS.ExpressionStatementSyntax || statement is CSS.BreakStatementSyntax @@ -128,7 +128,7 @@ bool IsSimpleStatement(CSS.StatementSyntax statement) || statement is CSS.ThrowStatementSyntax; } - bool TryConvertIfNotNullRaiseEvent(CSS.IfStatementSyntax node, out StatementSyntax raiseEventStatement) + private bool TryConvertIfNotNullRaiseEvent(CSS.IfStatementSyntax node, out StatementSyntax raiseEventStatement) { raiseEventStatement = null; return TryGetBinaryExpression(node, out var comparisonExpression, CS.SyntaxKind.NotEqualsExpression, CS.SyntaxKind.NullLiteralExpression) @@ -173,7 +173,7 @@ private bool TryConvertRaiseEvent(CSS.StatementSyntax resultStatement, return raiseEventStatement != null; } - void CollectElseBlocks(CSS.IfStatementSyntax node, List elseIfBlocks, ref ElseBlockSyntax elseBlock) + private void CollectElseBlocks(CSS.IfStatementSyntax node, List elseIfBlocks, ref ElseBlockSyntax elseBlock) { if (node.Else == null) return; if (node.Else.Statement is CSS.IfStatementSyntax) { @@ -208,7 +208,7 @@ public override SyntaxList VisitSwitchStatement(CSS.SwitchState return SyntaxFactory.SingletonList(stmt); } - IEnumerable AddLabels(CaseBlockSyntax[] blocks, List gotoLabels) + private IEnumerable AddLabels(CaseBlockSyntax[] blocks, List gotoLabels) { foreach (var block in blocks) { var modifiedBlock = block; @@ -221,7 +221,7 @@ IEnumerable AddLabels(CaseBlockSyntax[] blocks, List().Any(); } - SyntaxList ConvertSwitchSectionBlock(CSS.SwitchSectionSyntax section) + private SyntaxList ConvertSwitchSectionBlock(CSS.SwitchSectionSyntax section) { List statements = new List(); var lastStatement = section.Statements.LastOrDefault(); @@ -295,7 +295,7 @@ public override SyntaxList VisitForStatement(CSS.ForStatementSy return SyntaxFactory.SingletonList(block); } - bool ConvertForToSimpleForNext(CSS.ForStatementSyntax node, out StatementSyntax block) + private bool ConvertForToSimpleForNext(CSS.ForStatementSyntax node, out StatementSyntax block) { // ForStatement -> ForNextStatement when for-loop is simple @@ -446,7 +446,7 @@ public override SyntaxList VisitTryStatement(CSS.TryStatementSy return SyntaxFactory.SingletonList(block); } - CatchBlockSyntax ConvertCatchClause(int index, CSS.CatchClauseSyntax catchClause) + private CatchBlockSyntax ConvertCatchClause(int index, CSS.CatchClauseSyntax catchClause) { var statements = ConvertBlock(catchClause.Block); if (catchClause.Declaration == null) @@ -494,7 +494,7 @@ public override SyntaxList VisitLabeledStatement(CSS.LabeledSta .AddRange(ConvertBlock(node.Statement)); } - string MakeGotoSwitchLabel(VisualBasicSyntaxNode expression) + private string MakeGotoSwitchLabel(VisualBasicSyntaxNode expression) { string expressionText; if (expression is ElseCaseClauseSyntax) @@ -544,7 +544,7 @@ public static MultiLineIfBlockSyntax CreateBlock(SyntaxList sta return ifBlock; } - SyntaxList ConvertBlock(CSS.StatementSyntax node, params StatementSyntax[] prefixExtraVbStatements) + private SyntaxList ConvertBlock(CSS.StatementSyntax node, params StatementSyntax[] prefixExtraVbStatements) { if (node is CSS.BlockSyntax b) { return SyntaxFactory.List(prefixExtraVbStatements.Concat(b.Statements.Where(s => !(s is CSS.EmptyStatementSyntax)) @@ -654,7 +654,7 @@ public override SyntaxList VisitCheckedStatement(CSS.CheckedSta return WrapInComment(ConvertBlock(node.Block), "Visual Basic does not support checked statements!"); } - SyntaxList WrapInComment(SyntaxList nodes, string comment) + private SyntaxList WrapInComment(SyntaxList nodes, string comment) { if (nodes.Count > 0) { nodes = nodes.Replace(nodes[0], nodes[0].WithPrependedLeadingTrivia(SyntaxFactory.CommentTrivia("BEGIN TODO : " + comment))); diff --git a/ICSharpCode.CodeConverter/VB/NodesVisitor.cs b/ICSharpCode.CodeConverter/VB/NodesVisitor.cs index d3dded019..dbcc918e2 100644 --- a/ICSharpCode.CodeConverter/VB/NodesVisitor.cs +++ b/ICSharpCode.CodeConverter/VB/NodesVisitor.cs @@ -48,24 +48,24 @@ internal class NodesVisitor : CS.CSharpSyntaxVisitor { private readonly Document _document; private readonly CS.CSharpCompilation _compilation; - readonly SemanticModel _semanticModel; + private readonly SemanticModel _semanticModel; private readonly VisualBasicCompilation _vbViewOfCsSymbols; private readonly SyntaxGenerator _vbSyntaxGenerator; - readonly List _allImports = new List(); + private readonly List _allImports = new List(); - int _placeholder = 1; + private int _placeholder = 1; private readonly CSharpHelperMethodDefinition _cSharpHelperMethodDefinition; private readonly CommonConversions _commonConversions; public CommentConvertingNodesVisitor TriviaConvertingVisitor { get; } - string GeneratePlaceholder(string v) + private string GeneratePlaceholder(string v) { return $"__{v}{_placeholder++}__"; } - IEnumerable TidyImportsList(IEnumerable allImports) + private IEnumerable TidyImportsList(IEnumerable allImports) { return allImports .SelectMany(x => x.ImportsClauses) @@ -489,7 +489,7 @@ private ImplementsClauseSyntax CreateImplementsClauseSyntaxOrNull(ISymbol member return !implementors.Any() ? null: CreateImplementsClauseSyntax(implementors, id); } - ImplementsClauseSyntax CreateImplementsClauseSyntax(IEnumerable implementors, SyntaxToken id) { + private ImplementsClauseSyntax CreateImplementsClauseSyntax(IEnumerable implementors, SyntaxToken id) { return SyntaxFactory.ImplementsClause(implementors.Select(x => { var namedTypeSymbol = x.ContainingSymbol as INamedTypeSymbol; NameSyntax nameSyntax = null; @@ -605,7 +605,7 @@ private TokenContext GetMemberContext(CSS.MemberDeclarationSyntax member) throw new ArgumentOutOfRangeException(nameof(member), parentTypeKind, null); } } - bool IsNonGenericStatic(CSS.TypeDeclarationSyntax type) { + private bool IsNonGenericStatic(CSS.TypeDeclarationSyntax type) { return type.Modifiers.Any(CS.SyntaxKind.StaticKeyword) && type.TypeParameterList == null; } @@ -665,7 +665,7 @@ public override VisualBasicSyntaxNode VisitEventFieldDeclaration(CSS.EventFieldD ConvertAndSplitAttributes(node.AttributeLists, out SyntaxList attributes, out SyntaxList returnAttributes); return SyntaxFactory.EventStatement(attributes, CommonConversions.ConvertModifiers(node.Modifiers, GetMemberContext(node)), id, null, SyntaxFactory.SimpleAsClause(returnAttributes, (TypeSyntax)node.Declaration.Type.Accept(TriviaConvertingVisitor)), null); } - TypeSyntax GetTypeSyntax(ITypeSymbol typeInfo) { + private TypeSyntax GetTypeSyntax(ITypeSymbol typeInfo) { return (TypeSyntax) _vbSyntaxGenerator.TypeExpression(typeInfo); } @@ -704,7 +704,7 @@ public override VisualBasicSyntaxNode VisitOperatorDeclaration(CSS.OperatorDecla - SyntaxKind ConvertOperatorDeclarationToken(CS.SyntaxKind syntaxKind, bool firstParameterIsString) + private SyntaxKind ConvertOperatorDeclarationToken(CS.SyntaxKind syntaxKind, bool firstParameterIsString) { switch (syntaxKind) { case CS.SyntaxKind.PlusToken: @@ -1033,7 +1033,7 @@ private static bool IsReturnValueDiscarded(CSS.ExpressionSyntax node) || node.Parent.IsParentKind(CS.SyntaxKind.SetAccessorDeclaration); } - AssignmentStatementSyntax MakeAssignmentStatement(CSS.AssignmentExpressionSyntax node) + private AssignmentStatementSyntax MakeAssignmentStatement(CSS.AssignmentExpressionSyntax node) { var kind = CS.CSharpExtensions.Kind(node).ConvertToken(TokenContext.Local); if (node.IsKind(CS.SyntaxKind.AndAssignmentExpression, CS.SyntaxKind.OrAssignmentExpression, CS.SyntaxKind.ExclusiveOrAssignmentExpression, CS.SyntaxKind.ModuloAssignmentExpression)) { @@ -1424,7 +1424,7 @@ public override VisualBasicSyntaxNode VisitSelectClause(CSS.SelectClauseSyntax n ); } - IEnumerable ConvertQueryBody(CSS.QueryBodySyntax body) + private IEnumerable ConvertQueryBody(CSS.QueryBodySyntax body) { if (body.SelectOrGroup is CSS.GroupClauseSyntax && body.Continuation == null) throw new NotSupportedException("group by clause without into not supported in VB"); @@ -1690,7 +1690,7 @@ public override VisualBasicSyntaxNode VisitTypeArgumentList(CSS.TypeArgumentList return SyntaxFactory.TypeArgumentList(SyntaxFactory.SeparatedList(node.Arguments.Select(a => (TypeSyntax)a.Accept(TriviaConvertingVisitor)))); } - VisualBasicSyntaxNode WrapTypedNameIfNecessary(ExpressionSyntax name, CSS.ExpressionSyntax originalName) + private VisualBasicSyntaxNode WrapTypedNameIfNecessary(ExpressionSyntax name, CSS.ExpressionSyntax originalName) { if (originalName.Parent is CSS.NameSyntax || originalName.Parent is CSS.AttributeSyntax diff --git a/Tests/UnicodeNewline.cs b/Tests/UnicodeNewline.cs index 166d5eb9c..35ded10f4 100644 --- a/Tests/UnicodeNewline.cs +++ b/Tests/UnicodeNewline.cs @@ -7,7 +7,7 @@ namespace CodeConverter.Tests #if NR6 public #endif - enum UnicodeNewline + internal enum UnicodeNewline { Unknown, @@ -56,7 +56,7 @@ enum UnicodeNewline #if NR6 public #endif - static class NewLine + internal static class NewLine { /// /// Carriage Return, U+000D diff --git a/Tests/Utils.cs b/Tests/Utils.cs index e4a8cba5c..e62fe77da 100644 --- a/Tests/Utils.cs +++ b/Tests/Utils.cs @@ -2,7 +2,7 @@ namespace CodeConverter.Tests { - static class Utils + internal static class Utils { internal static string HomogenizeEol(string str) { diff --git a/Vsix/CodeConversion.cs b/Vsix/CodeConversion.cs index 9f5653a25..30b6605e4 100644 --- a/Vsix/CodeConversion.cs +++ b/Vsix/CodeConversion.cs @@ -21,7 +21,7 @@ namespace CodeConverter.VsExtension { - class CodeConversion + internal class CodeConversion { public Func> GetOptions { get; } private readonly IAsyncServiceProvider _serviceProvider; diff --git a/Vsix/ConvertCSToVBCommand.cs b/Vsix/ConvertCSToVBCommand.cs index 8b78ab98e..10f79362f 100644 --- a/Vsix/ConvertCSToVBCommand.cs +++ b/Vsix/ConvertCSToVBCommand.cs @@ -52,7 +52,7 @@ public static ConvertCSToVBCommand Instance { /// /// Gets the service provider from the owner package. /// - IAsyncServiceProvider ServiceProvider { + private IAsyncServiceProvider ServiceProvider { get { return _package; } @@ -75,7 +75,7 @@ public static void Initialize(REConverterPackage package, OleMenuCommandService /// /// /// Must be called on the UI thread due to VS 2017's implementation of AddCommand which calls GetService - ConvertCSToVBCommand(REConverterPackage package, CodeConversion codeConversion, OleMenuCommandService commandService) + private ConvertCSToVBCommand(REConverterPackage package, CodeConversion codeConversion, OleMenuCommandService commandService) { ThreadHelper.ThrowIfNotOnUIThread(); this._package = package ?? throw new ArgumentNullException(nameof(package)); diff --git a/Vsix/ConvertVBToCSCommand.cs b/Vsix/ConvertVBToCSCommand.cs index d99f986a9..f5fd94c32 100644 --- a/Vsix/ConvertVBToCSCommand.cs +++ b/Vsix/ConvertVBToCSCommand.cs @@ -51,7 +51,7 @@ public static ConvertVBToCSCommand Instance { /// /// Gets the service provider from the owner package. /// - IAsyncServiceProvider ServiceProvider { + private IAsyncServiceProvider ServiceProvider { get { return _package; } @@ -74,7 +74,7 @@ public static void Initialize(REConverterPackage package, OleMenuCommandService /// /// /// Must be called on the UI thread due to VS 2017's implementation of AddCommand which calls GetService - ConvertVBToCSCommand(REConverterPackage package, CodeConversion codeConversion, OleMenuCommandService commandService) + private ConvertVBToCSCommand(REConverterPackage package, CodeConversion codeConversion, OleMenuCommandService commandService) { ThreadHelper.ThrowIfNotOnUIThread(); this._package = package ?? throw new ArgumentNullException(nameof(package)); diff --git a/Vsix/VsDocument.cs b/Vsix/VsDocument.cs index 69099febf..9aa67c5c8 100644 --- a/Vsix/VsDocument.cs +++ b/Vsix/VsDocument.cs @@ -3,7 +3,7 @@ namespace CodeConverter.VsExtension { - class VsDocument + internal class VsDocument { private readonly IVsProject _hierarchy; private readonly uint _itemId;