runtime: Lots of duplicate *.cs files in corefx

I wrote a small script to detect duplicates and it turns out there lots of such files in the repository When I try to re-use some of the following files in mono I am confused which one to pick Also the script detects files with a very small diff (see second group) Is it intentional?

ExternDll.cs:
   src\System.DirectoryServices\src\System\DirectoryServices\ExternDll.cs
   src\System.DirectoryServices.AccountManagement\src\System\DirectoryServices\AccountManagement\ExternDll.cs

Interop.IOErrors.cs:
   src\Common\src\CoreLib\Interop\Unix\Interop.IOErrors.cs
   src\Common\src\Interop\Unix\Interop.IOErrors.cs

Interop.Close.cs:
   src\Common\src\CoreLib\Interop\Unix\System.Native\Interop.Close.cs
   src\Common\src\Interop\Unix\System.Native\Interop.Close.cs

Interop.FLock.cs:
   src\Common\src\CoreLib\Interop\Unix\System.Native\Interop.FLock.cs
   src\Common\src\Interop\Unix\System.Native\Interop.FLock.cs

Interop.FSync.cs:
   src\Common\src\CoreLib\Interop\Unix\System.Native\Interop.FSync.cs
   src\Common\src\Interop\Unix\System.Native\Interop.FSync.cs

Interop.FTruncate.cs:
   src\Common\src\CoreLib\Interop\Unix\System.Native\Interop.FTruncate.cs
   src\Common\src\Interop\Unix\System.Native\Interop.FTruncate.cs

Interop.GetCwd.cs:
   src\Common\src\CoreLib\Interop\Unix\System.Native\Interop.GetCwd.cs
   src\Common\src\Interop\Unix\System.Native\Interop.GetCwd.cs

Interop.LSeek.cs:
   src\Common\src\CoreLib\Interop\Unix\System.Native\Interop.LSeek.cs
   src\Common\src\Interop\Unix\System.Native\Interop.LSeek.cs

Interop.MksTemps.cs:
   src\Common\src\CoreLib\Interop\Unix\System.Native\Interop.MksTemps.cs
   src\Common\src\Interop\Unix\System.Native\Interop.MksTemps.cs

Interop.Open.cs:
   src\Common\src\CoreLib\Interop\Unix\System.Native\Interop.Open.cs
   src\Common\src\Interop\Unix\System.Native\Interop.Open.cs

Interop.OpenFlags.cs:
   src\Common\src\CoreLib\Interop\Unix\System.Native\Interop.OpenFlags.cs
   src\Common\src\Interop\Unix\System.Native\Interop.OpenFlags.cs

Interop.PathConf.cs:
   src\Common\src\CoreLib\Interop\Unix\System.Native\Interop.PathConf.cs
   src\Common\src\Interop\Unix\System.Native\Interop.PathConf.cs

Interop.Permissions.cs:
   src\Common\src\CoreLib\Interop\Unix\System.Native\Interop.Permissions.cs
   src\Common\src\Interop\Unix\System.Native\Interop.Permissions.cs

Interop.PosixFAdvise.cs:
   src\Common\src\CoreLib\Interop\Unix\System.Native\Interop.PosixFAdvise.cs
   src\Common\src\Interop\Unix\System.Native\Interop.PosixFAdvise.cs

Interop.ReadLink.cs:
   src\Common\src\CoreLib\Interop\Unix\System.Native\Interop.ReadLink.cs
   src\Common\src\Interop\Unix\System.Native\Interop.ReadLink.cs

Interop.Stat.cs:
   src\Common\src\CoreLib\Interop\Unix\System.Native\Interop.Stat.cs
   src\Common\src\Interop\Unix\System.Native\Interop.Stat.cs

Interop.SysLog.cs:
   src\Common\src\CoreLib\Interop\Unix\System.Native\Interop.SysLog.cs
   src\Common\src\Interop\Unix\System.Native\Interop.SysLog.cs

Interop.Unlink.cs:
   src\Common\src\CoreLib\Interop\Unix\System.Native\Interop.Unlink.cs
   src\Common\src\Interop\Unix\System.Native\Interop.Unlink.cs

Interop.BOOL.cs:
   src\Common\src\CoreLib\Interop\Windows\Interop.BOOL.cs
   src\Common\src\Interop\Windows\Interop.BOOL.cs

