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

Review unused locals across corefx #30457

Closed
stephentoub opened this issue Aug 1, 2019 · 24 comments · Fixed by #33619
Closed

Review unused locals across corefx #30457

stephentoub opened this issue Aug 1, 2019 · 24 comments · Fixed by #33619
Labels
area-Meta good first issue Issue should be easy to implement, good for first-time contributors help wanted [up-for-grabs] Good issue for external contributors
Milestone

Comments

@stephentoub
Copy link
Member

stephentoub commented Aug 1, 2019

Experimenting with various analyzers, I used SonarAnalyzers.CSharp to highlight all unused locals.

In dotnet/corefx#39956, I fixed some, but there remain a bunch across the repo. We could consider enabling the rule permanently, but there's enough noise that we may not want to. Even so, it'd probably be worth reviewing the remaining failures to ensure nothing important has slipped through.

D:\repos\corefx\src\Microsoft.Diagnostics.Tracing.EventSource.Redist\src\Microsoft.Diagnostics.Tracing.EventSource.Redist.csproj

  • D:\repos\corefx\src\Common\src\CoreLib\System\Diagnostics\Tracing\EventSource.cs(2698,18): warning S1481: Remove the unused local variable 'shouldReport'.
  • D:\repos\corefx\src\Common\src\CoreLib\System\Diagnostics\Tracing\EventSource.cs(3082,20): warning S1481: Remove the unused local variable 'fullTypeNameToFind'.

D:\repos\corefx\src\System.Configuration.ConfigurationManager\src\System.Configuration.ConfigurationManager.csproj

  • System\Configuration\ApplicationSettingsBase.cs(729,24): warning S1481: Remove the unused local variable 'temp'.

D:\repos\corefx\src\System.Data.Common\src\System.Data.Common.csproj

  • System\Data\DataColumnCollection.cs(807,28): warning S1481: Remove the unused local variable 'column'.
  • System\Data\xmlsaver.cs(1496,32): warning S1481: Remove the unused local variable 'prefix'.
  • System\Data\xmlsaver.cs(1497,36): warning S1481: Remove the unused local variable 'tNode'.
  • System\Data\xmlsaver.cs(2495,20): warning S1481: Remove the unused local variable 'val'.
  • System\Data\xmlsaver.cs(2782,17): warning S1481: Remove the unused local variable 'countTopTable'.
  • System\Data\xmlsaver.cs(952,24): warning S1481: Remove the unused local variable 'dsCompositor'.
  • System\Data\XMLSchema.cs(2368,28): warning S1481: Remove the unused local variable 'targetNamespace'.
  • System\Data\XMLSchema.cs(2540,17): warning S1481: Remove the unused local variable 'initialTableCount'.
  • System\Data\XMLSchema.cs(786,27): warning S1481: Remove the unused local variable 'table'.

D:\repos\corefx\src\System.Data.OleDb\src\System.Data.OleDb.csproj

  • OleDbConnection.cs(521,32): warning S1481: Remove the unused local variable 'exception'.
  • OleDbConnectionInternal.cs(324,29): warning S1481: Remove the unused local variable 'outerConnection'.
  • OleDbConnectionInternal.cs(824,18): warning S1481: Remove the unused local variable 'isopen'.
  • OleDbConnectionInternal.cs(825,35): warning S1481: Remove the unused local variable 'constr'.
  • OleDbDataAdapter.cs(267,50): warning S1481: Remove the unused local variable 'hresult'.
  • OleDbDataAdapter.cs(441,34): warning S1481: Remove the unused local variable 'hresult'.
  • OleDbDataReader.cs(1169,22): warning S1481: Remove the unused local variable 'info'.
  • OleDbDataReader.cs(2166,30): warning S1481: Remove the unused local variable 'nullsVal'.
  • OleDbTransaction.cs(111,34): warning S1481: Remove the unused local variable 'hr'.
  • RowBinding.cs(482,30): warning S1481: Remove the unused local variable 'hr'.
  • SafeHandles.cs(163,30): warning S1481: Remove the unused local variable 'hr'.

D:\repos\corefx\src\System.Data.SqlClient\src\System.Data.SqlClient.csproj

  • System\Data\Sql\SqlSer.cs(111,41): warning S1481: Remove the unused local variable 'udtAttr'.
  • System\Data\Sql\SqlSer.cs(31,20): warning S1481: Remove the unused local variable 'k'.
  • System\Data\SqlClient\SqlCommand.cs(3134,24): warning S1481: Remove the unused local variable 'val'.
  • System\Data\SqlClient\TdsParser.cs(6856,37): warning S1481: Remove the unused local variable 'metaData'.

