@@ -75,14 +75,6 @@ private string GetText(Location startLocation, Location endLocation)
75
75
return GetText ( startLocation . LineIndex , startLocation . CharIndex , endLocation . LineIndex , endLocation . CharIndex ) ;
76
76
}
77
77
78
- /// <summary>
79
- /// Retrieves the text starting at the given point and with the given length
80
- /// </summary>
81
- private string GetText ( Location startLocation , int count )
82
- {
83
- return GetText ( startLocation . LineIndex , startLocation . CharIndex , count ) ;
84
- }
85
-
86
78
/// <summary>
87
79
/// Retrieves all of the text in the buffer
88
80
/// </summary>
@@ -294,12 +286,7 @@ private static int FindClosingAngleBracketHelper(string line)
294
286
{
295
287
MoveToApplicationRootElement ( reader ) ;
296
288
XamlProperty ? prop = FindPropertyAsAttributeInCurrentElement ( reader , ApplicationElementName , propertyName ) ;
297
- if ( prop is null )
298
- {
299
- prop = FindPropertyAsChildElementInCurrentElement ( reader , ApplicationElementName , propertyName ) ;
300
- }
301
-
302
- return prop ;
289
+ return prop ?? FindPropertyAsChildElementInCurrentElement ( reader , ApplicationElementName , propertyName ) ;
303
290
}
304
291
305
292
private XamlPropertyInAttributeSyntax ? FindPropertyAsAttributeInCurrentElement ( XmlTextReader reader , string optionalPropertyQualifier , string propertyName )
@@ -411,7 +398,6 @@ private static int FindClosingAngleBracketHelper(string line)
411
398
// Found
412
399
413
400
Location tagStart = new ( reader ) ;
414
- Location tagEnd = new ( reader ) ;
415
401
416
402
Location ? startTagEndingBracketLocation = FindClosingAngleBracket ( tagStart ) ;
417
403
if ( startTagEndingBracketLocation is null )
@@ -469,7 +455,6 @@ private static int FindClosingAngleBracketHelper(string line)
469
455
}
470
456
471
457
// Reader is at location 'x' of </xyz>. So we want -2 from this location.
472
- Location currentPosition2 = new ( reader ) ;
473
458
Location valueEndPlusOne = new Location ( reader ) . Shift ( - 2 ) ;
474
459
475
460
// Get the inner text and unescape it.
@@ -499,10 +484,7 @@ private static int FindClosingAngleBracketHelper(string line)
499
484
500
485
private void SetApplicationPropertyValue ( string propertyName , string ? value )
501
486
{
502
- if ( value is null )
503
- {
504
- value = string . Empty ;
505
- }
487
+ value ??= string . Empty ;
506
488
507
489
using BufferLock bufferLock = new ( _vsTextLines , this ) ;
508
490
@@ -549,14 +531,6 @@ private void SetApplicationPropertyValue(string propertyName, string? value)
549
531
}
550
532
}
551
533
552
- /// <summary>
553
- /// Replace the text at the given location in the buffer with new text.
554
- /// </summary>
555
- private void ReplaceText ( Location sourceStart , int sourceLength , string newText )
556
- {
557
- ( ( IReplaceText ) this ) . ReplaceText ( sourceStart , new Location ( sourceStart . LineIndex , sourceStart . CharIndex + sourceLength ) , newText ) ;
558
- }
559
-
560
534
/// <summary>
561
535
/// Replace the text at the given location in the buffer with new text.
562
536
/// </summary>
@@ -576,48 +550,6 @@ void IReplaceText.ReplaceText(Location sourceStart, Location sourceEnd, string n
576
550
}
577
551
}
578
552
579
- /// <summary>
580
- /// Given the location of the start of an element tag, makes sure that it has an end tag.
581
- /// If the element tag is closed by "/>" instead of an end element, it is expanded
582
- /// into a start and end tag.
583
- /// </summary>
584
- /// <param name="tagStartLocation"></param>
585
- /// <param name="elementName">The name of the element at the given location</param>
586
- private void MakeSureElementHasStartAndEndTag ( Location tagStartLocation , string elementName )
587
- {
588
- if ( ! "<" . Equals ( GetText ( tagStartLocation , 1 ) , StringComparison . Ordinal ) )
589
- {
590
- DiagnosticsDebug . Fail ( "MakeSureElementHasStartAndEndTags: The start location doesn't point to the start of an element tag" ) ;
591
- ThrowUnexpectedFormatException ( tagStartLocation ) ;
592
- }
593
-
594
- Location ? startTagEndingBracketLocation = FindClosingAngleBracket ( tagStartLocation ) ;
595
- if ( startTagEndingBracketLocation is null )
596
- {
597
- ThrowUnexpectedFormatException ( tagStartLocation ) ;
598
- }
599
-
600
- if ( ">" . Equals ( GetText ( startTagEndingBracketLocation , 1 ) , StringComparison . Ordinal ) )
601
- {
602
- // The element tag is of the <xxx> form. We assume that there is an ending </xxx> tag, and
603
- // we don't need to do anything.
604
- }
605
- else
606
- {
607
- // It must be an empty tag of the <xxx/> form.
608
- string slashAndEndBracket = "/>" ;
609
- if ( ! slashAndEndBracket . Equals ( GetText ( startTagEndingBracketLocation , slashAndEndBracket . Length ) , StringComparison . Ordinal ) )
610
- {
611
- DiagnosticsDebug . Fail ( "FindClosingAngleBracket returned the wrong location?" ) ;
612
- ThrowUnexpectedFormatException ( startTagEndingBracketLocation ) ;
613
- }
614
-
615
- // We need to change <xxx attributes/> into <xxx attributes></xxx>
616
- string newText = "></" + elementName + ">" ;
617
- ReplaceText ( startTagEndingBracketLocation , slashAndEndBracket . Length , newText ) ;
618
- }
619
- }
620
-
621
553
/// <summary>
622
554
/// Finds the value of the StartupUri property inside the xaml file. If
623
555
/// the property is not set in the xaml, an empty string is returned.
@@ -655,29 +587,6 @@ private static void ThrowUnexpectedFormatException(Location location)
655
587
throw new XamlReadWriteException ( string . Format ( VSResources . WPFApp_Xaml_UnexpectedFormat_2 , location . LineIndex + 1 , location . CharIndex + 1 ) ) ;
656
588
}
657
589
658
- /// <summary>
659
- /// Verify the validity of the Application.xaml file, and throw an exception if
660
- /// problems are found.
661
- /// </summary>
662
- private void VerifyAppXamlIsValidAndThrowIfNot ( )
663
- {
664
- using BufferLock bufferLock = new ( _vsTextLines , this ) ;
665
-
666
- XmlTextReader reader = CreateXmlTextReader ( ) ;
667
- MoveToApplicationRootElement ( reader ) ;
668
-
669
- // Read through the Application element, including any child elements, to
670
- // ensure everything is properly closed.
671
- // The name of the element to find is irrelevant, as there shouldn't be
672
- // any elements following Application.
673
- reader . ReadToFollowing ( "Dummy Element" ) ;
674
-
675
- // If we made it to here, the .xaml file should be well-formed enough for us to read
676
- // it properly. As a final check, though, try getting some common properties.
677
- GetStartupUri ( ) ;
678
- GetShutdownMode ( ) ;
679
- }
680
-
681
590
void IDebugLockCheck . OnBufferLock ( )
682
591
{
683
592
_debugBufferLockCount ++ ;
0 commit comments