Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

General using cleanup in C# files #10011

Merged
merged 5 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
<Compile Include="$(WpfSharedDir)\MS\Internal\DecoderFallbackWithFailureFlag.cs" />
<Compile Include="$(WpfSharedDir)\MS\Internal\FloatUtil.cs" />
<Compile Include="$(WpfSharedDir)\MS\Internal\FreezableOperations.cs" />
<Compile Include="$(WpfSharedDir)\MS\Internal\HashHelper.cs" />
<Compile Include="$(WpfSharedDir)\MS\Internal\PointUtil.cs" />
<Compile Include="$(WpfSharedDir)\MS\Internal\MimeTypeMapper.cs" />
<Compile Include="$(WpfSharedDir)\MS\Internal\Pair.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Linq;

namespace MS.Internal.Hashing.PresentationFramework;

internal static class HashHelper
{
private static readonly Type[] s_unreliableTypes =
[
// The first four are from PresentationCore
typeof(System.Windows.Media.CharacterMetrics), // bug 1612093
typeof(System.Windows.Ink.ExtendedProperty), // bug 1612101
typeof(System.Windows.Media.FamilyTypeface), // bug 1612103
typeof(System.Windows.Media.NumberSubstitution), // bug 1612105

// Next two are PresentationFramework
typeof(System.Windows.Markup.Localizer.BamlLocalizableResource), // bug 1612118
typeof(System.Windows.ComponentResourceKey) // bug 1612119
];

/// <summary>
/// Certain objects don't have reliable hashcodes, and cannot be used in a Hashtable, Dictionary, etc.
/// </summary>
internal static bool HasReliableHashCode(object item) => !s_unreliableTypes.Contains(item.GetType());
JeremyKuhne marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<Compile Include="$(WpfCommonDir)\src\System\LocalAppContext.cs" />
<Compile Include="$(WpfCommonDir)\src\System\AppContextDefaultValues.cs" />
<Compile Include="GlobalUsings.cs" />
<Compile Include="HashHelper.cs" />
<Compile Include="LibraryAssemblyInfo.cs" />
<Compile Include="System\AppContextDefaultValues.cs" />

Expand Down Expand Up @@ -402,6 +403,7 @@
<Compile Include="MS\Internal\WeakHashtable.cs" />
<Compile Include="MS\Internal\WeakObjectHashtable.cs" />
<Compile Include="MS\Internal\WindowsRuntime\Generated\**\*.cs" />
<Compile Remove="D:\repos\wpf\src\Microsoft.DotNet.Wpf\src\Shared\\MS\Internal\HashHelper.cs" />
<Compile Include="MS\Internal\WindowsRuntime\Windows\Data\Text\WordsSegmenter.cs" />
<Compile Include="MS\Win32\UxThemeWrapper.cs" />
<Compile Include="OtherAssemblyAttrs.cs" />
Expand Down
70 changes: 0 additions & 70 deletions src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/HashHelper.cs

This file was deleted.

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 All @@ -7,30 +7,13 @@
// This class should be used by most - if not all - MIL parsers.
//

using System;
using System.Diagnostics;
using System.Globalization;

#if !PBTCOMPILER
using System.Windows;
#endif

#if WINDOWS_BASE
using MS.Internal.WindowsBase;
#elif PRESENTATION_CORE
using MS.Internal.PresentationCore;
#elif PRESENTATIONFRAMEWORK
using MS.Internal.PresentationFramework;
#elif PBTCOMPILER
#if PBTCOMPILER
using System;
using System.Diagnostics;
using MS.Utility;
using MS.Internal.Markup;
#elif DRT
using MS.Internal.Drt;
#else
using MS.Internal.YourAssemblyName;
#endif

#if PBTCOMPILER
namespace MS.Internal.Markup
#else
namespace MS.Internal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
// 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.


#region Using declarations

using System.Windows;
using System.Windows.Input;

namespace Microsoft.Windows.Input
{
#endregion Using declarations

#region CommandHelpers Class

/// <summary>
/// A helper class for executing Commands.
/// A helper class for executing Commands.
/// </summary>
internal static class CommandHelpers
{
Expand Down Expand Up @@ -122,6 +114,4 @@ internal enum CommandOperation
CancelPreview,
Execute
}

#endregion CommandHelpers Class
}

This file was deleted.

2 changes: 0 additions & 2 deletions src/Microsoft.DotNet.Wpf/src/WindowsBase/WindowsBase.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<Compile Include="$(WpfSharedDir)\MS\Internal\SafeSecurityHelper.cs" />
<Compile Include="$(WpfSharedDir)\MS\Internal\CulturePreservingExecutionContext.cs" />
<Compile Include="$(WpfSharedDir)\MS\Internal\DoubleUtil.cs" />
<Compile Include="$(WpfSharedDir)\MS\Internal\HashHelper.cs" />
<Compile Include="$(WpfSharedDir)\MS\Internal\Invariant.cs" />
<Compile Include="$(WpfSharedDir)\MS\Internal\MatrixUtil.cs" />
<Compile Include="$(WpfSharedDir)\MS\Internal\Registry.cs" />
Expand Down Expand Up @@ -77,7 +76,6 @@
<Compile Include="MS\Internal\AvTrace.cs" />
<Compile Include="MS\Internal\AvTraceDetails.cs" />
<Compile Include="MS\Internal\AvTraceFormat.cs" />
<Compile Include="MS\Internal\BaseHashHelper.cs" />
<Compile Include="MS\Internal\CleanupHelper.cs " />
<Compile Include="MS\Internal\BaseAppContextSwitches.cs" />
<Compile Include="MS\Internal\ComponentModel\APCustomTypeDescriptor.cs" />
Expand Down
Loading