forked from microsoft/appcenter-sdk-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
3,427 additions
and
10 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...soft.AppCenter.WindowsDesktop.Avalonia/Microsoft.AppCenter.WindowsDesktop.Avalonia.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>netcoreapp3.0;net461;net472;net5.0;net6.0</TargetFrameworks> | ||
<RootNamespace>Microsoft.AppCenter</RootNamespace> | ||
<UseWindowsForms>false</UseWindowsForms> | ||
<Version>4.5.0</Version> | ||
<AssemblyVersion>0.0.0.0</AssemblyVersion> | ||
<FileVersion>4.5.0.0</FileVersion> | ||
<AssemblyName>Microsoft.AppCenter</AssemblyName> | ||
<DocumentationFile>bin\Microsoft.AppCenter.xml</DocumentationFile> | ||
<SignAssembly>true</SignAssembly> | ||
<AssemblyOriginatorKeyFile>..\..\..\appcenter-public-key.snk</AssemblyOriginatorKeyFile> | ||
<DelaySign>true</DelaySign> | ||
<LangVersion>latest</LangVersion> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<DefineConstants>AVALONIA;$(DefineConstants)</DefineConstants> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)' == 'Release'"> | ||
<PackageId>Aigio.Avalonia.AppCenter</PackageId> | ||
<Authors>aigio + Microsoft</Authors> | ||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<Description>This package contains the basic functionalities that all App Center services use to communicate with the backend.</Description> | ||
<NeutralLanguage>en-US</NeutralLanguage> | ||
<PackageTags>app center appcenter mobilecenter avalonia avaloniaui</PackageTags> | ||
<PackageProjectUrl>https://github.com/BeyondDimension/appcenter-sdk-dotnet</PackageProjectUrl> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright> | ||
<Company>© Microsoft Corporation. All rights reserved.</Company> | ||
<RepositoryUrl>https://github.com/BeyondDimension/appcenter-sdk-dotnet.git</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
<NeutralLanguage>en-US</NeutralLanguage> | ||
<PackageIconUrl>https://aka.ms/k76877</PackageIconUrl> | ||
<PublishRepositoryUrl>true</PublishRepositoryUrl> | ||
<EmbedUntrackedSources>true</EmbedUntrackedSources> | ||
<IncludeSymbols>true</IncludeSymbols> | ||
<SymbolPackageFormat>snupkg</SymbolPackageFormat> | ||
</PropertyGroup> | ||
<Import Project="..\Microsoft.AppCenter.Windows.Shared\Microsoft.AppCenter.Windows.Shared.projitems" Label="Shared" /> | ||
<Import Project="..\Microsoft.AppCenter.Shared\Microsoft.AppCenter.Shared.projitems" Label="Shared" /> | ||
<ItemGroup> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | ||
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.0.2" /> | ||
<PackageReference Include="Avalonia" Version="0.10.11" /> | ||
</ItemGroup> | ||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'"> | ||
<PackageReference Include="System.Management" Version="4.6.0" /> | ||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.6.0" /> | ||
<!--<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.18362.2005" />--> | ||
<PackageReference Include="Microsoft.Win32.SystemEvents" Version="4.6.0" /> | ||
<PackageReference Include="Microsoft.Win32.Registry" Version="4.6.0" /> | ||
<PackageReference Include="System.Drawing.Common" Version="4.6.0" /> | ||
</ItemGroup> | ||
<ItemGroup Condition="$(TargetFramework.EndsWith('net5.0')) OR $(TargetFramework.StartsWith('net5.0-windows'))"> | ||
<PackageReference Include="System.Management" Version="5.0.0" /> | ||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" /> | ||
<PackageReference Include="Microsoft.Win32.SystemEvents" Version="5.0.0" /> | ||
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" /> | ||
</ItemGroup> | ||
<ItemGroup Condition="$(TargetFramework.EndsWith('net6.0')) OR $(TargetFramework.StartsWith('net6.0-windows'))"> | ||
<PackageReference Include="System.Management" Version="6.0.0" /> | ||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" /> | ||
</ItemGroup> | ||
<ItemGroup Condition="'$(TargetFramework)'=='net461'"> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Configuration" /> | ||
<Reference Include="System.Deployment" /> | ||
<Reference Include="System.Management" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Windows.Forms" /> | ||
</ItemGroup> | ||
<ItemGroup Condition="'$(TargetFramework)'=='net472'"> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Configuration" /> | ||
<Reference Include="System.Deployment" /> | ||
<Reference Include="System.Management" /> | ||
<Reference Include="System.Net.Http" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="..\Microsoft.AppCenter.WindowsDesktop\**\*.cs" /> | ||
<Compile Remove="..\Microsoft.AppCenter.WindowsDesktop\bin\**" /> | ||
<Compile Remove="..\Microsoft.AppCenter.WindowsDesktop\obj\**" /> | ||
<Compile Remove="..\Microsoft.AppCenter.WindowsDesktop\Utils\ApplicationLifecycleHelperWinUI.cs" /> | ||
<Compile Remove="..\Microsoft.AppCenter.WindowsDesktop\Utils\WpfHelper.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" /> | ||
</ItemGroup> | ||
</Project> |
5 changes: 5 additions & 0 deletions
5
SDK/AppCenter/Microsoft.AppCenter.WindowsDesktop.Avalonia/Properties/AssemblyInfo.OS.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#if NET5_0_OR_GREATER | ||
using System.Runtime.Versioning; | ||
|
||
[assembly: SupportedOSPlatform("Windows")] | ||
#endif |
137 changes: 137 additions & 0 deletions
137
...AppCenter/Microsoft.AppCenter.WindowsDesktop.Avalonia/System.Windows.Forms/Application.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
// https://github.com/dotnet/winforms/blob/v6.0.1/src/System.Windows.Forms/src/System/Windows/Forms/Application.cs | ||
|
||
#if !NETFRAMEWORK | ||
using System.Diagnostics; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.IO; | ||
using System.Reflection; | ||
using System.Text; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace System.Windows.Forms | ||
{ | ||
static class Application | ||
{ | ||
private static string s_executablePath; | ||
private static Type s_mainType; | ||
private static object s_appFileVersion; | ||
private static string s_productVersion; | ||
private static readonly object s_internalSyncObject = new(); | ||
|
||
/// <summary> | ||
/// Gets the product version associated with this application. | ||
/// </summary> | ||
public static string ProductVersion | ||
{ | ||
get | ||
{ | ||
lock (s_internalSyncObject) | ||
{ | ||
if (s_productVersion is null) | ||
{ | ||
// Custom attribute | ||
Assembly entryAssembly = Assembly.GetEntryAssembly(); | ||
if (entryAssembly is not null) | ||
{ | ||
object[] attrs = entryAssembly.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false); | ||
if (attrs is not null && attrs.Length > 0) | ||
{ | ||
s_productVersion = ((AssemblyInformationalVersionAttribute)attrs[0]).InformationalVersion; | ||
} | ||
} | ||
|
||
// Win32 version info | ||
if (s_productVersion is null || s_productVersion.Length == 0) | ||
{ | ||
s_productVersion = GetAppFileVersionInfo().ProductVersion; | ||
if (s_productVersion is not null) | ||
{ | ||
s_productVersion = s_productVersion.Trim(); | ||
} | ||
} | ||
|
||
// fake it | ||
if (s_productVersion is null || s_productVersion.Length == 0) | ||
{ | ||
s_productVersion = "1.0.0.0"; | ||
} | ||
} | ||
} | ||
|
||
return s_productVersion; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Retrieves the Type that contains the "Main" method. | ||
/// </summary> | ||
private static Type GetAppMainType() | ||
{ | ||
lock (s_internalSyncObject) | ||
{ | ||
if (s_mainType is null) | ||
{ | ||
Assembly exe = Assembly.GetEntryAssembly(); | ||
|
||
// Get Main type...This doesn't work in MC++ because Main is a global function and not | ||
// a class static method (it doesn't belong to a Type). | ||
if (exe is not null) | ||
{ | ||
s_mainType = exe.EntryPoint.ReflectedType; | ||
} | ||
} | ||
} | ||
|
||
return s_mainType; | ||
} | ||
|
||
/// <summary> | ||
/// Retrieves the FileVersionInfo associated with the main module for | ||
/// the application. | ||
/// </summary> | ||
#if NET5_0_OR_GREATER | ||
[UnconditionalSuppressMessage("SingleFile", "IL3002", Justification = "Single-file case is handled")] | ||
#endif | ||
private static FileVersionInfo GetAppFileVersionInfo() | ||
{ | ||
lock (s_internalSyncObject) | ||
{ | ||
if (s_appFileVersion is null) | ||
{ | ||
Type t = GetAppMainType(); | ||
if (t is not null && t.Assembly.Location.Length > 0) | ||
{ | ||
s_appFileVersion = FileVersionInfo.GetVersionInfo(t.Module.FullyQualifiedName); | ||
} | ||
else | ||
{ | ||
s_appFileVersion = FileVersionInfo.GetVersionInfo(ExecutablePath); | ||
} | ||
} | ||
} | ||
|
||
return (FileVersionInfo)s_appFileVersion; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the path for the executable file that started the application. | ||
/// </summary> | ||
public static string ExecutablePath | ||
{ | ||
get | ||
{ | ||
if (s_executablePath is null) | ||
{ | ||
StringBuilder sb = UnsafeNativeMethods.GetModuleFileNameLongPath(NativeMethods.NullHandleRef); | ||
s_executablePath = Path.GetFullPath(sb.ToString()); | ||
} | ||
|
||
return s_executablePath; | ||
} | ||
} | ||
} | ||
} | ||
#endif |
33 changes: 33 additions & 0 deletions
33
...ppCenter/Microsoft.AppCenter.WindowsDesktop.Avalonia/System.Windows.Forms/Interop.BOOL.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
// https://github.com/dotnet/winforms/blob/v6.0.1/src/System.Windows.Forms.Primitives/src/Interop/Interop.BOOL.cs | ||
|
||
#if !NETFRAMEWORK | ||
using static Interop; | ||
|
||
internal partial class Interop | ||
{ | ||
/// <summary> | ||
/// Blittable version of Windows BOOL type. It is convenient in situations where | ||
/// manual marshalling is required, or to avoid overhead of regular bool marshalling. | ||
/// </summary> | ||
/// <remarks> | ||
/// Some Windows APIs return arbitrary integer values although the return type is defined | ||
/// as BOOL. It is best to never compare BOOL to TRUE. Always use bResult != BOOL.FALSE | ||
/// or bResult == BOOL.FALSE . | ||
/// </remarks> | ||
internal enum BOOL : int | ||
{ | ||
FALSE = 0, | ||
TRUE = 1, | ||
} | ||
} | ||
|
||
internal static class BoolExtensions | ||
{ | ||
public static bool IsTrue(this BOOL b) => b != BOOL.FALSE; | ||
public static bool IsFalse(this BOOL b) => b == BOOL.FALSE; | ||
public static BOOL ToBOOL(this bool b) => b ? BOOL.TRUE : BOOL.FALSE; | ||
} | ||
#endif |
24 changes: 24 additions & 0 deletions
24
...nter/Microsoft.AppCenter.WindowsDesktop.Avalonia/System.Windows.Forms/Interop.CreateDC.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
// https://github.com/dotnet/winforms/blob/v6.0.1/src/System.Windows.Forms.Primitives/src/Interop/Gdi32/Interop.CreateDC.cs | ||
|
||
#if !NETFRAMEWORK | ||
#nullable enable | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class Gdi32 | ||
{ | ||
/// <remarks> | ||
/// Use <see cref="DeleteDC(HDC)"/> when finished with the returned DC. | ||
/// Calling with ("DISPLAY", null, null, IntPtr.Zero) will retrieve a DC for the entire desktop. | ||
/// </remarks> | ||
[DllImport(Libraries.Gdi32, SetLastError = true, CharSet = CharSet.Unicode)] | ||
public static extern HDC CreateDC(string lpszDriver, string? lpszDeviceName, string? lpszOutput, IntPtr devMode); | ||
} | ||
} | ||
#nullable disable | ||
#endif |
17 changes: 17 additions & 0 deletions
17
...nter/Microsoft.AppCenter.WindowsDesktop.Avalonia/System.Windows.Forms/Interop.DeleteDC.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
// https://github.com/dotnet/winforms/blob/v6.0.1/src/System.Windows.Forms.Primitives/src/Interop/Gdi32/Interop.DeleteDC.cs | ||
|
||
#if !NETFRAMEWORK | ||
using System.Runtime.InteropServices; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class Gdi32 | ||
{ | ||
[DllImport(Libraries.Gdi32, SetLastError = true, ExactSpelling = true)] | ||
public static extern BOOL DeleteDC(Gdi32.HDC hDC); | ||
} | ||
} | ||
#endif |
18 changes: 18 additions & 0 deletions
18
...pCenter/Microsoft.AppCenter.WindowsDesktop.Avalonia/System.Windows.Forms/Interop.ERROR.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
// https://github.com/dotnet/winforms/blob/v6.0.1/src/System.Windows.Forms.Primitives/src/Interop/Interop.ERROR.cs | ||
|
||
#if !NETFRAMEWORK | ||
internal partial class Interop | ||
{ | ||
// https://docs.microsoft.com/windows/win32/debug/system-error-codes--0-499- | ||
internal static class ERROR | ||
{ | ||
//public const int ACCESS_DENIED = 0x0005; | ||
//public const int INVALID_HANDLE = 0x0006; | ||
//public const int INVALID_PARAMETER = 0x0057; | ||
public const int INSUFFICIENT_BUFFER = 0x007A; | ||
} | ||
} | ||
#endif |
18 changes: 18 additions & 0 deletions
18
...oft.AppCenter.WindowsDesktop.Avalonia/System.Windows.Forms/Interop.EnumDisplayMonitors.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
// https://github.com/dotnet/winforms/blob/v6.0.1/src/System.Windows.Forms.Primitives/src/Interop/User32/Interop.EnumDisplayMonitors.cs | ||
|
||
#if !NETFRAMEWORK | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class User32 | ||
{ | ||
[DllImport(Libraries.User32, ExactSpelling = true)] | ||
public unsafe static extern BOOL EnumDisplayMonitors(IntPtr hdc, RECT* rcClip, MONITORENUMPROC lpfnEnum, IntPtr dwData); | ||
} | ||
} | ||
#endif |
28 changes: 28 additions & 0 deletions
28
...Microsoft.AppCenter.WindowsDesktop.Avalonia/System.Windows.Forms/Interop.GetDeviceCaps.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
// https://github.com/dotnet/winforms/blob/v6.0.1/src/System.Windows.Forms.Primitives/src/Interop/Gdi32/Interop.GetDeviceCaps.cs | ||
|
||
#if !NETFRAMEWORK | ||
using System.Runtime.InteropServices; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class Gdi32 | ||
{ | ||
public enum DeviceCapability : int | ||
{ | ||
BITSPIXEL = 12, | ||
PLANES = 14, | ||
LOGPIXELSX = 88, | ||
LOGPIXELSY = 90 | ||
} | ||
|
||
#if !NETCOREAPP3_0 // https://github.com/dotnet/winforms/blob/v3.1.20/src/Common/src/Interop/Gdi32/Interop.GetDeviceCaps.cs | ||
[SuppressGCTransition] | ||
#endif | ||
[DllImport(Libraries.Gdi32, SetLastError = true, ExactSpelling = true)] | ||
public static extern int GetDeviceCaps(HDC hDC, DeviceCapability nIndex); | ||
} | ||
} | ||
#endif |
Oops, something went wrong.