Interop.CancelIoEx.cs:
   src\Common\src\CoreLib\Interop\Windows\Kernel32\Interop.CancelIoEx.cs
   src\Common\src\Interop\Windows\kernel32\Interop.CancelIoEx.cs

Interop.CloseHandle.cs:
   src\Common\src\CoreLib\Interop\Windows\Kernel32\Interop.CloseHandle.cs
   src\Common\src\Interop\Windows\kernel32\Interop.CloseHandle.cs

Interop.FileAttributes.cs:
   src\Common\src\CoreLib\Interop\Windows\Kernel32\Interop.FileAttributes.cs
   src\Common\src\Interop\Windows\kernel32\Interop.FileAttributes.cs

Interop.FindClose.cs:
   src\Common\src\CoreLib\Interop\Windows\Kernel32\Interop.FindClose.cs
   src\Common\src\Interop\Windows\kernel32\Interop.FindClose.cs

Interop.FlushFileBuffers.cs:
   src\Common\src\CoreLib\Interop\Windows\Kernel32\Interop.FlushFileBuffers.cs
   src\Common\src\Interop\Windows\kernel32\Interop.FlushFileBuffers.cs

Interop.ReadFile_SafeHandle_IntPtr.cs:
   src\Common\src\CoreLib\Interop\Windows\Kernel32\Interop.ReadFile_SafeHandle_IntPtr.cs
   src\Common\src\Interop\Windows\kernel32\Interop.ReadFile_SafeHandle_IntPtr.cs

Interop.ReadFile_SafeHandle_NativeOverlapped.cs:
   src\Common\src\CoreLib\Interop\Windows\Kernel32\Interop.ReadFile_SafeHandle_NativeOverlapped.cs
   src\Common\src\Interop\Windows\kernel32\Interop.ReadFile_SafeHandle_NativeOverlapped.cs

Interop.SecurityOptions.cs:
   src\Common\src\CoreLib\Interop\Windows\Kernel32\Interop.SecurityOptions.cs
   src\Common\src\Interop\Windows\kernel32\Interop.SecurityOptions.cs

Interop.SetEndOfFile.cs:
   src\Common\src\CoreLib\Interop\Windows\Kernel32\Interop.SetEndOfFile.cs
   src\Common\src\Interop\Windows\kernel32\Interop.SetEndOfFile.cs

Interop.SetFilePointerEx.cs:
   src\Common\src\CoreLib\Interop\Windows\Kernel32\Interop.SetFilePointerEx.cs
   src\Common\src\Interop\Windows\kernel32\Interop.SetFilePointerEx.cs

Interop.WriteFile_SafeHandle_IntPtr.cs:
   src\Common\src\CoreLib\Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_IntPtr.cs
   src\Common\src\Interop\Windows\kernel32\Interop.WriteFile_SafeHandle_IntPtr.cs

Interop.WriteFile_SafeHandle_NativeOverlapped.cs:
   src\Common\src\CoreLib\Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_NativeOverlapped.cs
   src\Common\src\Interop\Windows\kernel32\Interop.WriteFile_SafeHandle_NativeOverlapped.cs

SafeDirectoryHandle.Unix.cs:
   src\Common\src\CoreLib\Microsoft\Win32\SafeHandles\SafeDirectoryHandle.Unix.cs
   src\Common\src\Microsoft\Win32\SafeHandles\SafeDirectoryHandle.Unix.cs

ICollectionDebugView.cs:
   src\Common\src\CoreLib\System\Collections\Generic\ICollectionDebugView.cs
   src\System.Collections\src\System\Collections\Generic\ICollectionDebugView.cs

IDictionaryDebugView.cs:
   src\Common\src\CoreLib\System\Collections\Generic\IDictionaryDebugView.cs
   src\System.Collections\src\System\Collections\Generic\IDictionaryDebugView.cs

DisableMediaInsertionPrompt.cs:
   src\Common\src\CoreLib\System\IO\DisableMediaInsertionPrompt.cs
   src\System.IO.FileSystem\src\System\IO\DisableMediaInsertionPrompt.cs

StreamHelpers.CopyValidation.cs:
   src\Common\src\CoreLib\System\IO\StreamHelpers.CopyValidation.cs
   src\Common\src\System\IO\StreamHelpers.CopyValidation.cs

DeferredDisposableLifetime.cs:
   src\Common\src\CoreLib\System\Threading\DeferredDisposableLifetime.cs
   src\System.Threading.Overlapped\src\System\Threading\DeferredDisposableLifetime.cs