D:\repos\corefx\src\System.DirectoryServices.AccountManagement\src\System.DirectoryServices.AccountManagement.csproj

  • System\DirectoryServices\AccountManagement\AD\ADStoreCtx.cs(1765,43): warning S1481: Remove the unused local variable 'adsGroup'.
  • System\DirectoryServices\AccountManagement\AD\ADStoreCtx.cs(2235,22): warning S1481: Remove the unused local variable 'ldapAttributesUsed'.
  • System\DirectoryServices\AccountManagement\AuthZSet.cs(47,20): warning S1481: Remove the unused local variable 'hUser'.
  • System\DirectoryServices\AccountManagement\SAM\SAMMembersSet.cs(104,26): warning S1481: Remove the unused local variable 'nativeMembers'.
  • System\DirectoryServices\AccountManagement\SAM\SAMStoreCtx_LoadStore.cs(787,20): warning S1481: Remove the unused local variable 'stringizedSid'.
  • System\DirectoryServices\AccountManagement\SAM\SAMUtils.cs(97,20): warning S1481: Remove the unused local variable 'className'.

D:\repos\corefx\src\System.DirectoryServices\src\System.DirectoryServices.csproj

  • System\DirectoryServices\ActiveDirectory\ActiveDirectorySchemaClass.cs(1001,22): warning S1481: Remove the unused local variable 'schemaGuid'.
  • System\DirectoryServices\ActiveDirectory\ActiveDirectorySchemaProperty.cs(1090,22): warning S1481: Remove the unused local variable 'schemaGuid'.
  • System\DirectoryServices\ActiveDirectory\ActiveDirectorySite.cs(1332,29): warning S1481: Remove the unused local variable 'status'.
  • System\DirectoryServices\ActiveDirectory\ActiveDirectorySite.cs(422,36): warning S1481: Remove the unused local variable 'tmp'.
  • System\DirectoryServices\ActiveDirectory\ConfigSet.cs(439,24): warning S1481: Remove the unused local variable 'entryName'.
  • System\DirectoryServices\ActiveDirectory\DirectoryServer.cs(112,28): warning S1481: Remove the unused local variable 'dn'.
  • System\DirectoryServices\ActiveDirectory\GlobalCatalog.cs(266,34): warning S1481: Remove the unused local variable 'schemaContext'.
  • System\DirectoryServices\ActiveDirectory\Utils.cs(1450,26): warning S1481: Remove the unused local variable 'propertiesToLoad2'.
  • System\DirectoryServices\ActiveDirectory\Utils.cs(692,21): warning S1481: Remove the unused local variable 'result'.
  • System\DirectoryServices\ActiveDirectory\Utils.cs(785,20): warning S1481: Remove the unused local variable 'crossRefDN'.
  • System\DirectoryServices\PropertyCollection.cs(113,50): warning S1481: Remove the unused local variable 'propList'.

D:\repos\corefx\src\System.Drawing.Common\src\System.Drawing.Common.csproj

  • System\Drawing\Pen.cs(586,27): warning S1481: Remove the unused local variable 'oldColor'.
  • System\Drawing\Printing\PrinterSettings.Windows.cs(489,29): warning S1481: Remove the unused local variable 'nRead'.
  • System\Drawing\SolidBrush.cs(103,27): warning S1481: Remove the unused local variable 'oldColor'.

D:\repos\corefx\src\System.IO.FileSystem.AccessControl\src\System.IO.FileSystem.AccessControl.csproj

  • System\Security\AccessControl\FileSecurity.cs(618,20): warning S1481: Remove the unused local variable 'fullPath'.
  • System\Security\AccessControl\FileSecurity.cs(645,20): warning S1481: Remove the unused local variable 'fullPath'.

D:\repos\corefx\src\System.IO.FileSystem.DriveInfo\src\System.IO.FileSystem.DriveInfo.csproj

  • D:\repos\corefx\src\Common\src\CoreLib\Interop\Unix\System.Native\Interop.MountPoints.cs(26,21): warning S1481: Remove the unused local variable 'result'.
  • System\IO\DriveInfo.Windows.cs(97,22): warning S1481: Remove the unused local variable 'success'.

