Skip to content

Commit 51ba512

Browse files
Replace resource constants with properties in UIAutomationClientSideProviders (#6832)
Contributes to #1
1 parent 3458292 commit 51ba512

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+294
-315
lines changed

eng/WpfArcadeSdk/tools/SystemResources.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<_GenerateResourcesCodeAsConstants>true</_GenerateResourcesCodeAsConstants>
1414

1515
<_GenerateResourcesCodeAsConstants Condition="'$(MSBuildProjectName)'=='UIAutomationClient'">false</_GenerateResourcesCodeAsConstants>
16+
<_GenerateResourcesCodeAsConstants Condition="'$(MSBuildProjectName)'=='UIAutomationClientSideProviders'">false</_GenerateResourcesCodeAsConstants>
1617
<_GenerateResourcesCodeAsConstants Condition="'$(MSBuildProjectName)'=='UIAutomationProvider'">false</_GenerateResourcesCodeAsConstants>
1718
<_GenerateResourcesCodeAsConstants Condition="'$(MSBuildProjectName)'=='System.Xaml'">false</_GenerateResourcesCodeAsConstants>
1819
<_GenerateResourcesCodeAsConstants Condition="'$(MSBuildProjectName)'=='WindowsBase'">false</_GenerateResourcesCodeAsConstants>
@@ -32,6 +33,7 @@
3233

3334
<ClassName Condition="'$(AssemblyName)'=='PresentationBuildTasks'">MS.Utility.SRID</ClassName>
3435
<ClassName Condition="'$(AssemblyName)'=='UIAutomationClient'">System.SR</ClassName>
36+
<ClassName Condition="'$(AssemblyName)'=='UIAutomationClientSideProviders'">System.SR</ClassName>
3537
<ClassName Condition="'$(AssemblyName)'=='UIAutomationProvider'">MS.Internal.Automation.SR</ClassName>
3638
<ClassName Condition="'$(AssemblyName)'=='UIAutomationTypes'">System.SR</ClassName>
3739
<ClassName Condition="'$(AssemblyName)'=='WindowsBase'">MS.Internal.WindowsBase.SR</ClassName>

src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/Accessible.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ internal string Value
549549
throw;
550550
}
551551

552-
throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed), e);
552+
throw new InvalidOperationException(SR.OperationCannotBePerformed, e);
553553
}
554554
}
555555
}
@@ -1155,7 +1155,7 @@ private void Select(int selFlags)
11551155
{
11561156
throw;
11571157
}
1158-
throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed), e);
1158+
throw new InvalidOperationException(SR.OperationCannotBePerformed, e);
11591159
}
11601160
}
11611161

@@ -1385,7 +1385,7 @@ private static bool HandleIAccessibleException(Exception e)
13851385
// One or more arguments were invalid. This error occurs when the caller attempts to identify
13861386
// a child object using an identifier that the server does not recognize. This error also results
13871387
// when a client attempts to identify a child object within an object that has no children.
1388-
throw new ArgumentException(SR.Get(SRID.InvalidParameter));
1388+
throw new ArgumentException(SR.InvalidParameter);
13891389

13901390
case NativeMethods.E_ACCESSDENIED:
13911391
// This is returned when you call get_accValue to get the value of a password control.

src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/MSAANativeProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ void CallDoDefaultAction()
12151215
throw;
12161216
}
12171217

1218-
throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed), e);
1218+
throw new InvalidOperationException(SR.OperationCannotBePerformed, e);
12191219
}
12201220
}
12211221

src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/Misc.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ internal static string AccessKey(string s)
5151
}
5252

5353
// Build the result string
54-
return SR.Get(SRID.KeyAlt) + "+" + s[iPosShortCut + 1];
54+
return SR.KeyAlt + "+" + s[iPosShortCut + 1];
5555
}
5656

5757
// Extend an existing RunTimeID by one element

src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/ProxySimple.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ void IRawElementProviderFragment.SetFocus()
560560
return;
561561
}
562562

563-
throw new InvalidOperationException(SR.Get(SRID.SetFocusFailed));
563+
throw new InvalidOperationException(SR.SetFocusFailed);
564564
}
565565

566566
#endregion

src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsButton.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private static IRawElementProviderSimple Create(IntPtr hwnd, int idChild)
9898
if (idChild != 0)
9999
{
100100
System.Diagnostics.Debug.Assert (idChild == 0, "Invalid Child Id, idChild != 0");
101-
throw new ArgumentOutOfRangeException("idChild", idChild, SR.Get(SRID.ShouldBeZero));
101+
throw new ArgumentOutOfRangeException("idChild", idChild, SR.ShouldBeZero);
102102
}
103103

