Skip to content

Replace resource constants with properties in PresentationCore #7519

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

Merged
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: 2 additions & 1 deletion eng/WpfArcadeSdk/tools/SystemResources.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
-->

<_GenerateResourcesCodeAsConstants Condition="'$(MSBuildProjectName)'=='PresentationBuildTasks'">false</_GenerateResourcesCodeAsConstants>
<_GenerateResourcesCodeAsConstants Condition="'$(MSBuildProjectName)'=='PresentationCore'">false</_GenerateResourcesCodeAsConstants>
<_GenerateResourcesCodeAsConstants Condition="'$(MSBuildProjectName)'=='PresentationFramework'">false</_GenerateResourcesCodeAsConstants>
<_GenerateResourcesCodeAsConstants Condition="'$(MSBuildProjectName)'=='PresentationUI' or '$(AssemblyName)'=='PresentationUI'">false</_GenerateResourcesCodeAsConstants>
<_GenerateResourcesCodeAsConstants Condition="'$(MSBuildProjectName)'=='ReachFramework'">false</_GenerateResourcesCodeAsConstants>
Expand Down Expand Up @@ -53,7 +54,7 @@
<ClassName Condition="'$(AssemblyName)'=='PresentationFramework'">System.Windows.SR</ClassName>
<ClassName Condition="'$(AssemblyName)'=='PresentationUI'">System.Windows.TrustUI.SR</ClassName>
<ClassName Condition="'$(AssemblyName)'=='WindowsFormsIntegration'">System.Windows.SR</ClassName>
<ClassName Condition="'$(AssemblyName)'=='PresentationCore'">MS.Internal.PresentationCore.SRID </ClassName>
<ClassName Condition="'$(AssemblyName)'=='PresentationCore'">MS.Internal.PresentationCore.SR</ClassName>
<ClassName Condition="'$(AssemblyName)'=='System.Xaml'">System.SR</ClassName>
<Classname Condition="'%(ClassName)'==''">System.SRID</Classname>
</EmbeddedResource>
Expand Down
1 change: 0 additions & 1 deletion src/Microsoft.DotNet.Wpf/src/Common/Graphics/exports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
using SafeNativeMethods=MS.Win32.PresentationCore.SafeNativeMethods;
using HRESULT=MS.Internal.HRESULT;
using SR=MS.Internal.PresentationCore.SR;
using SRID=MS.Internal.PresentationCore.SRID;
using DllImport=MS.Internal.PresentationCore.DllImport;