D:\repos\corefx\src\System.IO.FileSystem\src\System.IO.FileSystem.csproj

  • D:\repos\corefx\src\Common\src\CoreLib\Interop\Unix\System.Native\Interop.MountPoints.cs(26,21): warning S1481: Remove the unused local variable 'result'.

D:\repos\corefx\src\System.IO.MemoryMappedFiles\src\System.IO.MemoryMappedFiles.csproj

  • System\IO\MemoryMappedFiles\MemoryMappedView.Windows.cs(65,24): warning S1481: Remove the unused local variable 'tempHandle'.

D:\repos\corefx\src\System.IO.Ports\src\System.IO.Ports.csproj

  • System\IO\Ports\SerialPort.cs(1015,17): warning S1481: Remove the unused local variable 'startTicks'.
  • System\IO\Ports\SerialPort.cs(1028,17): warning S1481: Remove the unused local variable 'beginReadPos'.

D:\repos\corefx\src\System.Management\src\System.Management.csproj

  • System\Management\ManagementObject.cs(2307,31): warning S1481: Remove the unused local variable 'wbemServices'.
  • System\Management\ManagementScope.cs(974,26): warning S1481: Remove the unused local variable 'loc'.
  • System\Management\ManagementScope.cs(975,20): warning S1481: Remove the unused local variable 'punk'.
  • System\Management\WMIGenerator.cs(3040,42): warning S1481: Remove the unused local variable 'isRetTypeTimeInterval'.
  • System\Management\WMIGenerator.cs(7349,40): warning S1481: Remove the unused local variable 'cmie3'.

D:\repos\corefx\src\System.Net.HttpListener\src\System.Net.HttpListener.csproj

  • System\Net\Windows\HttpListener.Windows.cs(764,20): warning S1481: Remove the unused local variable 'verb'.
  • System\Net\Windows\WebSockets\WebSocketProtocolComponent.cs(252,44): warning S1481: Remove the unused local variable 'responseHeaders'.

D:\repos\corefx\src\System.Net.Requests\src\System.Net.Requests.csproj

  • System\Net\FtpControlStream.cs(414,31): warning S1481: Remove the unused local variable 'request'.

D:\repos\corefx\src\System.Net.Security\src\System.Net.Security.csproj

  • System\Net\CertificateValidationPal.Unix.cs(62,21): warning S1481: Remove the unused local variable 'errorCode'.

D:\repos\corefx\src\System.Numerics.Tensors\src\System.Numerics.Tensors.csproj

  • System\Numerics\Tensors\Tensor.cs(1228,17): warning S1481: Remove the unused local variable 'outerLength'.

D:\repos\corefx\src\System.Private.DataContractSerialization\src\System.Private.DataContractSerialization.csproj

  • System\Runtime\Serialization\ReflectionXmlFormatReader.cs(58,20): warning S1481: Remove the unused local variable 'requiredMembers'.
  • System\Runtime\Serialization\SchemaExporter.cs(453,50): warning S1481: Remove the unused local variable 'extension'.
  • System\Runtime\Serialization\XmlFormatReaderGenerator.cs(122,26): warning S1481: Remove the unused local variable 'isFactoryType'.
  • System\Xml\XmlBufferReader.cs(494,20): warning S1481: Remove the unused local variable 'buffer'.
  • System\Xml\XmlBufferReader.cs(503,20): warning S1481: Remove the unused local variable 'buffer'.
  • System\Xml\XmlBufferReader.cs(847,20): warning S1481: Remove the unused local variable 'buffer'.

