@@ -84,58 +84,17 @@ public sealed class CodeConverterPackage : AsyncPackage
8484
8585 internal Cancellation PackageCancellation { get ; } = new Cancellation ( ) ;
8686
87- private readonly AssemblyName _thisAssemblyName ;
88- private readonly HashSet < string > _ourAssemblyNames ;
8987 /// <summary>
9088 /// Initializes a new instance of package class.
9189 /// </summary>
9290 public CodeConverterPackage ( )
9391 {
94- var thisAssembly = GetType ( ) . Assembly ;
95- _thisAssemblyName = thisAssembly . GetName ( ) ;
96- _ourAssemblyNames = new HashSet < string > ( new [ ] { _thisAssemblyName } . Concat ( thisAssembly . GetReferencedAssemblies ( ) . Where ( a => a . Name . StartsWith ( "ICSharpCode" ) ) ) . Select ( a => a . FullName ) ) ;
9792 // Inside this method you can place any initialization code that does not require
9893 // any Visual Studio service because at this point the package object is created but
9994 // not sited yet inside Visual Studio environment. The place to do all the other
10095 // initialization is the Initialize method.
10196 }
10297
103- // System.Threading.Tasks.Dataflow 4.5.24.0 shipped with VS2017 15.9.21+28307.1064 but we want to target 4.6.0.0
104- private Assembly LoadWithoutVersionForOurDependencies ( object sender , ResolveEventArgs args )
105- {
106- var requestedAssemblyName = new AssemblyName ( args . Name ) ;
107- if ( requestedAssemblyName . Version != null && IsThisExtensionRequestingAssembly ( ) ) {
108- return LoadAnyVersionOfAssembly ( requestedAssemblyName ) ;
109- }
110- return null ;
111-
112- }
113-
114- private static Assembly LoadAnyVersionOfAssembly ( AssemblyName assemblyName )
115- {
116- try {
117- return Assembly . Load ( new AssemblyName ( assemblyName . Name ) { CultureName = assemblyName . CultureName } ) ;
118- } catch ( FileNotFoundException e ) when ( e . FileName . Contains ( "Microsoft.VisualStudio.LanguageServices" ) && ProbablyRequiresVsUpgrade ) {
119- MessageBox . Show (
120- "Code Converter cannot find `Microsoft.VisualStudio.LanguageServices`. Please upgrade Visual Studio to version 15.9.3 or above.\r \n \r \n " +
121- "If after upgrading you still see this error, attach your activity log %AppData%\\ Microsoft\\ VisualStudio\\ <version>\\ ActivityLog.xml to a GitHub issue at https://github.com/icsharpcode/CodeConverter \r \n \r \n " +
122- "You can press Ctrl + C to copy this message" ,
123- "Upgrade Visual Studio" , MessageBoxButton . OK ) ;
124- return null ;
125- }
126- }
127-
128- private bool IsThisExtensionRequestingAssembly ( )
129- {
130- return GetPossibleRequestingAssemblies ( ) . Any ( requesting => _ourAssemblyNames . Contains ( requesting . FullName ) ) ;
131- }
132-
133- private IEnumerable < AssemblyName > GetPossibleRequestingAssemblies ( )
134- {
135- return new StackTrace ( ) . GetFrames ( ) . Select ( f => f . GetMethod ( ) . DeclaringType ? . Assembly )
136- . Select ( a => a . GetName ( ) ) . SkipWhile ( a => Equals ( a , _thisAssemblyName ) ) ;
137- }
138-
13998 /// <summary>
14099 /// Initialization of the package; this method is called right after the package is sited, so this is the place
141100 /// where you can put all the initialization code that rely on services provided by VisualStudio.
@@ -155,25 +114,6 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
155114 await base . InitializeAsync ( cancellationToken , progress ) ;
156115 }
157116
158- public static bool ProbablyRequiresVsUpgrade {
159- get {
160- var version = FullVsVersion ;
161- return version == null || version < new Version ( 15 , 9 , 3 , 0 ) ;
162- }
163- }
164-
165- private static Version FullVsVersion {
166- get {
167- string path = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "msenv.dll" ) ;
168-
169- if ( File . Exists ( path ) ) {
170- var fvi = FileVersionInfo . GetVersionInfo ( path ) ;
171- return new Version ( fvi . ProductMajorPart , fvi . ProductMinorPart , fvi . ProductBuildPart ,
172- fvi . ProductPrivatePart ) ;
173- } else return null ;
174- }
175- }
176-
177117 internal OleMenuCommandWithBlockingStatus CreateCommand ( Func < CancellationToken , Task > callbackAsync , CommandID menuCommandId )
178118 {
179119 return new OleMenuCommandWithBlockingStatus ( JoinableTaskFactory , PackageCancellation , callbackAsync , menuCommandId ) ;
0 commit comments