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

[StyleCleanUp] Address IDE Warnings Part 1 #10168

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 0 additions & 3 deletions src/Microsoft.DotNet.Wpf/src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,6 @@ dotnet_diagnostic.CSIsNull002.severity = suggestion
# IDE0005: Using directive is unnecessary.
dotnet_diagnostic.IDE0005.severity = suggestion

# IDE0017: Simplify object initialization
dotnet_diagnostic.IDE0017.severity = suggestion

# IDE0019: Use pattern matching to avoid as followed by a null check
dotnet_diagnostic.IDE0019.severity = suggestion

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -49,16 +49,22 @@ internal override bool IsDataSetCollectionProperty(PropertyDescriptor pd)
{
// lazy load the types for the offending PD's. They're internal, so
// we get them indirectly.
DataSet dataset = new DataSet();
dataset.Locale = System.Globalization.CultureInfo.InvariantCulture;
DataSet dataset = new DataSet
{
Locale = System.Globalization.CultureInfo.InvariantCulture
};

DataTable table1 = new DataTable("Table1");
table1.Locale = System.Globalization.CultureInfo.InvariantCulture;
DataTable table1 = new DataTable("Table1")
{
Locale = System.Globalization.CultureInfo.InvariantCulture
};
table1.Columns.Add("ID", typeof(int));
dataset.Tables.Add(table1);

DataTable table2 = new DataTable("Table2");
table2.Locale = System.Globalization.CultureInfo.InvariantCulture;
DataTable table2 = new DataTable("Table2")
{
Locale = System.Globalization.CultureInfo.InvariantCulture
};
table2.Columns.Add("ID", typeof(int));
dataset.Tables.Add(table2);

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -762,9 +762,10 @@ public override void WritePIMapping(XamlPIMappingNode xamlPIMappingNode)
if (addMapping)
{
ClrNamespaceAssemblyPair namespaceMapping = new ClrNamespaceAssemblyPair(xamlPIMappingNode.ClrNamespace,
xamlPIMappingNode.AssemblyName);

namespaceMapping.LocalAssembly = true;
xamlPIMappingNode.AssemblyName)
{
LocalAssembly = true
};
XamlTypeMapper.PITable[xamlPIMappingNode.XmlNamespace] = namespaceMapping;
XamlTypeMapper.InvalidateMappingCache(xamlPIMappingNode.XmlNamespace);
if (!_pass2 && BamlRecordWriter != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,14 @@ internal bool DoCompilation(string assemblyName, string language, string rootNam
{
bool ret = true;

CompilationUnit compUnit = new CompilationUnit(assemblyName, language, rootNamespace, fileList);
compUnit.Pass2 = isSecondPass;
CompilationUnit compUnit = new CompilationUnit(assemblyName, language, rootNamespace, fileList)
{
Pass2 = isSecondPass,

// Set some properties required by the CompilationUnit
compUnit.ApplicationFile = _applicationMarkup;
compUnit.SourcePath = _sourceDir;
// Set some properties required by the CompilationUnit
ApplicationFile = _applicationMarkup,
SourcePath = _sourceDir
};

//Set the properties required by MarkupCompiler

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1472,9 +1472,11 @@ private void GenerateOutputItemsForCompiledXamlFiles(ITaskItem[] inputXamlItemLi
{
TaskItem codeItem;

codeItem = new TaskItem();
codeItem.ItemSpec = genLangFilePath;

codeItem = new TaskItem
{
ItemSpec = genLangFilePath
};

outputCodeFileList.Add(codeItem);

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

bamlItem = new TaskItem();
bamlItem.ItemSpec = bamlFile;
bamlItem = new TaskItem
{
ItemSpec = bamlFile
};

//
// Transfer some special custom attributes from source task item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -790,8 +790,10 @@ private TaskItem GenerateBamlItem(string resolvedXamlfile, bool localizable, str
// Generate a TaskItem for it.
//

bamlItem = new TaskItem();
bamlItem.ItemSpec = bamlFile;
bamlItem = new TaskItem
{
ItemSpec = bamlFile
};

// Transfer the metadata value from source item to the generated baml item.
bamlItem.SetMetadata(SharedStrings.Localizable, localizable ? "True" : "False");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ public override bool Execute()
// Update the manifest file.
try
{
manifestWriter = new XmlTextWriter(appManifestFile, System.Text.Encoding.UTF8);
manifestWriter.Formatting = Formatting.Indented;
manifestWriter.Indentation = 4;
manifestWriter = new XmlTextWriter(appManifestFile, System.Text.Encoding.UTF8)
{
Formatting = Formatting.Indented,
Indentation = 4
};
manifestDocument.WriteTo(manifestWriter);
}
finally
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -114,15 +114,16 @@ internal static Quaternion InterpolateQuaternion(Quaternion from, Quaternion to,

internal static Rect InterpolateRect(Rect from, Rect to, Double progress)
{
Rect temp = new Rect();

// from + ((from - to) * progress)
temp.Location = new Point(
Rect temp = new Rect
{
// from + ((from - to) * progress)
Location = new Point(
from.Location.X + ((to.Location.X - from.Location.X) * progress),
from.Location.Y + ((to.Location.Y - from.Location.Y) * progress));
temp.Size = new Size(
from.Location.Y + ((to.Location.Y - from.Location.Y) * progress)),
Size = new Size(
from.Size.Width + ((to.Size.Width - from.Size.Width) * progress),
from.Size.Height + ((to.Size.Height - from.Size.Height) * progress));
from.Size.Height + ((to.Size.Height - from.Size.Height) * progress))
};

return temp;
}
Expand Down Expand Up @@ -563,14 +564,15 @@ internal static Quaternion ScaleQuaternion(Quaternion value, Double factor)

internal static Rect ScaleRect(Rect value, Double factor)
{
Rect temp = new Rect();

temp.Location = new Point(
Rect temp = new Rect
{
Location = new Point(
value.Location.X * factor,
value.Location.Y * factor);
temp.Size = new Size(
value.Location.Y * factor),
Size = new Size(
value.Size.Width * factor,
value.Size.Height * factor);
value.Size.Height * factor)
};

return temp;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -221,12 +221,13 @@ private CompositeFontParser(Stream fileStream)
/// </summary>
private XmlReader CreateXmlReader(Stream fileStream)
{
XmlReaderSettings settings = new XmlReaderSettings();

settings.CloseInput = true;
settings.IgnoreComments = true;
settings.IgnoreWhitespace = false;
settings.ProhibitDtd = true;
XmlReaderSettings settings = new XmlReaderSettings
{
CloseInput = true,
IgnoreComments = true,
IgnoreWhitespace = false,
ProhibitDtd = true
};

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -591,12 +591,13 @@ private void EnsureDownloader()
_byteRangeDownloader = new ByteRangeDownloader(_uri,
_tempFileStream,
_readEventHandles[(int)ReadEvent.ByteRangeReadEvent].SafeWaitHandle,
_tempFileMutex);

_byteRangeDownloader.Proxy = _originalRequest.Proxy;
_tempFileMutex)
{
Proxy = _originalRequest.Proxy,

_byteRangeDownloader.Credentials = _originalRequest.Credentials;
_byteRangeDownloader.CachePolicy = _originalRequest.CachePolicy;
Credentials = _originalRequest.Credentials,
CachePolicy = _originalRequest.CachePolicy
};

_byteRangesAvailable = new ArrayList(); // byte ranges that are downloaded
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -35,8 +35,10 @@ internal void Analyze(StylusPointCollection stylusPoints, double rSpan)

// Construct the lists of data points and nodes
_nodes.Add(0);
CDataPoint cdp0 = new CDataPoint();
cdp0.Index = 0;
CDataPoint cdp0 = new CDataPoint
{
Index = 0
};
//convert from Avalon to Himetric
Point point = (Point)stylusPoints[0];
point.X *= StrokeCollectionSerializer.AvalonToHimetricMultiplier;
Expand All @@ -54,8 +56,10 @@ internal void Analyze(StylusPointCollection stylusPoints, double rSpan)
//this is a unique point, add it
index++;

CDataPoint cdp = new CDataPoint();
cdp.Index = index;
CDataPoint cdp = new CDataPoint
{
Index = index
};

//convert from Avalon to Himetric
Point point2 = (Point)stylusPoints[i];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -508,11 +508,13 @@ StylusPointDescription reformatDescription
packetProperties[i].guid = propertyGuids[i];
propertyInfo = infosToUse[i];

MS.Win32.Recognizer.PROPERTY_METRICS propertyMetrics = new MS.Win32.Recognizer.PROPERTY_METRICS( );
propertyMetrics.nLogicalMin = propertyInfo.Minimum;
propertyMetrics.nLogicalMax = propertyInfo.Maximum;
propertyMetrics.Units = (int)(propertyInfo.Unit);
propertyMetrics.fResolution = propertyInfo.Resolution;
MS.Win32.Recognizer.PROPERTY_METRICS propertyMetrics = new MS.Win32.Recognizer.PROPERTY_METRICS
{
nLogicalMin = propertyInfo.Minimum,
nLogicalMax = propertyInfo.Maximum,
Units = (int)(propertyInfo.Unit),
fResolution = propertyInfo.Resolution
};
packetProperties[i].PropertyMetrics = propertyMetrics;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -836,12 +836,14 @@ private uint LoadDrawAttrsTable(Stream strm, GuidList guidList, uint cbSize)



// Create a new drawing attribute
DrawingAttributes attributes = new DrawingAttributes();
// pull off our defaults onthe drawing attribute as we need to
// respect what the ISF has.
attributes.DrawingFlags = 0;
cb = DrawingAttributeSerializer.DecodeAsISF(strm, guidList, cbDA, attributes);
// Create a new drawing attribute
DrawingAttributes attributes = new DrawingAttributes
{
// pull off our defaults onthe drawing attribute as we need to
// respect what the ISF has.
DrawingFlags = 0
};
cb = DrawingAttributeSerializer.DecodeAsISF(strm, guidList, cbDA, attributes);

// Load the stream into this attribute
if (cbSize < cbDA)
Expand Down Expand Up @@ -1107,9 +1109,10 @@ private uint DecodeMetricBlock(Stream strm, uint cbSize, out MetricBlock block)
cbTotal -= cb;

// now create new metric entry
MetricEntry entry = new MetricEntry();

entry.Tag = (KnownTagCache.KnownTagIndex)dw;
MetricEntry entry = new MetricEntry
{
Tag = (KnownTagCache.KnownTagIndex)dw
};

byte[] data = new byte[size];

Expand Down Expand Up @@ -1237,8 +1240,10 @@ internal static uint ReliableRead(Stream stream, byte[] buffer, uint requestedCo
/// <returns></returns>
private uint DecodeTransformBlock(Stream strm, KnownTagCache.KnownTagIndex tag, uint cbSize, bool useDoubles, out TransformDescriptor xform)
{
xform = new TransformDescriptor();
xform.Tag = tag;
xform = new TransformDescriptor
{
Tag = tag
};

uint cbRead = 0;
uint cbTotal = cbSize;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -575,8 +575,10 @@ public static LassoCrossing EmptyCrossing
{
get
{
LassoCrossing crossing = new LassoCrossing();
crossing.FIndices = StrokeFIndices.Empty;
LassoCrossing crossing = new LassoCrossing
{
FIndices = StrokeFIndices.Empty
};
return crossing;
}
}
Expand Down Expand Up @@ -714,9 +716,11 @@ protected override bool Filter(Point point)
if (!DoubleUtil.AreClose(i, intersection))
{
// Move points[i] to the intersection position
Point intersectionPoint = new Point(0, 0);
intersectionPoint.X = points[i].X + (intersection - i) * (points[i + 1].X - points[i].X);
intersectionPoint.Y = points[i].Y + (intersection - i) * (points[i + 1].Y - points[i].Y);
Point intersectionPoint = new Point(0, 0)
{
X = points[i].X + (intersection - i) * (points[i + 1].X - points[i].X),
Y = points[i].Y + (intersection - i) * (points[i + 1].Y - points[i].Y)
};
points[i] = intersectionPoint;
IsIncrementalLassoDirty = true;
}
Expand Down
Loading
Loading