D:\repos\corefx\src\System.Private.Xml\src\System.Private.Xml.csproj

  • System\Xml\Core\XsdValidatingReader.cs(1440,17): warning S1481: Remove the unused local variable 'startDepth'.
  • System\Xml\Core\XsdValidatingReaderAsync.cs(337,17): warning S1481: Remove the unused local variable 'startDepth'.
  • System\Xml\Dom\XmlNode.cs(469,21): warning S1481: Remove the unused local variable 'node'.
  • System\Xml\Dom\XmlNode.cs(838,29): warning S1481: Remove the unused local variable 'doc'.
  • System\Xml\Schema\ContentValidator.cs(1317,17): warning S1481: Remove the unused local variable 'symbolsCount'.
  • System\Xml\Schema\ContentValidator.cs(1922,17): warning S1481: Remove the unused local variable 'positionsCount'.
  • System\Xml\Schema\FacetChecker.cs(471,35): warning S1481: Remove the unused local variable 'baseRestriction'.
  • System\Xml\Schema\Inference\Infer.cs(927,42): warning S1481: Remove the unused local variable 'subelement'.
  • System\Xml\Schema\Inference\Infer.cs(936,42): warning S1481: Remove the unused local variable 'subelement'.
  • System\Xml\Schema\Inference\Infer.cs(948,42): warning S1481: Remove the unused local variable 'subelement'.
  • System\Xml\Serialization\Compiler.cs(81,26): warning S1481: Remove the unused local variable 'originalAssembly'.
  • System\Xml\Serialization\ReflectionXmlSerializationReader.cs(1760,33): warning S1481: Remove the unused local variable 'allMemberMappings'.
  • System\Xml\Serialization\ReflectionXmlSerializationWriter.cs(1257,35): warning S1481: Remove the unused local variable 'member'.
  • System\Xml\Serialization\ReflectionXmlSerializationWriter.cs(206,24): warning S1481: Remove the unused local variable 'enumTypeName'.
  • System\Xml\Serialization\ReflectionXmlSerializationWriter.cs(363,30): warning S1481: Remove the unused local variable 'arrayTypeDesc'.
  • System\Xml\Serialization\SchemaObjectWriter.cs(1036,25): warning S1481: Remove the unused local variable 't'.
  • System\Xml\Serialization\SchemaObjectWriter.cs(1091,25): warning S1481: Remove the unused local variable 't'.
  • System\Xml\Serialization\SchemaObjectWriter.cs(1117,25): warning S1481: Remove the unused local variable 't'.
  • System\Xml\Serialization\SchemaObjectWriter.cs(1139,25): warning S1481: Remove the unused local variable 't'.
  • System\Xml\Serialization\SchemaObjectWriter.cs(974,25): warning S1481: Remove the unused local variable 't'.
  • System\Xml\Serialization\XmlReflectionImporter.cs(1564,30): warning S1481: Remove the unused local variable 'targetTypeDesc'.
  • System\Xml\Serialization\XmlSerializationReader.cs(188,20): warning S1481: Remove the unused local variable 'ns'.
  • System\Xml\Serialization\XmlSerializationReader.cs(189,20): warning S1481: Remove the unused local variable 'ns2'.
  • System\Xml\Serialization\XmlSerializationReader.cs(2118,35): warning S1481: Remove the unused local variable 'elements'.
  • System\Xml\Serialization\XmlSerializationReader.cs(3428,18): warning S1481: Remove the unused local variable 'useReflection'.
  • System\Xml\Serialization\XmlSerializationReader.cs(3568,18): warning S1481: Remove the unused local variable 'useReflection'.
  • System\Xml\Serialization\XmlSerializationWriter.cs(1877,22): warning S1481: Remove the unused local variable 'saveTypeDesc'.
  • System\Xml\Serialization\XmlSerializationWriter.cs(2564,35): warning S1481: Remove the unused local variable 'member'.
  • System\Xml\Serialization\XmlSerializationWriter.cs(3434,22): warning S1481: Remove the unused local variable 'choiceUseReflection'.
  • System\Xml\Serialization\XmlSerializationWriter.cs(3681,30): warning S1481: Remove the unused local variable 'useReflection'.
  • System\Xml\Serialization\XmlSerializationWriter.cs(4064,22): warning S1481: Remove the unused local variable 'useReflection'.
  • System\Xml\Serialization\XmlSerializationWriter.cs(4066,24): warning S1481: Remove the unused local variable 'fullTypeName'.
  • System\Xml\Serialization\XmlSerializationWriterILGen.cs(1629,32): warning S1481: Remove the unused local variable 'fullTypeName'.
  • System\Xml\Serialization\XmlSerializationWriterILGen.cs(1656,28): warning S1481: Remove the unused local variable 'fullTypeName'.
  • System\Xml\Serialization\XmlSerializationWriterILGen.cs(1798,28): warning S1481: Remove the unused local variable 'fullTypeName'.
  • System\Xml\Serialization\XmlSerializationWriterILGen.cs(1916,24): warning S1481: Remove the unused local variable 'fullTypeName'.
  • System\Xml\Serialization\XmlSerializationWriterILGen.cs(2022,24): warning S1481: Remove the unused local variable 'fullTypeName'.
  • System\Xml\Serialization\XmlSerializationWriterILGen.cs(2318,26): warning S1481: Remove the unused local variable 'typeDesc'.
  • System\Xml\Serialization\XmlSerializationWriterILGen.cs(394,35): warning S1481: Remove the unused local variable 'member'.
  • System\Xml\Xsl\Xslt\CompilerScopeManager.cs(277,36): warning S1481: Remove the unused local variable 'prevFlags'.
  • System\Xml\Xsl\Xslt\QilGenerator.cs(2345,17): warning S1481: Remove the unused local variable 'startPos'.
  • System\Xml\Xsl\Xslt\XsltLoader.cs(1936,18): warning S1481: Remove the unused local variable 'isParam'.
  • System\Xml\Xsl\Xslt\XsltLoader.cs(2154,20): warning S1481: Remove the unused local variable 'collation'.
  • System\Xml\Xsl\Xslt\XsltLoader.cs(474,25): warning S1481: Remove the unused local variable 'ctxInfo'.
  • System\Xml\Xsl\Xslt\XsltLoader.cs(503,25): warning S1481: Remove the unused local variable 'ctxInfo'.
  • System\Xml\Xsl\Xslt\XsltLoader.cs(573,25): warning S1481: Remove the unused local variable 'ctxInfo'.
  • System\Xml\Xsl\Xslt\XsltLoader.cs(849,20): warning S1481: Remove the unused local variable 'collation'.
  • System\Xml\Xsl\XsltOld\CopyAction.cs(40,20): warning S1481: Remove the unused local variable 'value'.

