提交 81d37a65 编写于 作者: C Cyrus Najmabadi

Simplify collections. Make local functions static.

上级 f7a19b70
......@@ -47,8 +47,10 @@ public async Task MoveFile_SingleAction1()
var defaultNamespace = "A";
var declaredNamespace = "A.B.C";
var expectedFolders = new List<string[]>();
expectedFolders.Add(new[] { "B", "C" });
var expectedFolders = new List<string[]>
{
new[] { "B", "C" }
};
var documentPath = CreateDocumentFilePath(Array.Empty<string>());
var code =
......@@ -77,8 +79,10 @@ public async Task MoveFile_SingleAction2()
var defaultNamespace = "A";
var declaredNamespace = "A.B.C.D.E";
var expectedFolders = new List<string[]>();
expectedFolders.Add(new[] { "B", "C", "D", "E" });
var expectedFolders = new List<string[]>
{
new[] { "B", "C", "D", "E" }
};
var documentPath1 = CreateDocumentFilePath(Array.Empty<string>(), "File1.cs");
var documentPath2 = CreateDocumentFilePath(new[] { "B", "C" }, "File2.cs"); // file2 is in <root>\B\C\
......@@ -115,8 +119,10 @@ public async Task MoveFile_MoveToRoot()
var defaultNamespace = "";
var expectedFolders = new List<string[]>();
expectedFolders.Add(Array.Empty<string>());
var expectedFolders = new List<string[]>
{
Array.Empty<string>()
};
var documentPath = CreateDocumentFilePath(new[] { "A", "B", "C" });
var code =
......
......@@ -1910,7 +1910,7 @@ private static NamingStylePreferences NamesEndWithSuffixPreferences()
// Local functions
(SymbolSpecification specification, NamingStyle style) SpecificationStyle(SymbolKindOrTypeKind kind, string suffix)
static (SymbolSpecification specification, NamingStyle style) SpecificationStyle(SymbolKindOrTypeKind kind, string suffix)
{
var symbolSpecification = new SymbolSpecification(
id: null,
......@@ -1930,7 +1930,7 @@ private static NamingStylePreferences NamesEndWithSuffixPreferences()
return (symbolSpecification, namingStyle);
}
SerializableNamingRule CreateRule(SymbolSpecification specification, NamingStyle style)
static SerializableNamingRule CreateRule(SymbolSpecification specification, NamingStyle style)
{
return new SerializableNamingRule()
{
......
......@@ -323,7 +323,7 @@ static void Main()
// Test2.M2: adding a line in front of try-catch.
// Test2.F2: moving the entire method 2 lines down.
LinePositionSpan AddDelta(LinePositionSpan span, int lineDelta)
static LinePositionSpan AddDelta(LinePositionSpan span, int lineDelta)
=> new LinePositionSpan(new LinePosition(span.Start.Line + lineDelta, span.Start.Character), new LinePosition(span.End.Line + lineDelta, span.End.Character));
var newActiveStatementsInChangedDocuments = ImmutableArray.Create(
......
......@@ -512,7 +512,7 @@ protected override Compilation CreateCompilation(SyntaxTree tree)
protected override bool CompilationSucceeded(Compilation compilation, Stream temporaryStream)
{
var langCompilation = compilation;
bool isProblem(Diagnostic d) => d.Severity >= DiagnosticSeverity.Warning;
static bool isProblem(Diagnostic d) => d.Severity >= DiagnosticSeverity.Warning;
return !langCompilation.GetDiagnostics().Any(isProblem) &&
!langCompilation.Emit(temporaryStream).Diagnostics.Any(isProblem);
}
......
......@@ -248,8 +248,10 @@ private void EnsureSources()
{
if (_sources == null)
{
_sources = new Dictionary<object, AbstractTableEntriesSource<TItem>>();
_sources.Add(_primary.Key, _primary);
_sources = new Dictionary<object, AbstractTableEntriesSource<TItem>>
{
{ _primary.Key, _primary }
};
_primary = null;
}
}
......
......@@ -32,7 +32,7 @@ protected static void VerifyPropertyOutsideConfiguration(XElement projectElement
projectElement.Elements().Where(IsUnconditionalPropertyGroup),
group => GetPropertyValue(group, name) == value);
bool IsUnconditionalPropertyGroup(XElement element)
static bool IsUnconditionalPropertyGroup(XElement element)
=> element.Name.LocalName == "PropertyGroup" && !element.Attributes().Any(a => a.Name.LocalName == "Condition");
}
......@@ -42,7 +42,7 @@ protected static void VerifyPropertyInEachConfiguration(XElement projectElement,
projectElement.Elements().Where(IsConditionalPropertyGroup),
group => Assert.Equal(value, GetPropertyValue(group, name)));
bool IsConditionalPropertyGroup(XElement element)
static bool IsConditionalPropertyGroup(XElement element)
=> element.Name.LocalName == "PropertyGroup" && element.Attributes().Any(a => a.Name.LocalName == "Condition");
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册