11using System ;
22using System . IO ;
3+ using System . Runtime . CompilerServices ;
34using System . Runtime . InteropServices ;
45using PSADT . Interop . Extensions ;
56using PSADT . Interop . SafeHandles ;
@@ -29,6 +30,7 @@ internal sealed class ShellLinkFile : IDisposable
2930 /// Creates a new, empty shell link.
3031 /// </summary>
3132 /// <returns>A new <see cref="ShellLinkFile"/> instance.</returns>
33+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
3234 public static ShellLinkFile New ( )
3335 {
3436 return new ( ) ;
@@ -39,6 +41,7 @@ public static ShellLinkFile New()
3941 /// </summary>
4042 /// <param name="targetPath">The target path for the shortcut.</param>
4143 /// <returns>A new <see cref="ShellLinkFile"/> instance with the target path set.</returns>
44+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
4245 public static ShellLinkFile New ( string targetPath )
4346 {
4447 return new ( ) { TargetPath = targetPath } ;
@@ -54,6 +57,7 @@ public static ShellLinkFile New(string targetPath)
5457 /// <exception cref="FileNotFoundException">Thrown when the specified file does not exist.</exception>
5558 /// <exception cref="COMException">Thrown when the COM operation fails.</exception>
5659 /// <remarks>Use <see cref="Load(string, STGM)"/> with <see cref="STGM.STGM_READWRITE"/> if you need to modify the shortcut.</remarks>
60+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
5761 public static ShellLinkFile Load ( string filePath )
5862 {
5963 return Load ( filePath , STGM . STGM_READ ) ;
@@ -92,6 +96,7 @@ public static ShellLinkFile Load(string filePath, STGM storageMode)
9296 /// <summary>
9397 /// Initializes a new instance of the <see cref="ShellLinkFile"/> class.
9498 /// </summary>
99+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
95100 private ShellLinkFile ( )
96101 {
97102 _shellLink = ( IShellLinkW ) new ShellLink ( ) ;
@@ -100,6 +105,7 @@ private ShellLinkFile()
100105 /// <summary>
101106 /// Finalizes an instance of the <see cref="ShellLinkFile"/> class.
102107 /// </summary>
108+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
103109 ~ ShellLinkFile ( )
104110 {
105111 Dispose ( false ) ;
@@ -185,7 +191,10 @@ public string TargetPath
185191 /// <exception cref="COMException">Thrown when the COM operation fails.</exception>
186192 public string ? Description
187193 {
194+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
188195 get => GetStringProperty ( in PInvoke . PKEY_Link_Comment ) ;
196+
197+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
189198 set => SetStringProperty ( in PInvoke . PKEY_Link_Comment , value ) ;
190199 }
191200
@@ -222,7 +231,10 @@ public string WorkingDirectory
222231 /// <exception cref="COMException">Thrown when the COM operation fails.</exception>
223232 public string ? Arguments
224233 {
234+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
225235 get => GetStringProperty ( in PInvoke . PKEY_Link_Arguments ) ;
236+
237+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
226238 set => SetStringProperty ( in PInvoke . PKEY_Link_Arguments , value ) ;
227239 }
228240
@@ -320,7 +332,10 @@ public int IconIndex
320332 /// </value>
321333 public string ? AppUserModelId
322334 {
335+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
323336 get => GetStringProperty ( in PInvoke . PKEY_AppUserModel_ID ) ;
337+
338+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
324339 set => SetStringProperty ( in PInvoke . PKEY_AppUserModel_ID , value ) ;
325340 }
326341
@@ -329,7 +344,10 @@ public string? AppUserModelId
329344 /// </summary>
330345 public bool ? AppUserModelExcludeFromShowInNewInstall
331346 {
347+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
332348 get => GetBoolProperty ( in PInvoke . PKEY_AppUserModel_ExcludeFromShowInNewInstall ) ;
349+
350+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
333351 set => SetBoolProperty ( in PInvoke . PKEY_AppUserModel_ExcludeFromShowInNewInstall , value ) ;
334352 }
335353
@@ -338,7 +356,10 @@ public bool? AppUserModelExcludeFromShowInNewInstall
338356 /// </summary>
339357 public bool ? AppUserModelIsDestListSeparator
340358 {
359+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
341360 get => GetBoolProperty ( in PInvoke . PKEY_AppUserModel_IsDestListSeparator ) ;
361+
362+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
342363 set => SetBoolProperty ( in PInvoke . PKEY_AppUserModel_IsDestListSeparator , value ) ;
343364 }
344365
@@ -347,7 +368,10 @@ public bool? AppUserModelIsDestListSeparator
347368 /// </summary>
348369 public bool ? AppUserModelIsDualMode
349370 {
371+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
350372 get => GetBoolProperty ( in PInvoke . PKEY_AppUserModel_IsDualMode ) ;
373+
374+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
351375 set => SetBoolProperty ( in PInvoke . PKEY_AppUserModel_IsDualMode , value ) ;
352376 }
353377
@@ -356,7 +380,10 @@ public bool? AppUserModelIsDualMode
356380 /// </summary>
357381 public bool ? AppUserModelPreventPinning
358382 {
383+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
359384 get => GetBoolProperty ( in PInvoke . PKEY_AppUserModel_PreventPinning ) ;
385+
386+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
360387 set => SetBoolProperty ( in PInvoke . PKEY_AppUserModel_PreventPinning , value ) ;
361388 }
362389
@@ -365,7 +392,10 @@ public bool? AppUserModelPreventPinning
365392 /// </summary>
366393 public string ? AppUserModelRelaunchCommand
367394 {
395+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
368396 get => GetStringProperty ( in PInvoke . PKEY_AppUserModel_RelaunchCommand ) ;
397+
398+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
369399 set => SetStringProperty ( in PInvoke . PKEY_AppUserModel_RelaunchCommand , value ) ;
370400 }
371401
@@ -374,7 +404,10 @@ public string? AppUserModelRelaunchCommand
374404 /// </summary>
375405 public string ? AppUserModelRelaunchDisplayNameResource
376406 {
407+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
377408 get => GetStringProperty ( in PInvoke . PKEY_AppUserModel_RelaunchDisplayNameResource ) ;
409+
410+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
378411 set => SetStringProperty ( in PInvoke . PKEY_AppUserModel_RelaunchDisplayNameResource , value ) ;
379412 }
380413
@@ -383,7 +416,10 @@ public string? AppUserModelRelaunchDisplayNameResource
383416 /// </summary>
384417 public string ? AppUserModelRelaunchIconResource
385418 {
419+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
386420 get => GetStringProperty ( in PInvoke . PKEY_AppUserModel_RelaunchIconResource ) ;
421+
422+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
387423 set => SetStringProperty ( in PInvoke . PKEY_AppUserModel_RelaunchIconResource , value ) ;
388424 }
389425
@@ -392,7 +428,10 @@ public string? AppUserModelRelaunchIconResource
392428 /// </summary>
393429 public uint ? AppUserModelStartPinOption
394430 {
431+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
395432 get => GetUInt32Property ( in PInvoke . PKEY_AppUserModel_StartPinOption ) ;
433+
434+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
396435 set => SetUInt32Property ( in PInvoke . PKEY_AppUserModel_StartPinOption , value ) ;
397436 }
398437
@@ -401,7 +440,10 @@ public uint? AppUserModelStartPinOption
401440 /// </summary>
402441 public Guid ? AppUserModelToastActivatorClsid
403442 {
443+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
404444 get => GetGuidProperty ( in PInvoke . PKEY_AppUserModel_ToastActivatorCLSID ) ;
445+
446+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
405447 set => SetGuidProperty ( in PInvoke . PKEY_AppUserModel_ToastActivatorCLSID , value ) ;
406448 }
407449
@@ -458,7 +500,10 @@ public Guid? AppUserModelToastActivatorClsid
458500 /// </summary>
459501 public bool ForceNoLinkInfo
460502 {
503+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
461504 get => GetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_FORCE_NO_LINKINFO ) ;
505+
506+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
462507 set => SetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_FORCE_NO_LINKINFO , value ) ;
463508 }
464509
@@ -473,7 +518,10 @@ public bool ForceNoLinkInfo
473518 /// </summary>
474519 public bool RunInSeparate
475520 {
521+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
476522 get => GetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_RUN_IN_SEPARATE ) ;
523+
524+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
477525 set => SetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_RUN_IN_SEPARATE , value ) ;
478526 }
479527
@@ -488,7 +536,10 @@ public bool RunInSeparate
488536 /// </summary>
489537 public bool RunAsUser
490538 {
539+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
491540 get => GetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_RUNAS_USER ) ;
541+
542+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
492543 set => SetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_RUNAS_USER , value ) ;
493544 }
494545
@@ -503,7 +554,10 @@ public bool RunAsUser
503554 /// </summary>
504555 public bool NoPidlAlias
505556 {
557+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
506558 get => GetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_NO_PIDL_ALIAS ) ;
559+
560+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
507561 set => SetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_NO_PIDL_ALIAS , value ) ;
508562 }
509563
@@ -512,7 +566,10 @@ public bool NoPidlAlias
512566 /// </summary>
513567 public bool ForceUncName
514568 {
569+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
515570 get => GetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_FORCE_UNCNAME ) ;
571+
572+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
516573 set => SetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_FORCE_UNCNAME , value ) ;
517574 }
518575
@@ -521,7 +578,10 @@ public bool ForceUncName
521578 /// </summary>
522579 public bool RunWithShimLayer
523580 {
581+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
524582 get => GetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_RUN_WITH_SHIMLAYER ) ;
583+
584+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
525585 set => SetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_RUN_WITH_SHIMLAYER , value ) ;
526586 }
527587
@@ -530,7 +590,10 @@ public bool RunWithShimLayer
530590 /// </summary>
531591 public bool ForceNoLinkTrack
532592 {
593+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
533594 get => GetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_FORCE_NO_LINKTRACK ) ;
595+
596+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
534597 set => SetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_FORCE_NO_LINKTRACK , value ) ;
535598 }
536599
@@ -539,7 +602,10 @@ public bool ForceNoLinkTrack
539602 /// </summary>
540603 public bool EnableTargetMetadata
541604 {
605+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
542606 get => GetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_ENABLE_TARGET_METADATA ) ;
607+
608+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
543609 set => SetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_ENABLE_TARGET_METADATA , value ) ;
544610 }
545611
@@ -548,7 +614,10 @@ public bool EnableTargetMetadata
548614 /// </summary>
549615 public bool DisableLinkPathTracking
550616 {
617+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
551618 get => GetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_DISABLE_LINK_PATH_TRACKING ) ;
619+
620+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
552621 set => SetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_DISABLE_LINK_PATH_TRACKING , value ) ;
553622 }
554623
@@ -557,7 +626,10 @@ public bool DisableLinkPathTracking
557626 /// </summary>
558627 public bool DisableKnownFolderRelativeTracking
559628 {
629+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
560630 get => GetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_DISABLE_KNOWNFOLDER_RELATIVE_TRACKING ) ;
631+
632+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
561633 set => SetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_DISABLE_KNOWNFOLDER_RELATIVE_TRACKING , value ) ;
562634 }
563635
@@ -566,7 +638,10 @@ public bool DisableKnownFolderRelativeTracking
566638 /// </summary>
567639 public bool NoKnownFolderAlias
568640 {
641+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
569642 get => GetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_NO_KF_ALIAS ) ;
643+
644+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
570645 set => SetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_NO_KF_ALIAS , value ) ;
571646 }
572647
@@ -575,7 +650,10 @@ public bool NoKnownFolderAlias
575650 /// </summary>
576651 public bool AllowLinkToLink
577652 {
653+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
578654 get => GetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_ALLOW_LINK_TO_LINK ) ;
655+
656+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
579657 set => SetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_ALLOW_LINK_TO_LINK , value ) ;
580658 }
581659
@@ -584,7 +662,10 @@ public bool AllowLinkToLink
584662 /// </summary>
585663 public bool UnaliasOnSave
586664 {
665+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
587666 get => GetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_UNALIAS_ON_SAVE ) ;
667+
668+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
588669 set => SetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_UNALIAS_ON_SAVE , value ) ;
589670 }
590671
@@ -593,7 +674,10 @@ public bool UnaliasOnSave
593674 /// </summary>
594675 public bool PreferEnvironmentPath
595676 {
677+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
596678 get => GetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_PREFER_ENVIRONMENT_PATH ) ;
679+
680+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
597681 set => SetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_PREFER_ENVIRONMENT_PATH , value ) ;
598682 }
599683
@@ -602,7 +686,10 @@ public bool PreferEnvironmentPath
602686 /// </summary>
603687 public bool KeepLocalIdListForUncTarget
604688 {
689+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
605690 get => GetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_KEEP_LOCAL_IDLIST_FOR_UNC_TARGET ) ;
691+
692+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
606693 set => SetFlag ( SHELL_LINK_DATA_FLAGS . SLDF_KEEP_LOCAL_IDLIST_FOR_UNC_TARGET , value ) ;
607694 }
608695
@@ -917,6 +1004,7 @@ private void SetFlags(SHELL_LINK_DATA_FLAGS flags)
9171004 /// </summary>
9181005 /// <param name="flag">The flag to get or set.</param>
9191006 /// <returns><see langword="true"/> if the flag is set; otherwise, <see langword="false"/>.</returns>
1007+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
9201008 private bool GetFlag ( SHELL_LINK_DATA_FLAGS flag )
9211009 {
9221010 return ( GetFlags ( ) & flag ) != 0 ;
0 commit comments