D:\repos\corefx\src\System.Runtime.Extensions\src\System.Runtime.Extensions.csproj

  • D:\repos\corefx\src\Common\src\CoreLib\Interop\Unix\System.Native\Interop.MountPoints.cs(26,21): warning S1481: Remove the unused local variable 'result'.

D:\repos\corefx\src\System.Runtime.Serialization.Formatters\src\System.Runtime.Serialization.Formatters.csproj

  • System\Runtime\Serialization\Formatters\Binary\BinaryFormatterWriter.cs(257,17): warning S1481: Remove the unused local variable 'byteLength'.
  • System\Runtime\Serialization\Formatters\Binary\BinaryObjectReader.cs(358,18): warning S1481: Remove the unused local variable 'genId'.
  • System\Runtime\Serialization\Formatters\Binary\BinaryObjectReader.cs(702,20): warning S1481: Remove the unused local variable 'objName'.
  • System\Runtime\Serialization\ObjectManager.cs(282,26): warning S1481: Remove the unused local variable 'originalHolder'.

D:\repos\corefx\src\System.Runtime.WindowsRuntime.UI.Xaml\src\System.Runtime.WindowsRuntime.UI.Xaml.csproj

  • System\Windows\GridLength.cs(118,18): warning S1481: Remove the unused local variable 'listSeparator'.

D:\repos\corefx\src\System.Runtime.WindowsRuntime\src\System.Runtime.WindowsRuntime.csproj

  • System\Threading\WindowsRuntimeSynchronizationContext.cs(121,17): warning S1481: Remove the unused local variable 'ignored'.
  • System\Threading\WindowsRuntimeSynchronizationContext.cs(146,17): warning S1481: Remove the unused local variable 'ignored'.

D:\repos\corefx\src\System.Security.AccessControl\src\System.Security.AccessControl.csproj

  • System\Security\AccessControl\ACL.cs(603,24): warning S1481: Remove the unused local variable 'ace'.
  • System\Security\AccessControl\SecurityDescriptor.cs(291,17): warning S1481: Remove the unused local variable 'length'.

D:\repos\corefx\src\System.Security.Cryptography.Algorithms\src\System.Security.Cryptography.Algorithms.csproj

  • D:\repos\corefx\src\Common\src\System\Security\Cryptography\Asn1Reader\AsnReader.cs(105,21): warning S1481: Remove the unused local variable 'tag'.
  • D:\repos\corefx\src\Common\src\System\Security\Cryptography\Asn1Reader\AsnReader.cs(130,21): warning S1481: Remove the unused local variable 'tag'.