104104
ButtonType type;
@@ -262,7 +262,7 @@ internal override object GetElementProperty (AutomationProperty idProp)
262262
if (!WindowsFormsHelper.IsWindowsFormsControl(_hwnd, ref _windowsForms) && IsStartButton())
263263
{
264264
// Hard coded shortcut for the start button
265-
return SR.Get(SRID.KeyCtrl) + " + " + SR.Get(SRID.KeyEsc);
265+
return SR.KeyCtrl + " + " + SR.KeyEsc;
266266
}
267267
return Misc.AccessKey(Misc.ProxyGetText(_hwnd));
268268
}
@@ -376,13 +376,13 @@ void ISelectionItemProvider.Select()
376376
// Adds this element to the selection
377377
void ISelectionItemProvider.AddToSelection()
378378
{
379-
throw new InvalidOperationException(SR.Get(SRID.DoesNotSupportMultipleSelection));
379+
throw new InvalidOperationException(SR.DoesNotSupportMultipleSelection);
380380
}
381381

382382
// Removes this element from the selection
383383
void ISelectionItemProvider.RemoveFromSelection()
384384
{
385-
throw new InvalidOperationException(SR.Get(SRID.DoesNotSupportMultipleSelection));
385+
throw new InvalidOperationException(SR.DoesNotSupportMultipleSelection);
386386
}
387387

388388
// True if this element is part of the the selection

src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsComboBox.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ internal static IRawElementProviderSimple Create(IntPtr hwnd, int idChild)
7272
if (idChild != 0)
7373
{
7474
System.Diagnostics.Debug.Assert (idChild == 0, "Invalid Child Id, idChild != 0");
75-
throw new ArgumentOutOfRangeException("idChild", idChild, SR.Get(SRID.ShouldBeZero));
75+
throw new ArgumentOutOfRangeException("idChild", idChild, SR.ShouldBeZero);
7676
}
7777

7878
return new WindowsComboBox(hwnd, null, HostedByComboEx(hwnd), idChild);
@@ -404,7 +404,7 @@ void IValueProvider.SetValue (string str)
404404
return;
405405
}
406406

407-
throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed));
407+
throw new InvalidOperationException(SR.OperationCannotBePerformed);
408408
}
409409

410410
// Request to get the value that this UI element is representing as a string
@@ -944,7 +944,7 @@ internal override string LocalizedName
944944
{
945945
get
946946
{
947-
return SR.Get(SRID.LocalizedNameWindowsComboButton);
947+
return SR.LocalizedNameWindowsComboButton;
948948
}
949949
}
950950

src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsContainer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ public WindowsContainer (IntPtr hwnd, ProxyHwnd parent, int item)
3535
{
3636
if (className.Equals("#32770"))
3737
{
38-
_sType = SR.Get(SRID.LocalizedControlTypeDialog);
38+
_sType = SR.LocalizedControlTypeDialog;
3939
}
4040
else if (className.IndexOf("AfxControlBar", StringComparison.Ordinal) != -1)
4141
{
42-
_sType = SR.Get(SRID.LocalizedControlTypeContainer);
42+
_sType = SR.LocalizedControlTypeContainer;
4343
}
4444
}
4545

@@ -64,7 +64,7 @@ private static IRawElementProviderSimple Create(IntPtr hwnd, int idChild)
6464
if (idChild != 0)
6565
{
6666
System.Diagnostics.Debug.Assert(idChild == 0, "Invalid Child Id, idChild != 0");
67-
throw new ArgumentOutOfRangeException("idChild", idChild, SR.Get(SRID.ShouldBeZero));
67+
throw new ArgumentOutOfRangeException("idChild", idChild, SR.ShouldBeZero);
6868
}
6969

7070
return new WindowsContainer(hwnd, null, 0);

src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsEditBox.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private static IRawElementProviderSimple Create(IntPtr hwnd, int idChild)
8686
if (idChild != 0)
8787
{
8888
System.Diagnostics.Debug.Assert (idChild == 0, "Invalid Child Id, idChild != 0");
89-
throw new ArgumentOutOfRangeException("idChild", idChild, SR.Get(SRID.ShouldBeZero));
89+
throw new ArgumentOutOfRangeException("idChild", idChild, SR.ShouldBeZero);
9090
}
9191

9292
return new WindowsEditBox(hwnd, null, 0);
@@ -277,7 +277,7 @@ void IValueProvider.SetValue (string str)
277277

278278
if (Misc.IsBitSet(styles, NativeMethods.ES_READONLY))
279279
{
280-
throw new InvalidOperationException(SR.Get(SRID.ValueReadonly));
280+
throw new InvalidOperationException(SR.ValueReadonly);
281281
}
282282

