Skip to content

Commit

Permalink
Merge pull request #4 from koszeggy/Development
Browse files Browse the repository at this point in the history
Releasing version v2.4.0
  • Loading branch information
koszeggy authored Jul 2, 2021
2 parents 29f936f + 3fff58c commit 7e3c416
Show file tree
Hide file tree
Showing 218 changed files with 11,098 additions and 3,131 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage("Style", "IDE0090:Use 'new(...)'", Justification = "Decided individually")]
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<UseCodebase>true</UseCodebase>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\KGySoft.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
Expand All @@ -24,7 +18,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>KGySoft.Drawing.DebuggerVisualizers.Package</RootNamespace>
<AssemblyName>KGySoft.Drawing.DebuggerVisualizers.Package</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<GeneratePkgDefFile>true</GeneratePkgDefFile>
<IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer>
<IncludeDebugSymbolsInVSIXContainer>true</IncludeDebugSymbolsInVSIXContainer>
Expand All @@ -34,6 +28,8 @@
<StartAction>Program</StartAction>
<StartProgram Condition="'$(DevEnvDir)' != ''">$(DevEnvDir)devenv.exe</StartProgram>
<StartArguments>/rootsuffix Exp</StartArguments>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -53,6 +49,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
Expand All @@ -67,6 +64,7 @@
<Compile Include="_Attributes\PackageRegistrationAsyncAttribute.cs" />
<Compile Include="_Attributes\ProvideAutoLoadAsyncAttribute.cs" />
<Compile Include="_Classes\ShellDialogs.cs" />
<Compile Include="_Classes\ViewHelper.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\KGySoft.snk">
Expand All @@ -79,6 +77,7 @@
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<None Include="readme.md" />
<None Include="source.extension.vsixmanifest">
<SubType>Designer</SubType>
</None>
Expand All @@ -101,11 +100,11 @@
<EmbedInteropTypes>False</EmbedInteropTypes>
<Private>False</Private>
</Reference>
<Reference Include="KGySoft.CoreLibraries, Version=5.4.0.0, Culture=neutral, PublicKeyToken=b45eba277439ddfe, processorArchitecture=MSIL">
<HintPath>..\..\packages\KGySoft.CoreLibraries.5.4.0\lib\net45\KGySoft.CoreLibraries.dll</HintPath>
<Reference Include="KGySoft.CoreLibraries, Version=5.6.1.0, Culture=neutral, PublicKeyToken=b45eba277439ddfe, processorArchitecture=MSIL">
<HintPath>..\..\packages\KGySoft.CoreLibraries.5.6.1\lib\net45\KGySoft.CoreLibraries.dll</HintPath>
</Reference>
<Reference Include="KGySoft.Drawing, Version=5.3.0.0, Culture=neutral, PublicKeyToken=b45eba277439ddfe, processorArchitecture=MSIL">
<HintPath>..\..\packages\KGySoft.Drawing.5.3.0\lib\net45\KGySoft.Drawing.dll</HintPath>
<Reference Include="KGySoft.Drawing, Version=5.3.1.0, Culture=neutral, PublicKeyToken=b45eba277439ddfe, processorArchitecture=MSIL">
<HintPath>..\..\packages\KGySoft.Drawing.5.3.1\lib\net45\KGySoft.Drawing.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.GraphModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\VSSDK.GraphModel.11.0.4\lib\net45\Microsoft.VisualStudio.GraphModel.dll</HintPath>
Expand Down
11 changes: 5 additions & 6 deletions KGySoft.Drawing.DebuggerVisualizers.Package/Res.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#endregion

#nullable enable