D:\repos\corefx\src\System.Security.Cryptography.Cng\src\System.Security.Cryptography.Cng.csproj

  • D:\repos\corefx\src\Common\src\System\Security\Cryptography\Asn1Reader\AsnReader.cs(105,21): warning S1481: Remove the unused local variable 'tag'.
  • D:\repos\corefx\src\Common\src\System\Security\Cryptography\Asn1Reader\AsnReader.cs(130,21): warning S1481: Remove the unused local variable 'tag'.
  • System\Security\Cryptography\ECDiffieHellmanCng.Key.cs(85,28): warning S1481: Remove the unused local variable 'key'.
  • System\Security\Cryptography\ECDsaCng.Key.cs(73,28): warning S1481: Remove the unused local variable 'key'.

D:\repos\corefx\src\System.Security.Cryptography.Csp\src\System.Security.Cryptography.Csp.csproj

  • D:\repos\corefx\src\Common\src\Interop\Windows\Advapi32\SafeProvHandle.cs(113,22): warning S1481: Remove the unused local variable 'ignoredSuccess'.
  • System\Security\Cryptography\CapiHelper.DSA.Shared.cs(181,29): warning S1481: Remove the unused local variable 'magic'.
  • System\Security\Cryptography\CapiHelper.DSA.Shared.cs(223,29): warning S1481: Remove the unused local variable 'magic'.
  • System\Security\Cryptography\CapiHelper.DSA.Shared.cs(282,18): warning S1481: Remove the unused local variable 'bType'.
  • System\Security\Cryptography\CapiHelper.Shared.cs(166,22): warning S1481: Remove the unused local variable 'bType'.
  • System\Security\Cryptography\CapiHelper.Shared.cs(167,22): warning S1481: Remove the unused local variable 'bVersion'.
  • System\Security\Cryptography\CapiHelper.Shared.cs(173,21): warning S1481: Remove the unused local variable 'magic'.

D:\repos\corefx\src\System.Security.Cryptography.Encoding\src\System.Security.Cryptography.Encoding.csproj

  • D:\repos\corefx\src\Common\src\System\Security\Cryptography\Asn1Reader\AsnReader.cs(105,21): warning S1481: Remove the unused local variable 'tag'.
  • D:\repos\corefx\src\Common\src\System\Security\Cryptography\Asn1Reader\AsnReader.cs(130,21): warning S1481: Remove the unused local variable 'tag'.

D:\repos\corefx\src\System.Security.Cryptography.OpenSsl\src\System.Security.Cryptography.OpenSsl.csproj

  • D:\repos\corefx\src\Common\src\System\Security\Cryptography\Asn1Reader\AsnReader.cs(105,21): warning S1481: Remove the unused local variable 'tag'.
  • D:\repos\corefx\src\Common\src\System\Security\Cryptography\Asn1Reader\AsnReader.cs(130,21): warning S1481: Remove the unused local variable 'tag'.

D:\repos\corefx\src\System.Security.Cryptography.Pkcs\src\System.Security.Cryptography.Pkcs.csproj

  • D:\repos\corefx\src\Common\src\Interop\Windows\Advapi32\SafeProvHandle.cs(113,22): warning S1481: Remove the unused local variable 'ignoredSuccess'.
  • D:\repos\corefx\src\Common\src\System\Security\Cryptography\Asn1Reader\AsnReader.cs(105,21): warning S1481: Remove the unused local variable 'tag'.
  • D:\repos\corefx\src\Common\src\System\Security\Cryptography\Asn1Reader\AsnReader.cs(130,21): warning S1481: Remove the unused local variable 'tag'.
  • Internal\Cryptography\Pal\Windows\PkcsPalWindows.Encrypt.cs(73,21): warning S1481: Remove the unused local variable 'tag'.

D:\repos\corefx\src\System.Security.Cryptography.X509Certificates\src\System.Security.Cryptography.X509Certificates.csproj

  • D:\repos\corefx\src\Common\src\System\Security\Cryptography\Asn1Reader\AsnReader.cs(105,21): warning S1481: Remove the unused local variable 'tag'.
  • D:\repos\corefx\src\Common\src\System\Security\Cryptography\Asn1Reader\AsnReader.cs(130,21): warning S1481: Remove the unused local variable 'tag'.
  • Internal\Cryptography\Pal.Windows\CertificatePal.PrivateKey.cs(248,25): warning S1481: Remove the unused local variable 'dwErrorCode'.
  • Internal\Cryptography\Pal.Windows\Native\SafeHandles.cs(188,30): warning S1481: Remove the unused local variable 'success'.
  • Internal\Cryptography\Pal.Windows\StorePal.Import.cs(167,18): warning S1481: Remove the unused local variable 'ignore'.
  • System\Security\Cryptography\X509Certificates\X509Certificate2.cs(362,20): warning S1481: Remove the unused local variable 'fullPath'.