TaskToApm.cs:
   src\Common\src\CoreLib\System\Threading\Tasks\TaskToApm.cs
   src\Common\src\System\Threading\Tasks\TaskToApm.cs

NetEventSource.Security.Windows.cs:
   src\Common\src\System\Net\Security\NetEventSource.Security.Windows.cs
   src\System.Net.Security\src\System\Net\Security\NetEventSource.Security.Windows.cs

DisableParallelization.cs:
   src\Common\tests\System\Xml\DisableParallelization.cs
   src\System.Private.Xml\tests\Writers\XmlWriterApi\DisableParallelization.cs

AppContext.Switch.cs:
   src\System.AppContext\tests\AppContext.Switch.cs
   src\System.Runtime\tests\System\AppContext\AppContext.Switch.cs

AppContext.Switch.Validation.cs:
   src\System.AppContext\tests\AppContext.Switch.Validation.cs
   src\System.Runtime\tests\System\AppContext\AppContext.Switch.Validation.cs

KeyValuePairs.cs:
   src\System.Collections.NonGeneric\src\System\Collections\KeyValuePairs.cs
   src\System.Runtime.Extensions\src\System\Collections\KeyValuePairs.cs

TimeoutTimer.cs:
   src\System.Data.Odbc\src\Common\System\Data\ProviderBase\TimeoutTimer.cs
   src\System.Data.SqlClient\src\System\Data\ProviderBase\TimeoutTimer.cs

FakeContextAwareResult.cs:
   src\System.Net.NameResolution\tests\PalTests\Fakes\FakeContextAwareResult.cs
   src\System.Net.NameResolution\tests\UnitTests\Fakes\FakeContextAwareResult.cs

CollectionDataContractAttribute.cs:
   src\System.Private.DataContractSerialization\src\System\Runtime\Serialization\CollectionDataContractAttribute.cs
   src\System.Runtime.Serialization.Primitives\src\System\Runtime\Serialization\CollectionDataContractAttribute.cs

ContractNamespaceAttribute.cs:
   src\System.Private.DataContractSerialization\src\System\Runtime\Serialization\ContractNamespaceAttribute.cs
   src\System.Runtime.Serialization.Primitives\src\System\Runtime\Serialization\ContractNamespaceAttribute.cs

DataContractAttribute.cs:
   src\System.Private.DataContractSerialization\src\System\Runtime\Serialization\DataContractAttribute.cs
   src\System.Runtime.Serialization.Primitives\src\System\Runtime\Serialization\DataContractAttribute.cs

EnumMemberAttribute.cs:
   src\System.Private.DataContractSerialization\src\System\Runtime\Serialization\EnumMemberAttribute.cs
   src\System.Runtime.Serialization.Primitives\src\System\Runtime\Serialization\EnumMemberAttribute.cs

AssemblyAttributes.cs:
   src\Common\tests\System\Diagnostics\RemoteExecutorConsoleApp\AssemblyAttributes.cs
   src\System.Runtime\tests\TestAssembly\AssemblyAttributes.cs
   src\System.Runtime.Extensions\tests\AssemblyResolveTests\AssemblyAttributes.cs
   src\System.Runtime.Extensions\tests\TestApp\AssemblyAttributes.cs
   src\System.Runtime.Extensions\tests\TestAppOutsideOfTPA\AssemblyAttributes.cs
   src\System.Runtime.Extensions\tests\VoidMainWithExitCodeApp\AssemblyAttributes.cs

GlobalSuppressions.cs:
   src\System.Collections.Immutable\src\GlobalSuppressions.cs
   src\System.Text.Encodings.Web\src\Properties\GlobalSuppressions.cs

XunitTestAssemblyAtrributes.cs:
   src\System.Net.Http.WinHttpHandler\tests\FunctionalTests\XunitTestAssemblyAtrributes.cs
   src\System.Net.Http.WinHttpHandler\tests\UnitTests\XunitTestAssemblyAtrributes.cs

Serialization.cs:
   src\System.Net.Primitives\tests\PalTests\Fakes\Serialization.cs
   src\System.Net.Primitives\tests\UnitTests\Fakes\Serialization.cs

The following files have a very small diff:

Interop.Errors.cs:
   src\Common\src\CoreLib\Interop\Unix\Interop.Errors.cs
   src\Common\src\Interop\Unix\Interop.Errors.cs