namespace KGySoft.Drawing.DebuggerVisualizers.Package
{
#region Usings
Expand Down Expand Up @@ -72,9 +74,9 @@ internal static class Res

private static string Get(string id) => Resources.ResourceManager.GetString(id) ?? String.Format(CultureInfo.InvariantCulture, unavailableResource, id);

private static string Get(string format, params object[] args) => args == null ? format : SafeFormat(format, args);
private static string Get(string format, params object?[]? args) => args == null ? format : SafeFormat(format, args);

private static string SafeFormat(string format, object[] args)
private static string SafeFormat(string format, object?[] args)
{
try
{
Expand All @@ -83,10 +85,7 @@ private static string SafeFormat(string format, object[] args)
{
string nullRef = PublicResources.Null;
for (; i < args.Length; i++)
{
if (args[i] == null)
args[i] = nullRef;
}
args[i] ??= nullRef;
}

return String.Format(LanguageSettings.FormattingLanguage, format, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#endregion

#nullable enable

namespace KGySoft.Drawing.DebuggerVisualizers.Package
{
/// <summary>
Expand All @@ -46,7 +48,7 @@ internal sealed class PackageRegistrationAsyncAttribute : RegistrationAttribute
public override void Register(RegistrationContext context)
{
Type t = context.ComponentType;
Key packageKey = null;
Key? packageKey = null;
try
{
packageKey = context.CreateKey(RegKeyName(context));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#endregion

#nullable enable

namespace KGySoft.Drawing.DebuggerVisualizers.Package
{
/// <summary>
Expand All @@ -39,16 +41,16 @@ internal sealed class ProvideAutoLoadAsyncAttribute : RegistrationAttribute

#region Properties

private string RegKeyName => $"AutoLoadPackages\\{new Guid(VSConstants.UICONTEXT.NoSolution_string):B}";
private static string RegKeyName => $"AutoLoadPackages\\{new Guid(VSConstants.UICONTEXT.NoSolution_string):B}";

#endregion

#region Methods

public override void Register(RegistrationContext context)
{
using (Key childKey = context.CreateKey(RegKeyName))
childKey.SetValue(context.ComponentType.GUID.ToString("B"), backgroundLoad);
using Key childKey = context.CreateKey(RegKeyName);
childKey.SetValue(context.ComponentType.GUID.ToString("B"), backgroundLoad);
}

public override void Unregister(RegistrationContext context) => context.RemoveValue(RegKeyName, context.ComponentType.GUID.ToString("B"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

#endregion

#nullable enable

namespace KGySoft.Drawing.DebuggerVisualizers.Package
{
#region Usings
Expand Down Expand Up @@ -62,7 +64,7 @@ public sealed class DebuggerVisualizersPackage : Microsoft.VisualStudio.Shell.Pa
/// </summary>
public IVsTask Initialize(IAsyncServiceProvider pServiceProvider, IProfferAsyncService pProfferService, IAsyncProgressCallback pProgressCallback)
{
return ThreadHelper.JoinableTaskFactory.RunAsync<object>(async () =>
return ThreadHelper.JoinableTaskFactory.RunAsync<object?>(async () =>
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
var shellService = await GetServiceAsync<IVsShell>(pServiceProvider, typeof(SVsShell));
Expand All @@ -83,16 +85,13 @@ protected override void Initialize()
{
base.Initialize();

#pragma warning disable VSTHRD108, VSTHRD010 // Invoke single-threaded types on Main thread: Initialize is on Main thread (see also the assert and IAsyncLoadablePackageInitialize.Initialize)

// returning if async initialization is supported
Debug.Assert(ThreadHelper.CheckAccess());
if (GetService(typeof(SAsyncServiceProvider)) is IAsyncServiceProvider)
return;

var uiShellService = GetService(typeof(SVsShell)) as IVsShell;
var menuCommandService = GetService(typeof(IMenuCommandService)) as IMenuCommandService;
#pragma warning restore VSTHRD010, VSTHRD010 // Invoke single-threaded types on Main thread

DoInitialize(uiShellService, menuCommandService);
}
Expand All @@ -102,16 +101,17 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing);
if (!disposing)
return;
DestroyCommands();
ExecuteImagingToolsCommand.DestroyCommand();
ManageDebuggerVisualizerInstallationsCommand.DestroyCommand();
}

#endregion

#region Private Methods

private async Task<T> GetServiceAsync<T>(IAsyncServiceProvider asyncServiceProvider, Type serviceType) where T : class
private async Task<T?> GetServiceAsync<T>(IAsyncServiceProvider asyncServiceProvider, Type serviceType) where T : class
{
T result = null;
T? result = null;
await ThreadHelper.JoinableTaskFactory.RunAsync(async () =>
{
Guid serviceTypeGuid = serviceType.GUID;
Expand All @@ -123,7 +123,7 @@ await ThreadHelper.JoinableTaskFactory.RunAsync(async () =>
return result;
}

private void DoInitialize(IVsShell shellService, IMenuCommandService menuCommandService)
private void DoInitialize(IVsShell? shellService, IMenuCommandService? menuCommandService)
{
if (initialized)
return;
Expand All @@ -133,7 +133,7 @@ private void DoInitialize(IVsShell shellService, IMenuCommandService menuCommand
InitCommands(shellService, menuCommandService);
}

private void InstallIfNeeded(IVsShell shellService)
private void InstallIfNeeded(IVsShell? shellService)
{
if (shellService == null)
{
Expand All @@ -150,29 +150,27 @@ private void InstallIfNeeded(IVsShell shellService)
if (installedVersion.Installed && (installedVersion.Version == null || installedVersion.Version >= availableVersion.Version))
return;

InstallationManager.Install(targetPath, out string error, out string warning);
InstallationManager.Install(targetPath, out string? error, out string? warning);
if (error != null)
ShellDialogs.Error(this, Res.ErrorMessageFailedToInstall(targetPath, error));
else if (warning != null)
ShellDialogs.Warning(this, Res.WarningMessageInstallationFinishedWithWarning(targetPath, warning));
else if (installedVersion.Installed && installedVersion.Version != null)
ShellDialogs.Info(this, Res.InfoMessageUpgradeFinished(installedVersion.Version, availableVersion.Version, targetPath));
ShellDialogs.Info(this, Res.InfoMessageUpgradeFinished(installedVersion.Version, availableVersion.Version!, targetPath));
else
ShellDialogs.Info(this, Res.InfoMessageInstallationFinished(availableVersion.Version, targetPath));
ShellDialogs.Info(this, Res.InfoMessageInstallationFinished(availableVersion.Version!, targetPath));
}

private void InitCommands(IVsShell shellService, IMenuCommandService menuCommandService)
private void InitCommands(IVsShell? shellService, IMenuCommandService? menuCommandService)
{
// no menu point will be added
if (menuCommandService == null)
return;

menuCommandService.AddCommand(ExecuteImagingToolsCommand.GetCreateCommand(this));
menuCommandService.AddCommand(ManageDebuggerVisualizerInstallationsCommand.GetCreateCommand(this, shellService));
}

private void DestroyCommands()
{
ExecuteImagingToolsCommand.DestroyCommand();
ManageDebuggerVisualizerInstallationsCommand.DestroyCommand();
}

#endregion

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@

#endregion

#nullable enable

namespace KGySoft.Drawing.DebuggerVisualizers.Package
{
internal static class ExecuteImagingToolsCommand
{
#region Fields

private static MenuCommand commandInstance;
private static IServiceProvider serviceProvider;
private static IViewModel imagingToolsViewModel;
private static IView imagingToolsView;
private static MenuCommand? commandInstance;
private static IServiceProvider? serviceProvider;
private static volatile IView? imagingToolsView;

#endregion

Expand All @@ -58,8 +59,6 @@ internal static void DestroyCommand()
{
imagingToolsView?.Dispose();
imagingToolsView = null;
imagingToolsViewModel?.Dispose();
imagingToolsViewModel = null;
}

#endregion
Expand All @@ -71,20 +70,15 @@ private static void OnExecuteImagingToolsCommand(object sender, EventArgs e)
try
{
if (imagingToolsView == null || imagingToolsView.IsDisposed)
{
imagingToolsViewModel?.Dispose();
imagingToolsViewModel = ViewModelFactory.CreateDefault();
imagingToolsView = ViewFactory.CreateView(imagingToolsViewModel);
}

imagingToolsView.Show();
imagingToolsView = ViewHelper.CreateViewInNewThread(ViewModelFactory.CreateDefault);
else
imagingToolsView.Show();
}
catch (Exception ex)
{
imagingToolsView?.Dispose();
imagingToolsViewModel?.Dispose();
imagingToolsView = null;
ShellDialogs.Error(serviceProvider, Res.ErrorMessageUnexpectedError(ex.Message));
ShellDialogs.Error(serviceProvider!, Res.ErrorMessageUnexpectedError(ex.Message));
}
}

Expand Down
4 changes: 3 additions & 1 deletion KGySoft.Drawing.DebuggerVisualizers.Package/_Classes/Ids.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#endregion

#nullable enable

namespace KGySoft.Drawing.DebuggerVisualizers.Package
{
internal static class Ids
Expand All @@ -30,7 +32,7 @@ internal static class Ids
internal const string ResourceTitle = "110";
internal const string ResourceDetails = "112";
internal const int IconResourceId = 400;
internal const string Version = "2.3.0"; // Note: in .vsixmanifest it should be adjusted manually
internal const string Version = "2.4.0"; // Note: in .vsixmanifest it should be adjusted manually
internal const int ExecuteImagingToolsCommandId = 0x0100;
internal const int ManageDebuggerVisualizerInstallationsCommandId = 0x0101;

Expand Down
Loading

0 comments on commit 7e3c416

Please sign in to comment.