D:\repos\corefx\src\System.Security.Cryptography.Xml\src\System.Security.Cryptography.Xml.csproj

  • System\Security\Cryptography\Xml\SignedXml.cs(418,20): warning S1481: Remove the unused local variable 'hashvalue'.

D:\repos\corefx\src\System.Security.Principal.Windows\src\System.Security.Principal.Windows.csproj

  • System\Security\Principal\WindowsIdentity.cs(625,30): warning S1481: Remove the unused local variable 'groupCount'.

D:\repos\corefx\src\System.ServiceModel.Syndication\src\System.ServiceModel.Syndication.csproj

  • System\ServiceModel\Syndication\Atom10FeedFormatter.cs(606,20): warning S1481: Remove the unused local variable 'localName'.
  • System\ServiceModel\Syndication\Atom10FeedFormatter.cs(607,20): warning S1481: Remove the unused local variable 'nameSpace'.

D:\repos\corefx\src\System.ServiceProcess.ServiceController\src\System.ServiceProcess.ServiceController.csproj

  • System\ServiceProcess\ServiceBase.cs(484,22): warning S1481: Remove the unused local variable 'statusResult'.
@stephentoub stephentoub changed the title Unused locals across corefx Review unused locals across corefx Aug 1, 2019
@danmoseley
Copy link
Member

Just curious does it affect the code gen?

@stephentoub
Copy link
Member Author

Just curious does it affect the code gen?

It depends. If it's just about an unused local, then no, it shouldn't. But some of the cases I fixed in my PR were, for example, initializing unused locals with allocations, or invoking properties or methods or delegates to initialize them. Those require more analysis to validate they can be removed safely (in some cases the side effects are important), but when they can be removed, obviously they effect code gen.

@vcsjones
Copy link
Member

vcsjones commented Oct 18, 2019

@bartonjs I went through the S.S.C ones, I'm not sure about one of them: The DSA magic field isn't checked here:

https://github.com/dotnet/corefx/blob/b8048a1e2bd7ee776b4cb6df684db3a0b35886c1/src/System.Security.Cryptography.Csp/src/System/Security/Cryptography/CapiHelper.DSA.Shared.cs#L181

Should there be checks that it is DSS1 - DSS4 magic values?

@bartonjs
Copy link
Member

Seems reasonable to at least assert it :)

@eriawan
Copy link
Member

eriawan commented Oct 21, 2019

@stephentoub

I'll take the System.Data.Common. PR is ready: dotnet/corefx#41962

eriawan referenced this issue in eriawan/corefx Nov 8, 2019
@eriawan
Copy link
Member

eriawan commented Nov 8, 2019

@stephentoub

PR on removing unused variables on System.Data.OleDb is submitted: dotnet/corefx#42485

ghost referenced this issue in dotnet/corefx Nov 13, 2019
* emove unused locals in System.Data.OleDband keep some logic using discard. Partially fix issue #39962

* Update src/System.Data.OleDb/src/OleDbDataReader.cs

update as suggested (OleDbDataReader)

Co-Authored-By: Stephen Toub <[email protected]>

* Update src/System.Data.OleDb/src/OleDbTransaction.cs

Done update as suggested

Co-Authored-By: Stephen Toub <[email protected]>

* Update src/System.Data.OleDb/src/RowBinding.cs

Done update as suggested (RowDataBinding)

Co-Authored-By: Stephen Toub <[email protected]>

* Update src/System.Data.OleDb/src/RowBinding.cs

Done as suggested

Co-Authored-By: Stephen Toub <[email protected]>

* Update src/System.Data.OleDb/src/SafeHandles.cs

Done updating as suggested (SafeHandles)

Co-Authored-By: Stephen Toub <[email protected]>
@eriawan
Copy link
Member

eriawan commented Jan 13, 2020

@stephentoub

Now that we have dotnet/runtime repo, I think we have to transfer/move this issue to dotnet/runtime repo for more visibility and tracking this to .NET Core 5.0, because I also think the progress on this issue is valid for .NET Core 5.0 milestone, cmiiw.

Could we move/transfer this issue to https://github.com/dotnet/runtime repo?

@stephentoub
Copy link
Member Author

All issues are going to be transferred in bulk.

@eriawan
Copy link
Member

eriawan commented Jan 13, 2020