IPv4AddressHelper.cs:
   src\System.Net.Primitives\src\System\Net\IPv4AddressHelper.cs
   src\System.Private.Uri\src\System\IPv4AddressHelper.cs

Interop.FormatMessage.cs:
   src\Common\src\CoreLib\Interop\Windows\Kernel32\Interop.FormatMessage.cs
   src\Common\src\Interop\Windows\kernel32\Interop.FormatMessage.cs

TupleExtensions.cs:
   src\Common\src\CoreLib\System\TupleExtensions.cs
   src\System.ValueTuple\src\System\ValueTuple\TupleExtensions.cs

DriveNotFoundException.cs:
   src\Common\src\CoreLib\System\IO\DriveNotFoundException.cs
   src\System.IO.FileSystem.DriveInfo\src\System\IO\DriveNotFoundException.cs

XmlRawWriter.cs:
   src\Common\src\System\Xml\XmlRawWriter.cs
   src\System.Private.Xml\src\System\Xml\Core\XmlRawWriter.cs

IProducerConsumerCollection.cs:
   src\System.Collections.Concurrent\src\System\Collections\Concurrent\IProducerConsumerCollection.cs
   src\System.Threading.Tasks.Dataflow\src\Internal\IProducerConsumerCollection.cs

InvalidEnumArgumentException.cs:
   src\System.ComponentModel.Primitives\src\System\ComponentModel\InvalidEnumArgumentException.cs
   src\System.Drawing.Common\src\misc\InvalidEnumArgumentException.cs

DbConnectionClosed.cs:
   src\System.Data.Odbc\src\Common\System\Data\ProviderBase\DbConnectionClosed.cs
   src\System.Data.SqlClient\src\System\Data\ProviderBase\DbConnectionClosed.cs

DbConnectionFactory.cs:
   src\System.Data.Odbc\src\Common\System\Data\ProviderBase\DbConnectionFactory.cs
   src\System.Data.SqlClient\src\System\Data\ProviderBase\DbConnectionFactory.cs

DbConnectionPoolGroup.cs:
   src\System.Data.Odbc\src\Common\System\Data\ProviderBase\DbConnectionPoolGroup.cs
   src\System.Data.SqlClient\src\System\Data\ProviderBase\DbConnectionPoolGroup.cs

DbMetaDataFactory.cs:
   src\System.Data.Odbc\src\Common\System\Data\ProviderBase\DbMetaDataFactory.cs
   src\System.Data.SqlClient\src\System\Data\ProviderBase\DbMetaDataFactory.cs

DbReferenceCollection.cs:
   src\System.Data.Odbc\src\Common\System\Data\ProviderBase\DbReferenceCollection.cs
   src\System.Data.SqlClient\src\System\Data\ProviderBase\DbReferenceCollection.cs

DataMemberAttribute.cs:
   src\System.Private.DataContractSerialization\src\System\Runtime\Serialization\DataMemberAttribute.cs
   src\System.Runtime.Serialization.Primitives\src\System\Runtime\Serialization\DataMemberAttribute.cs

EDIT by @krwq: Similar issue but needs investigation on exact file list:

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 34 (34 by maintainers)

Most upvoted comments

@danmosemsft @MarcoRossignoli Here is the script: https://gist.github.com/EgorBo/bc20111c9f7514f6ba584e1d91da60a6 it looks messy and I used a diff tool provided by git ๐Ÿ™‚

Interop.FindFirstFileEx.cs

These should be pretty straightforward to unify:

  • BestFitMapping = false in CoreFX version is unnecessary
  • EnsureExtendedPrefixOverMaxPath in CoreCLR version should be replaced by EnsureExtendedPrefixIfNeeded
  • FINDEX_INFO_LEVELS and FINDEX_SEARCH_OPS are separate files in corefx. They can be in the same file with FindFirstFileEx since they are only ever used with this API.

Oh yes itโ€™s not your issue. @EgorBo mind if we close this and @MarcoRossignoli starts a fresh one with the remainder?

We had some issues with the changes and during that I probably forgot to delete the old one. This one should be deleted: corefx\src\System.Runtime.Extensions\src\System\Collections\Hashtable.cs

OK we are stabilizing to ship over coming weeks so I suggest first a safe PR for identical and dead files. Then the rest maybe we hold the PR for after we branch for the last time

@MarcoRossignoli yes the sync is only coreclr to corefx. It would be great if you could look at deduping yes.

@egorbo do you still have the script handy?