283283
// check if control only accepts numbers
@@ -288,7 +288,7 @@ void IValueProvider.SetValue (string str)
288288
{
289289
if (char.IsLetter (ch))
290290
{
291-
throw new ArgumentException(SR.Get(SRID.NotAValidValue, str), "val");
291+
throw new ArgumentException(SR.Format(SR.NotAValidValue, str), "val");
292292
}
293293
}
294294
}
@@ -299,14 +299,14 @@ void IValueProvider.SetValue (string str)
299299
// A result of -1 means that no limit is set.
300300
if (result != -1 && result < str.Length)
301301
{
302-
throw new InvalidOperationException (SR.Get(SRID.OperationCannotBePerformed));
302+
throw new InvalidOperationException (SR.OperationCannotBePerformed);
303303
}
304304

305305
// Send the message...
306306
result = Misc.ProxySendMessageInt(_hwnd, NativeMethods.WM_SETTEXT, IntPtr.Zero, new StringBuilder(str));
307307
if (result != 1)
308308
{
309-
throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed));
309+
throw new InvalidOperationException(SR.OperationCannotBePerformed);
310310
}
311311
}
312312

@@ -349,7 +349,7 @@ ITextRangeProvider [] ITextProvider.GetVisibleRanges()
349349
ITextRangeProvider ITextProvider.RangeFromChild(IRawElementProviderSimple childElement)
350350
{
351351
// we don't have any children so this call must be in error.
352-
throw new InvalidOperationException(SR.Get(SRID.EditControlsHaveNoChildren,GetType().FullName));
352+
throw new InvalidOperationException(SR.Format(SR.EditControlsHaveNoChildren, GetType().FullName));
353353
}
354354

355355
ITextRangeProvider ITextProvider.RangeFromPoint(Point screenLocation)

src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsEditBoxRange.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ internal WindowsEditBoxRange(WindowsEditBox provider, int start, int end)
4141
// i'm throwing an invalid operation exception rather than an argument exception because
4242
// clients never call this constructor directly. it always happens as a result of some
4343
// other operation, e.g. cloning an existing TextPatternRange.
44-
throw new InvalidOperationException(SR.Get(SRID.InvalidTextRangeOffset,GetType().FullName));
44+
throw new InvalidOperationException(SR.Format(SR.InvalidTextRangeOffset, GetType().FullName));
4545
}
4646
Debug.Assert(provider != null);
4747

@@ -210,7 +210,7 @@ ITextRangeProvider ITextRangeProvider.FindText(string text, bool backwards, bool
210210
#pragma warning suppress 6507
211211
if (text.Length == 0)
212212
{
213-
throw new ArgumentException(SR.Get(SRID.InvalidParameter));
213+
throw new ArgumentException(SR.InvalidParameter);
214214
}
215215

216216
// get the text of the range
@@ -1081,7 +1081,7 @@ private void MoveTo(int start, int end)
10811081
{
10821082
if (start < 0 || end < start)
10831083
{
1084-
throw new InvalidOperationException(SR.Get(SRID.InvalidTextRangeOffset,GetType().FullName));
1084+
throw new InvalidOperationException(SR.Format(SR.InvalidTextRangeOffset, GetType().FullName));
10851085
}
10861086

10871087
_start = start;
@@ -1093,7 +1093,7 @@ private void ValidateEndpoints()
10931093
int limit = _provider.GetTextLength();
10941094
if (Start > limit || End > limit)
10951095
{
1096-
throw new InvalidOperationException(SR.Get(SRID.InvalidRangeEndpoint,GetType().FullName));
1096+
throw new InvalidOperationException(SR.Format(SR.InvalidRangeEndpoint, GetType().FullName));
10971097
}
10981098
}
10991099

@@ -1127,7 +1127,7 @@ private int End
11271127
// ensure that we never accidentally get a negative index
11281128
if (value < 0)
11291129
{
1130-
throw new InvalidOperationException(SR.Get(SRID.InvalidTextRangeOffset,GetType().FullName));
1130+
throw new InvalidOperationException(SR.Format(SR.InvalidTextRangeOffset, GetType().FullName));
11311131
}
11321132

11331133
// ensure that end never moves before start
@@ -1158,7 +1158,7 @@ private int Start
11581158
// ensure that we never accidentally get a negative index
11591159
if (value < 0)
11601160
{
1161-
throw new InvalidOperationException(SR.Get(SRID.InvalidTextRangeOffset,GetType().FullName));
1161+
throw new InvalidOperationException(SR.Format(SR.InvalidTextRangeOffset, GetType().FullName));
11621162
}
11631163

11641164
// ensure that start never moves after end

0 commit comments

Comments
 (0)