@stephentoub
Thanks for the quick reply! 🙂
I'm glad to know we'll move the issues here to dotnet/runtime.

Just for tracking update, if you don't mind could you also update the finished/merged progress on System.Data.OleDb check marks? Thanks in advance.

@msftgits msftgits transferred this issue from dotnet/corefx Feb 1, 2020
@msftgits msftgits added this to the Future milestone Feb 1, 2020
@maryamariyan maryamariyan added the untriaged New issue has not been triaged by the area owner label Feb 23, 2020
@stephentoub stephentoub removed the untriaged New issue has not been triaged by the area owner label Feb 25, 2020
@alanisaac
Copy link
Contributor

@stephentoub

Submitted #32896 for System.IO.Ports.

handlespeed added a commit to handlespeed/runtime that referenced this issue Mar 16, 2020
src/libraries/System.Net.Requests/src/System/Net/FtpControlStream.cs, remove unused variable 'request' in L414.

Partially Fix dotnet#30457
@handlespeed
Copy link
Contributor

@stephentoub
Submitted #33619 for System.Net.Requests, thanks.

stephentoub pushed a commit that referenced this issue Mar 16, 2020
…3619)

src/libraries/System.Net.Requests/src/System/Net/FtpControlStream.cs, remove unused variable 'request' in L414.

Partially Fix #30457
@MattKotsenas
Copy link
Member

Hey @stephentoub @danmosemsft ! With the PRs I opened Friday / today, all the issues listed in this issue have been addressed. How would you like to proceed?

Since keeping this rule clean isn't enforced I would assume new issues will / have crept in, but even so, my vote would be to close this issue to avoid accumulating mentions forever, and if desired open a new issue to track turning on enforcement.

If you disagree or have anything you'd like me to follow up on, please let me know. Thanks!

@bartonjs
Copy link
Member

Closing the issue once all the PRs are merged seems fine to me.

KimKiHyuk added a commit to KimKiHyuk/runtime that referenced this issue Aug 7, 2020
MattKotsenas added a commit to MattKotsenas/runtime that referenced this issue Aug 10, 2020
Remove unused locals and private methods in
System.ServiceProcess.ServiceController.

This fixes a part of dotnet#30457.
danmoseley pushed a commit that referenced this issue Aug 11, 2020
Remove unused locals and private methods in
System.ServiceProcess.ServiceController.

This fixes a part of #30457.
hiMinju added a commit to hiMinju/runtime that referenced this issue Aug 12, 2020
dotnet#30457 
In line 292, remove the unused variable 'length'.

Thanks.
danmoseley pushed a commit that referenced this issue Aug 12, 2020
#30457 
In line 292, remove the unused variable 'length'.

Thanks.
jkotas pushed a commit that referenced this issue Aug 23, 2020
issue #30457
remove unused local variable dwErrorCode at line 248
danmoseley pushed a commit that referenced this issue Aug 24, 2020
* remove unused local

issue #30457
remove unused local variable fullPath at line 415

* Update src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs

Co-authored-by: Kevin Gosse <[email protected]>

Co-authored-by: Kevin Gosse <[email protected]>
@MattKotsenas
Copy link
Member

Hi @bartonjs! I believe all the outstanding PRs for this are now merged; it would be great if we could either close this issue out, or update it with what's remaining.

If you have any questions, please let me know. Thanks!

@stephentoub
Copy link
Member Author

Thanks, @MattKotsenas (and to all who contributed here). I just re-ran the analyzer over the repo, and while there were a few remaining occurrences, it was only a small number. I submitted a PR to fix the only impactful one (#42778). Since we're not currently planning on enabling this analyzer, we don't need to be 100% clean, and we can close the issue. Thanks!

@danmoseley
Copy link
Member

@stephentoub I missed or don't see the discussion about enabling it. Is there any reason we can't safely "baseline" everything remaining by using a discard, and then enable the analyzer?

@stephentoub
Copy link
Member Author

and then enable the analyzer?

It would mean pulling a 3rd-party analyzer into the repo, which means someone else's arbitrary code would run on every build on every dev's machine and in CI. We need to have a longer discussion before we do such a thing.

@danmoseley
Copy link
Member

Ah I missed that aspect

@ghost ghost locked as resolved and limited conversation to collaborators Dec 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Meta good first issue Issue should be easy to implement, good for first-time contributors help wanted [up-for-grabs] Good issue for external contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.