Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(icon-handling) - Disposing icon after ImageSource is created from its handle #617

Merged
merged 4 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageVersion Include="xunit" Version="2.4.2" />
</ItemGroup>
</Project>
</Project>
14 changes: 7 additions & 7 deletions src/fdc3/dotnet/AppDirectory/AppDirectory.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppDirectory.Tests", "test\
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lib", "lib", "{62C29BA4-0D3B-4764-A898-38F29FF5C36C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorganStanley.ComposeUI.Testing", "..\..\..\shared\dotnet\MorganStanley.ComposeUI.Testing\MorganStanley.ComposeUI.Testing.csproj", "{08AEA9CD-1DA8-4A73-BB10-90B0EF0EE8DC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{976748F5-4871-48F4-8AE0-99ABFB733D29}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorganStanley.ComposeUI.ModuleLoader.Abstractions", "..\..\..\module-loader\dotnet\src\MorganStanley.ComposeUI.ModuleLoader.Abstractions\MorganStanley.ComposeUI.ModuleLoader.Abstractions.csproj", "{7038B36A-ADD6-4882-BFBC-ED7E4B422520}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorganStanley.ComposeUI.Testing", "..\..\..\shared\dotnet\tests\TestUtils\MorganStanley.ComposeUI.Testing\MorganStanley.ComposeUI.Testing.csproj", "{823FEEB6-1B94-42EF-B2E6-28C7A8F649E6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -31,23 +31,23 @@ Global
{EAA7B5A8-FD08-4E2F-809B-6CBD489714C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EAA7B5A8-FD08-4E2F-809B-6CBD489714C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EAA7B5A8-FD08-4E2F-809B-6CBD489714C1}.Release|Any CPU.Build.0 = Release|Any CPU
{08AEA9CD-1DA8-4A73-BB10-90B0EF0EE8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{08AEA9CD-1DA8-4A73-BB10-90B0EF0EE8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{08AEA9CD-1DA8-4A73-BB10-90B0EF0EE8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{08AEA9CD-1DA8-4A73-BB10-90B0EF0EE8DC}.Release|Any CPU.Build.0 = Release|Any CPU
{7038B36A-ADD6-4882-BFBC-ED7E4B422520}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7038B36A-ADD6-4882-BFBC-ED7E4B422520}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7038B36A-ADD6-4882-BFBC-ED7E4B422520}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7038B36A-ADD6-4882-BFBC-ED7E4B422520}.Release|Any CPU.Build.0 = Release|Any CPU
{823FEEB6-1B94-42EF-B2E6-28C7A8F649E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{823FEEB6-1B94-42EF-B2E6-28C7A8F649E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{823FEEB6-1B94-42EF-B2E6-28C7A8F649E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{823FEEB6-1B94-42EF-B2E6-28C7A8F649E6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{4B8CA047-2023-4E1A-BD73-85F7EB1D56B3} = {9E52D00C-AABB-4579-8724-6CC7049F021E}
{EAA7B5A8-FD08-4E2F-809B-6CBD489714C1} = {976748F5-4871-48F4-8AE0-99ABFB733D29}
{08AEA9CD-1DA8-4A73-BB10-90B0EF0EE8DC} = {62C29BA4-0D3B-4764-A898-38F29FF5C36C}
{7038B36A-ADD6-4882-BFBC-ED7E4B422520} = {62C29BA4-0D3B-4764-A898-38F29FF5C36C}
{823FEEB6-1B94-42EF-B2E6-28C7A8F649E6} = {62C29BA4-0D3B-4764-A898-38F29FF5C36C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D2C43446-C01E-438A-8A88-554F1351D134}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\..\shared\dotnet\MorganStanley.ComposeUI.Testing\MorganStanley.ComposeUI.Testing.csproj" />
<ProjectReference Include="..\..\..\..\..\shared\dotnet\tests\TestUtils\MorganStanley.ComposeUI.Testing\MorganStanley.ComposeUI.Testing.csproj" />
<ProjectReference Include="..\..\src\AppDirectory\AppDirectory.csproj" />
</ItemGroup>

Expand Down
14 changes: 7 additions & 7 deletions src/messaging/dotnet/Messaging.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorganStanley.ComposeUI.Mes
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lib", "lib", "{B7E63957-3C1B-4A16-B530-3EAD0D0C5F07}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorganStanley.ComposeUI.Testing", "..\..\shared\dotnet\MorganStanley.ComposeUI.Testing\MorganStanley.ComposeUI.Testing.csproj", "{AE71CBC4-FD4E-4C66-B894-D7C31DE4D1BE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorganStanley.ComposeUI.Messaging.Host.Tests", "test\Host.Tests\MorganStanley.ComposeUI.Messaging.Host.Tests.csproj", "{CEF78D3F-C645-4471-BAD2-9C538A0CA763}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorganStanley.ComposeUI.Testing", "..\..\shared\dotnet\tests\TestUtils\MorganStanley.ComposeUI.Testing\MorganStanley.ComposeUI.Testing.csproj", "{F1B0C089-450E-4B02-881F-F41A8B7F5867}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -75,14 +75,14 @@ Global
{AA63BC7C-9DB8-4062-A689-7FA9689EF6B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AA63BC7C-9DB8-4062-A689-7FA9689EF6B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AA63BC7C-9DB8-4062-A689-7FA9689EF6B1}.Release|Any CPU.Build.0 = Release|Any CPU
{AE71CBC4-FD4E-4C66-B894-D7C31DE4D1BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AE71CBC4-FD4E-4C66-B894-D7C31DE4D1BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE71CBC4-FD4E-4C66-B894-D7C31DE4D1BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE71CBC4-FD4E-4C66-B894-D7C31DE4D1BE}.Release|Any CPU.Build.0 = Release|Any CPU
{CEF78D3F-C645-4471-BAD2-9C538A0CA763}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CEF78D3F-C645-4471-BAD2-9C538A0CA763}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CEF78D3F-C645-4471-BAD2-9C538A0CA763}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CEF78D3F-C645-4471-BAD2-9C538A0CA763}.Release|Any CPU.Build.0 = Release|Any CPU
{F1B0C089-450E-4B02-881F-F41A8B7F5867}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F1B0C089-450E-4B02-881F-F41A8B7F5867}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F1B0C089-450E-4B02-881F-F41A8B7F5867}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F1B0C089-450E-4B02-881F-F41A8B7F5867}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -97,8 +97,8 @@ Global
{CDC30566-1801-40CD-9EBD-2913418FC2F9} = {78E94277-B0B4-425C-9C47-81E09933FE5B}
{29122DF1-0AE3-4101-9D96-4711553C7696} = {B245E9BB-69CC-4457-9FDF-635E742993CB}
{AA63BC7C-9DB8-4062-A689-7FA9689EF6B1} = {78E94277-B0B4-425C-9C47-81E09933FE5B}
{AE71CBC4-FD4E-4C66-B894-D7C31DE4D1BE} = {B7E63957-3C1B-4A16-B530-3EAD0D0C5F07}
{CEF78D3F-C645-4471-BAD2-9C538A0CA763} = {78E94277-B0B4-425C-9C47-81E09933FE5B}
{F1B0C089-450E-4B02-881F-F41A8B7F5867} = {B7E63957-3C1B-4A16-B530-3EAD0D0C5F07}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {38CFF5DF-459A-49E1-8189-2DB429A99B3A}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../../../../shared/dotnet/MorganStanley.ComposeUI.Testing/MorganStanley.ComposeUI.Testing.csproj" />
<ProjectReference Include="../../../../shared/dotnet/tests/TestUtils/MorganStanley.ComposeUI.Testing/MorganStanley.ComposeUI.Testing.csproj" />
<ProjectReference Include="../../src/Client/MorganStanley.ComposeUI.Messaging.Client.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<ProjectReference Include="../../src/Client/MorganStanley.ComposeUI.Messaging.Client.csproj" />
<ProjectReference Include="../../src/Server/MorganStanley.ComposeUI.Messaging.Server.csproj" />
<ProjectReference Include="../../src/Host/MorganStanley.ComposeUI.Messaging.Host.csproj" />
<ProjectReference Include="../../../../shared/dotnet/MorganStanley.ComposeUI.Testing/MorganStanley.ComposeUI.Testing.csproj" />
<ProjectReference Include="../../../../shared/dotnet/tests/TestUtils/MorganStanley.ComposeUI.Testing/MorganStanley.ComposeUI.Testing.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<ItemGroup>
<ProjectReference Include="../../src/Server/MorganStanley.ComposeUI.Messaging.Server.csproj" />
<ProjectReference Include="../../../../shared/dotnet/MorganStanley.ComposeUI.Testing/MorganStanley.ComposeUI.Testing.csproj" />
<ProjectReference Include="../../../../shared/dotnet/tests/TestUtils/MorganStanley.ComposeUI.Testing/MorganStanley.ComposeUI.Testing.csproj" />
</ItemGroup>

</Project>
10 changes: 10 additions & 0 deletions src/shared/dotnet/MorganStanley.ComposeUI.Shared.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorganStanley.ComposeUI.Uti
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorganStanley.ComposeUI.Utilities.Tests", "tests\MorganStanley.ComposeUI.Utilities.Tests\MorganStanley.ComposeUI.Utilities.Tests.csproj", "{ED668A15-0186-41CD-B79D-2D9F18A6F15B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestUtils", "TestUtils", "{01E62FC1-7F5E-4C75-8F6C-1C9027BCBFEC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorganStanley.ComposeUI.Testing", "tests\TestUtils\MorganStanley.ComposeUI.Testing\MorganStanley.ComposeUI.Testing.csproj", "{71213EAF-2B49-4756-AD62-EE3C1CB7315C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -25,13 +29,19 @@ Global
{ED668A15-0186-41CD-B79D-2D9F18A6F15B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED668A15-0186-41CD-B79D-2D9F18A6F15B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED668A15-0186-41CD-B79D-2D9F18A6F15B}.Release|Any CPU.Build.0 = Release|Any CPU
{71213EAF-2B49-4756-AD62-EE3C1CB7315C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{71213EAF-2B49-4756-AD62-EE3C1CB7315C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{71213EAF-2B49-4756-AD62-EE3C1CB7315C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{71213EAF-2B49-4756-AD62-EE3C1CB7315C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{13B9FB01-144E-4BBE-9920-1C69B44FB711} = {8E838164-6370-4320-ACD5-CD1E6631C09C}
{ED668A15-0186-41CD-B79D-2D9F18A6F15B} = {51355F98-9BDE-42CA-B284-296AAE6B6B38}
{01E62FC1-7F5E-4C75-8F6C-1C9027BCBFEC} = {51355F98-9BDE-42CA-B284-296AAE6B6B38}
{71213EAF-2B49-4756-AD62-EE3C1CB7315C} = {01E62FC1-7F5E-4C75-8F6C-1C9027BCBFEC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EF62D6D0-E133-4C3A-A1AF-79C44BAD39C4}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Morgan Stanley makes this available to you under the Apache License,
* Version 2.0 (the "License"). You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.
*
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. Unless required by applicable law or agreed
* to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/

using System.Runtime.InteropServices;
using System;

namespace MorganStanley.ComposeUI.Utilities;

public static class NativeMethods
{
[DllImport("gdi32.dll", SetLastError = true)]
public static extern bool DeleteObject(in IntPtr hObject);
}
4 changes: 3 additions & 1 deletion src/shell/dotnet/Shell.sln
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{DA
examples\module-catalog.json = examples\module-catalog.json
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiagnosticsExample", "..\..\..\examples\dotnet-diagnostics\DiagnosticsExample\DiagnosticsExample.csproj", "{24E64AFE-D2C5-487D-85F3-B0CE5AC0A128}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiagnosticsExample", "..\..\..\examples\dotnet-diagnostics\DiagnosticsExample\DiagnosticsExample.csproj", "{24E64AFE-D2C5-487D-85F3-B0CE5AC0A128}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9173857E-84BF-4F8B-906B-39BCF0A8915B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
11 changes: 5 additions & 6 deletions src/shell/dotnet/Shell/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
using MorganStanley.ComposeUI.ModuleLoader;
using MorganStanley.ComposeUI.Shell.Abstractions;
using MorganStanley.ComposeUI.Shell.Fdc3;
using MorganStanley.ComposeUI.Shell.ImageSource;
using MorganStanley.ComposeUI.Shell.Messaging;
using MorganStanley.ComposeUI.Shell.Modules;
using MorganStanley.ComposeUI.Shell.Utilities;
Expand Down Expand Up @@ -125,7 +124,7 @@
};

await _host.Services.GetRequiredService<IMessageRouter>().RegisterServiceAsync("Diagnostics", (e, m, t) =>
ValueTask.FromResult(MessageBuffer.Factory.CreateJson(diagnostics))!);
ValueTask.FromResult(MessageBuffer.Factory.CreateJson(diagnostics))!);

Check warning on line 127 in src/shell/dotnet/Shell/App.xaml.cs

View check run for this annotation

Codecov / codecov/patch

src/shell/dotnet/Shell/App.xaml.cs#L127

Added line #L127 was not covered by tests

await OnHostInitializedAsync();

Expand Down Expand Up @@ -231,10 +230,10 @@
});

var moduleLoader = _host.Services.GetRequiredService<IModuleLoader>();
moduleLoader.StartModule(new StartRequest(moduleId, new List<KeyValuePair<string, string>>()
{
{ new(WebWindowOptions.ParameterName, JsonSerializer.Serialize(webWindowOptions)) }
}));
moduleLoader.StartModule(new StartRequest(moduleId, new List<KeyValuePair<string, string>>
{
new(WebWindowOptions.ParameterName, JsonSerializer.Serialize(webWindowOptions))
}));

Check warning on line 236 in src/shell/dotnet/Shell/App.xaml.cs

View check run for this annotation

Codecov / codecov/patch

src/shell/dotnet/Shell/App.xaml.cs#L233-L236

Added lines #L233 - L236 were not covered by tests

return;
}
Expand Down
8 changes: 4 additions & 4 deletions src/shell/dotnet/Shell/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ See the License for the specific language governing permissions and limitations
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MorganStanley.ComposeUI.Shell"
mc:Ignorable="d"
Title="ComposeUI Shell"
Height="450"
Width="600"
Title="ComposeUI Shell"
Height="450"
Width="600"
Background="{DynamicResource {x:Static SystemColors.AppWorkspaceBrushKey}}"
WindowStartupLocation="CenterScreen"
Initialized="RibbonWindow_Initialized">
Initialized="RibbonWindow_Initialized">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
Expand Down
16 changes: 10 additions & 6 deletions src/shell/dotnet/Shell/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
using System.IO;
using System.Windows;
using System.Windows.Controls.Ribbon;
using System.Windows.Media.Imaging;
using CommunityToolkit.Mvvm.ComponentModel;
using MorganStanley.ComposeUI.ModuleLoader;
using MorganStanley.ComposeUI.Shell.ImageSource;
using MorganStanley.ComposeUI.Shell.Utilities;
using IconUtilities = MorganStanley.ComposeUI.Shell.Utilities.IconUtilities;

namespace MorganStanley.ComposeUI.Shell;

Expand Down Expand Up @@ -106,12 +107,15 @@
}
else if (manifest.TryGetDetails<NativeManifestDetails>(out var nativeManifestDetails))
{
var icon = System.Drawing.Icon.ExtractAssociatedIcon(Path.GetFullPath(nativeManifestDetails.Path.ToString()));
using var icon =
System.Drawing.Icon.ExtractAssociatedIcon(Path.GetFullPath(nativeManifestDetails.Path.ToString()));

Check warning on line 111 in src/shell/dotnet/Shell/MainWindow.xaml.cs

View check run for this annotation

Codecov / codecov/patch

src/shell/dotnet/Shell/MainWindow.xaml.cs#L110-L111

Added lines #L110 - L111 were not covered by tests

ImageSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(
icon.Handle,
new Int32Rect { Width = icon.Width, Height = icon.Height },
BitmapSizeOptions.FromEmptyOptions());
if (icon != null)
{
using var bitmap = icon.ToBitmap();

Check warning on line 115 in src/shell/dotnet/Shell/MainWindow.xaml.cs

View check run for this annotation

Codecov / codecov/patch

src/shell/dotnet/Shell/MainWindow.xaml.cs#L115

Added line #L115 was not covered by tests

ImageSource = bitmap.ToImageSource();

Check warning on line 117 in src/shell/dotnet/Shell/MainWindow.xaml.cs

View check run for this annotation

Codecov / codecov/patch

src/shell/dotnet/Shell/MainWindow.xaml.cs#L117

Added line #L117 was not covered by tests
}
}
}

Expand Down
33 changes: 21 additions & 12 deletions src/shell/dotnet/Shell/Utilities/DiagnosticInfo.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// /*
// * Morgan Stanley makes this available to you under the Apache License,
// * Version 2.0 (the "License"). You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0.
// *
// * See the NOTICE file distributed with this work for additional information
// * regarding copyright ownership. Unless required by applicable law or agreed
// * to in writing, software distributed under the License is distributed on an
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// * or implied. See the License for the specific language governing permissions
// * and limitations under the License.
// */

namespace MorganStanley.ComposeUI.Shell.Utilities
using System;

namespace MorganStanley.ComposeUI.Shell.Utilities;

internal class DiagnosticInfo
{
internal class DiagnosticInfo
{
public DateTime StartupTime { get; set; }
public string ShellVersion { get; set; }
}
}
public DateTime StartupTime { get; set; }
public string ShellVersion { get; set; }

Check warning on line 22 in src/shell/dotnet/Shell/Utilities/DiagnosticInfo.cs

View check run for this annotation

Codecov / codecov/patch

src/shell/dotnet/Shell/Utilities/DiagnosticInfo.cs#L21-L22

Added lines #L21 - L22 were not covered by tests
}
49 changes: 49 additions & 0 deletions src/shell/dotnet/Shell/Utilities/IconUtilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// /*
// * Morgan Stanley makes this available to you under the Apache License,
// * Version 2.0 (the "License"). You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0.
// *
// * See the NOTICE file distributed with this work for additional information
// * regarding copyright ownership. Unless required by applicable law or agreed
// * to in writing, software distributed under the License is distributed on an
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// * or implied. See the License for the specific language governing permissions
// * and limitations under the License.
// */

using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Media.Imaging;
using MorganStanley.ComposeUI.Utilities;

namespace MorganStanley.ComposeUI.Shell.Utilities;
public static class IconUtilities
{
public static System.Windows.Media.ImageSource ToImageSource(this Bitmap bitmap)
lilla28 marked this conversation as resolved.
Show resolved Hide resolved
{
try
{
using var memoryStream = new MemoryStream();

bitmap.Save(memoryStream, ImageFormat.Png);
memoryStream.Position = 0;

var bitmapImage = new BitmapImage();

bitmapImage.BeginInit();
bitmapImage.StreamSource = memoryStream;
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.EndInit();
bitmapImage.Freeze();

return bitmapImage;
}
finally
{
NativeMethods.DeleteObject(bitmap.GetHbitmap());
}
}
}

1 change: 1 addition & 0 deletions src/shell/dotnet/tests/Shell.Tests/Shell.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="FluentAssertions" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Loading
Loading