/*
Expand Down
107 changes: 53 additions & 54 deletions src/Microsoft.DotNet.Wpf/src/Common/Graphics/wgx_render.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ internal static void EnsurePenImcClassesActivated()
// succeeds, or IntPtr.Zero if SxS registration fails.
if ((_pimcActCtxCookie = RegisterDllForSxSCOM()) == IntPtr.Zero)
{
throw new InvalidOperationException(SR.Get(SRID.PenImcSxSRegistrationFailed, ExternDll.Penimc));
throw new InvalidOperationException(SR.Format(SR.PenImcSxSRegistrationFailed, ExternDll.Penimc));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
using MS.Internal.PresentationCore;
using MS.Win32;
using SR=MS.Internal.PresentationCore.SR;
using SRID=MS.Internal.PresentationCore.SRID;

namespace MS.Internal.Automation
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
using MS.Internal.PresentationCore; // SafeSecurityHelper

using SR=MS.Internal.PresentationCore.SR;
using SRID=MS.Internal.PresentationCore.SRID;

namespace MS.Internal.Automation
{
Expand Down Expand Up @@ -241,11 +240,11 @@ internal static object Invoke(AutomationPeer peer, DispatcherOperationCallback w

if(dispatcherInShutdown)
{
throw new InvalidOperationException(SR.Get(SRID.AutomationDispatcherShutdown));
throw new InvalidOperationException(SR.AutomationDispatcherShutdown);
}
else
{
throw new TimeoutException(SR.Get(SRID.AutomationTimeout));
throw new TimeoutException(SR.AutomationTimeout);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
using System.Windows.Threading;

using SR=MS.Internal.PresentationCore.SR;
using SRID=MS.Internal.PresentationCore.SRID;

namespace MS.Internal.Automation
{
Expand Down Expand Up @@ -122,7 +121,7 @@ private static AutomationEvent GetRegisteredEventObjectHelper(AutomationEvents e
case AutomationEvents.ActiveTextPositionChanged: eventObject = AutomationElementIdentifiers.ActiveTextPositionChangedEvent; break;

default:
throw new ArgumentException(SR.Get(SRID.Automation_InvalidEventId), "eventId");
throw new ArgumentException(SR.Automation_InvalidEventId, "eventId");
}

if ((eventObject != null) && (!_eventsTable.ContainsKey(eventObject.Id)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

using MS.Internal;
using SR = MS.Internal.PresentationCore.SR;
using SRID = MS.Internal.PresentationCore.SRID;

namespace MS.Internal.Automation
{
Expand Down Expand Up @@ -47,15 +46,15 @@ void ISynchronizedInputProvider.StartListening(SynchronizedInputType inputType)
inputType != SynchronizedInputType.MouseRightButtonDown &&
inputType != SynchronizedInputType.MouseRightButtonUp)
{
throw new ArgumentException(SR.Get(SRID.Automation_InvalidSynchronizedInputType, inputType));
throw new ArgumentException(SR.Format(SR.Automation_InvalidSynchronizedInputType, inputType));
}

UIElement e = _owner as UIElement;
if (e != null)
{
if (!e.StartListeningSynchronizedInput(inputType))
{
throw new InvalidOperationException(SR.Get(SRID.Automation_RecursivePublicCall));
throw new InvalidOperationException(SR.Automation_RecursivePublicCall);
}
}
else
Expand All @@ -65,15 +64,15 @@ void ISynchronizedInputProvider.StartListening(SynchronizedInputType inputType)
{
if (!ce.StartListeningSynchronizedInput(inputType))
{
throw new InvalidOperationException(SR.Get(SRID.Automation_RecursivePublicCall));
throw new InvalidOperationException(SR.Automation_RecursivePublicCall);
}
}
else
{
UIElement3D e3D = (UIElement3D)_owner;
if (!e3D.StartListeningSynchronizedInput(inputType))
{
throw new InvalidOperationException(SR.Get(SRID.Automation_RecursivePublicCall));
throw new InvalidOperationException(SR.Automation_RecursivePublicCall);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
using System.Windows.Automation.Text;
using System.Windows.Automation.Peers;
using SR = MS.Internal.PresentationCore.SR;
using SRID = MS.Internal.PresentationCore.SRID;

namespace MS.Internal.Automation
{
Expand Down Expand Up @@ -64,7 +63,7 @@ public ITextRangeProvider RangeFromChild(IRawElementProviderSimple childElement)
{
if (!(childElement is ElementProxy))
{
throw new ArgumentException(SR.Get(SRID.TextProvider_InvalidChild, "childElement"));
throw new ArgumentException(SR.Format(SR.TextProvider_InvalidChild, "childElement"));
}

return (ITextRangeProvider)ElementUtil.Invoke(_peer, new DispatcherOperationCallback(RangeFromChild), childElement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
using System.Windows.Automation.Text;
using System.Windows.Automation.Peers;
using SR = MS.Internal.PresentationCore.SR;
using SRID = MS.Internal.PresentationCore.SRID;

namespace MS.Internal.Automation
{
Expand Down Expand Up @@ -60,7 +59,7 @@ public bool Compare(ITextRangeProvider range)
{
if (!(range is TextRangeProviderWrapper))
{
throw new ArgumentException(SR.Get(SRID.TextRangeProvider_InvalidRangeProvider, "range"));
throw new ArgumentException(SR.Format(SR.TextRangeProvider_InvalidRangeProvider, "range"));
}

return (bool)ElementUtil.Invoke(_peer, new DispatcherOperationCallback(Compare), range);
Expand All @@ -70,7 +69,7 @@ public int CompareEndpoints(TextPatternRangeEndpoint endpoint, ITextRangeProvide
{
if (!(targetRange is TextRangeProviderWrapper))
{
throw new ArgumentException(SR.Get(SRID.TextRangeProvider_InvalidRangeProvider, "targetRange"));
throw new ArgumentException(SR.Format(SR.TextRangeProvider_InvalidRangeProvider, "targetRange"));
}

object[] args = new object[] { endpoint, targetRange, targetEndpoint };
Expand Down Expand Up @@ -133,7 +132,7 @@ public void MoveEndpointByRange(TextPatternRangeEndpoint endpoint, ITextRangePro
{
if (!(targetRange is TextRangeProviderWrapper))
{
throw new ArgumentException(SR.Get(SRID.TextRangeProvider_InvalidRangeProvider, "targetRange"));
throw new ArgumentException(SR.Format(SR.TextRangeProvider_InvalidRangeProvider, "targetRange"));
}

object[] args = new object[] { endpoint, targetRange, targetEndpoint };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal CustomCategoryAttribute(string category) : base(category)

protected override string GetLocalizedString(string value)
{
string s = SR.Get(value);
string s = SR.GetResourceString(value);
if (s != null)
{
return s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ static DWriteFactory()
new FontSourceCollectionFactory(),
new FontSourceFactory());

Text.TextInterface.LocalizedErrorMsgs.EnumeratorNotStarted = SR.Get(SRID.Enumerator_NotStarted);
Text.TextInterface.LocalizedErrorMsgs.EnumeratorReachedEnd = SR.Get(SRID.Enumerator_ReachedEnd);
Text.TextInterface.LocalizedErrorMsgs.EnumeratorNotStarted = SR.Enumerator_NotStarted;
Text.TextInterface.LocalizedErrorMsgs.EnumeratorReachedEnd = SR.Enumerator_ReachedEnd;
}

internal static Text.TextInterface.Factory Instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ internal static void SplitFontFaceIndex(Uri fontUri, out Uri fontSourceUri, out
out faceIndex
))
{
throw new ArgumentException(SR.Get(SRID.FaceIndexMustBePositiveOrZero), "fontUri");
throw new ArgumentException(SR.FaceIndexMustBePositiveOrZero, "fontUri");
}

// face index was specified in a fragment, we need to strip off fragment from the source Uri
Expand Down Expand Up @@ -767,19 +767,19 @@ internal static void ThrowWin32Exception(int errorCode, string fileName)
switch (errorCode)
{
case NativeMethods.ERROR_FILE_NOT_FOUND:
throw new FileNotFoundException(SR.Get(SRID.FileNotFoundExceptionWithFileName, fileName), fileName);
throw new FileNotFoundException(SR.Format(SR.FileNotFoundExceptionWithFileName, fileName), fileName);

case NativeMethods.ERROR_PATH_NOT_FOUND:
throw new DirectoryNotFoundException(SR.Get(SRID.DirectoryNotFoundExceptionWithFileName, fileName));
throw new DirectoryNotFoundException(SR.Format(SR.DirectoryNotFoundExceptionWithFileName, fileName));

case NativeMethods.ERROR_ACCESS_DENIED:
throw new UnauthorizedAccessException(SR.Get(SRID.UnauthorizedAccessExceptionWithFileName, fileName));
throw new UnauthorizedAccessException(SR.Format(SR.UnauthorizedAccessExceptionWithFileName, fileName));

case NativeMethods.ERROR_FILENAME_EXCED_RANGE:
throw new PathTooLongException(SR.Get(SRID.PathTooLongExceptionWithFileName, fileName));
throw new PathTooLongException(SR.Format(SR.PathTooLongExceptionWithFileName, fileName));

default:
throw new IOException(SR.Get(SRID.IOExceptionWithFileName, fileName), NativeMethods.MakeHRFromErrorCode(errorCode));
throw new IOException(SR.Format(SR.IOExceptionWithFileName, fileName), NativeMethods.MakeHRFromErrorCode(errorCode));
}
}

Expand All @@ -795,7 +795,7 @@ internal static Exception ConvertInPageException(FontSource fontSource, SEHExcep
fileName = fontSource.GetUriString();
}

return new IOException(SR.Get(SRID.IOExceptionWithFileName, fileName), e);
return new IOException(SR.Format(SR.IOExceptionWithFileName, fileName), e);
}
}

Expand Down Expand Up @@ -861,7 +861,7 @@ internal void OpenFile(string fileName)

UnsafeNativeMethods.LARGE_INTEGER fileSize = new UnsafeNativeMethods.LARGE_INTEGER();
if (!UnsafeNativeMethods.GetFileSizeEx(fileHandle, ref fileSize))
throw new IOException(SR.Get(SRID.IOExceptionWithFileName, fileName));
throw new IOException(SR.Format(SR.IOExceptionWithFileName, fileName));

size = (long)fileSize.QuadPart;
if (size == 0)
Expand All @@ -877,11 +877,11 @@ internal void OpenFile(string fileName)
}

if (_mappingHandle.IsInvalid)
throw new IOException(SR.Get(SRID.IOExceptionWithFileName, fileName));
throw new IOException(SR.Format(SR.IOExceptionWithFileName, fileName));

_viewHandle = UnsafeNativeMethods.MapViewOfFileEx(_mappingHandle, UnsafeNativeMethods.FILE_MAP_READ, 0, 0, IntPtr.Zero, IntPtr.Zero);
if (_viewHandle.IsInvalid)
throw new IOException(SR.Get(SRID.IOExceptionWithFileName, fileName));
throw new IOException(SR.Format(SR.IOExceptionWithFileName, fileName));

#pragma warning restore 6523

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ public void CopyTo(KeyValuePair<int, ushort>[] array, int arrayIndex)

if (array.Rank != 1)
{
throw new ArgumentException(SR.Get(SRID.Collection_BadRank));
throw new ArgumentException(SR.Collection_BadRank);
}

// The extra "arrayIndex >= array.Length" check in because even if _collection.Count
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
using System.Windows.Media;

using SR=MS.Internal.PresentationCore.SR;
using SRID=MS.Internal.PresentationCore.SRID;

namespace MS.Internal.FontFace
{
Expand Down Expand Up @@ -62,7 +61,7 @@ internal void PrepareToAddFamilyMap(FontFamilyMap familyMap)
throw new ArgumentNullException("familyMap");

if (string.IsNullOrEmpty(familyMap.Target))
throw new ArgumentException(SR.Get(SRID.FamilyMap_TargetNotSet));
throw new ArgumentException(SR.FamilyMap_TargetNotSet);

// If it's culture-specific make sure it's in the hash table.
if (familyMap.Language != null)
Expand Down
Loading