Skip to content

Commit 8408fde

Browse files
authored
[StyleCleanUp] Address IDE Warnings Part 1 (#10168)
Fixes IDE0017: Use object initializers in src
1 parent 8137ca6 commit 8408fde

File tree

461 files changed

+12878
-8465
lines changed

Some content is hidden

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

461 files changed

+12878
-8465
lines changed

src/Microsoft.DotNet.Wpf/src/.editorconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ dotnet_diagnostic.CA5362.severity = suggestion
185185
# IDE0005: Using directive is unnecessary.
186186
dotnet_diagnostic.IDE0005.severity = suggestion
187187

188-
# IDE0017: Simplify object initialization
189-
dotnet_diagnostic.IDE0017.severity = suggestion
190-
191188
# IDE0030: Null check can be simplified
192189
dotnet_diagnostic.IDE0030.severity = suggestion
193190

src/Microsoft.DotNet.Wpf/src/Extensions/PresentationFramework-SystemData/SystemDataExtension.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,22 @@ internal override bool IsDataSetCollectionProperty(PropertyDescriptor pd)
4949
{
5050
// lazy load the types for the offending PD's. They're internal, so
5151
// we get them indirectly.
52-
DataSet dataset = new DataSet();
53-
dataset.Locale = System.Globalization.CultureInfo.InvariantCulture;
52+
DataSet dataset = new DataSet
53+
{
54+
Locale = System.Globalization.CultureInfo.InvariantCulture
55+
};
5456

55-
DataTable table1 = new DataTable("Table1");
56-
table1.Locale = System.Globalization.CultureInfo.InvariantCulture;
57+
DataTable table1 = new DataTable("Table1")
58+
{
59+
Locale = System.Globalization.CultureInfo.InvariantCulture
60+
};
5761
table1.Columns.Add("ID", typeof(int));
5862
dataset.Tables.Add(table1);
5963

60-
DataTable table2 = new DataTable("Table2");
61-
table2.Locale = System.Globalization.CultureInfo.InvariantCulture;
64+
DataTable table2 = new DataTable("Table2")
65+
{
66+
Locale = System.Globalization.CultureInfo.InvariantCulture
67+
};
6268
table2.Columns.Add("ID", typeof(int));
6369
dataset.Tables.Add(table2);
6470

src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/MarkupCompiler.cs

Lines changed: 163 additions & 96 deletions
Large diffs are not rendered by default.

src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/ParserExtension.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -762,9 +762,10 @@ public override void WritePIMapping(XamlPIMappingNode xamlPIMappingNode)
762762
if (addMapping)
763763
{
764764
ClrNamespaceAssemblyPair namespaceMapping = new ClrNamespaceAssemblyPair(xamlPIMappingNode.ClrNamespace,
765-
xamlPIMappingNode.AssemblyName);
766-
767-
namespaceMapping.LocalAssembly = true;
765+
xamlPIMappingNode.AssemblyName)
766+
{
767+
LocalAssembly = true
768+
};
768769
XamlTypeMapper.PITable[xamlPIMappingNode.XmlNamespace] = namespaceMapping;
769770
XamlTypeMapper.InvalidateMappingCache(xamlPIMappingNode.XmlNamespace);
770771
if (!_pass2 && BamlRecordWriter != null)

src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerWrapper.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,14 @@ internal bool DoCompilation(string assemblyName, string language, string rootNam
223223
{
224224
bool ret = true;
225225

226-
CompilationUnit compUnit = new CompilationUnit(assemblyName, language, rootNamespace, fileList);
227-
compUnit.Pass2 = isSecondPass;
226+
CompilationUnit compUnit = new CompilationUnit(assemblyName, language, rootNamespace, fileList)
227+
{
228+
Pass2 = isSecondPass,
228229

229-
// Set some properties required by the CompilationUnit
230-
compUnit.ApplicationFile = _applicationMarkup;
231-
compUnit.SourcePath = _sourceDir;
230+
// Set some properties required by the CompilationUnit
231+
ApplicationFile = _applicationMarkup,
232+
SourcePath = _sourceDir
233+
};
232234

233235
//Set the properties required by MarkupCompiler
234236

src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/MarkupCompilePass1.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,9 +1472,11 @@ private void GenerateOutputItemsForCompiledXamlFiles(ITaskItem[] inputXamlItemLi
14721472
{
14731473
TaskItem codeItem;
14741474

1475-
codeItem = new TaskItem();
1476-
codeItem.ItemSpec = genLangFilePath;
1477-
1475+
codeItem = new TaskItem
1476+
{
1477+
ItemSpec = genLangFilePath
1478+
};
1479+
14781480
outputCodeFileList.Add(codeItem);
14791481

14801482
Log.LogMessageFromResources(MessageImportance.Low, nameof(SR.GeneratedCodeFile), codeItem.ItemSpec);
@@ -1577,8 +1579,10 @@ private TaskItem GenerateBamlItem(string bamlFile, ITaskItem SourceItem)
15771579
{
15781580
TaskItem bamlItem;
15791581

1580-
bamlItem = new TaskItem();
1581-
bamlItem.ItemSpec = bamlFile;
1582+
bamlItem = new TaskItem
1583+
{
1584+
ItemSpec = bamlFile
1585+
};
15821586

15831587
//
15841588
// Transfer some special custom attributes from source task item

src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/MarkupCompilePass2.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,10 @@ private TaskItem GenerateBamlItem(string resolvedXamlfile, bool localizable, str
790790
// Generate a TaskItem for it.
791791
//
792792

793-
bamlItem = new TaskItem();
794-
bamlItem.ItemSpec = bamlFile;
793+
bamlItem = new TaskItem
794+
{
795+
ItemSpec = bamlFile
796+
};
795797

796798
// Transfer the metadata value from source item to the generated baml item.
797799
bamlItem.SetMetadata(SharedStrings.Localizable, localizable ? "True" : "False");

src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/UpdateManifestForBrowserApplication.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,11 @@ public override bool Execute()
117117
// Update the manifest file.
118118
try
119119
{
120-
manifestWriter = new XmlTextWriter(appManifestFile, System.Text.Encoding.UTF8);
121-
manifestWriter.Formatting = Formatting.Indented;
122-
manifestWriter.Indentation = 4;
120+
manifestWriter = new XmlTextWriter(appManifestFile, System.Text.Encoding.UTF8)
121+
{
122+
Formatting = Formatting.Indented,
123+
Indentation = 4
124+
};
123125
manifestDocument.WriteTo(manifestWriter);
124126
}
125127
finally

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/AnimatedTypeHelpers.cs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

@@ -114,15 +114,16 @@ internal static Quaternion InterpolateQuaternion(Quaternion from, Quaternion to,
114114

115115
internal static Rect InterpolateRect(Rect from, Rect to, Double progress)
116116
{
117-
Rect temp = new Rect();
118-
119-
// from + ((from - to) * progress)
120-
temp.Location = new Point(
117+
Rect temp = new Rect
118+
{
119+
// from + ((from - to) * progress)
120+
Location = new Point(
121121
from.Location.X + ((to.Location.X - from.Location.X) * progress),
122-
from.Location.Y + ((to.Location.Y - from.Location.Y) * progress));
123-
temp.Size = new Size(
122+
from.Location.Y + ((to.Location.Y - from.Location.Y) * progress)),
123+
Size = new Size(
124124
from.Size.Width + ((to.Size.Width - from.Size.Width) * progress),
125-
from.Size.Height + ((to.Size.Height - from.Size.Height) * progress));
125+
from.Size.Height + ((to.Size.Height - from.Size.Height) * progress))
126+
};
126127

127128
return temp;
128129
}
@@ -563,14 +564,15 @@ internal static Quaternion ScaleQuaternion(Quaternion value, Double factor)
563564

564565
internal static Rect ScaleRect(Rect value, Double factor)
565566
{
566-
Rect temp = new Rect();
567-
568-
temp.Location = new Point(
567+
Rect temp = new Rect
568+
{
569+
Location = new Point(
569570
value.Location.X * factor,
570-
value.Location.Y * factor);
571-
temp.Size = new Size(
571+
value.Location.Y * factor),
572+
Size = new Size(
572573
value.Size.Width * factor,
573-
value.Size.Height * factor);
574+
value.Size.Height * factor)
575+
};
574576

575577
return temp;
576578
}

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontFace/CompositeFontParser.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

@@ -221,12 +221,13 @@ private CompositeFontParser(Stream fileStream)
221221
/// </summary>
222222
private XmlReader CreateXmlReader(Stream fileStream)
223223
{
224-
XmlReaderSettings settings = new XmlReaderSettings();
225-
226-
settings.CloseInput = true;
227-
settings.IgnoreComments = true;
228-
settings.IgnoreWhitespace = false;
229-
settings.ProhibitDtd = true;
224+
XmlReaderSettings settings = new XmlReaderSettings
225+
{
226+
CloseInput = true,
227+
IgnoreComments = true,
228+
IgnoreWhitespace = false,
229+
ProhibitDtd = true
230+
};
230231

231232
XmlReader baseReader = XmlReader.Create(fileStream, settings);
232233

0 commit comments

Comments
 (0)