Skip to content

Commit c83f3e6

Browse files
committed
Support Avalonia
1 parent 7b0c8b1 commit c83f3e6

File tree

41 files changed

+3427
-10
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3427
-10
lines changed

AppCenter-SDK-Build-Windows-Avalonia.sln

Lines changed: 417 additions & 0 deletions
Large diffs are not rendered by default.

SDK/AppCenter/Microsoft.AppCenter.Shared/WrapperSdk.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ public partial class WrapperSdk
88
public const string Name = "appcenter.xamarin";
99

1010
/* We can't use reflection for assemblyInformationalVersion on iOS with "Link All" optimization. */
11-
internal const string Version = "4.5.0-SNAPSHOT";
11+
internal const string Version = "4.5.0";
1212
}
1313
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
3+
<PropertyGroup>
4+
<TargetFrameworks>netcoreapp3.0;net461;net472;net5.0;net6.0</TargetFrameworks>
5+
<RootNamespace>Microsoft.AppCenter</RootNamespace>
6+
<UseWindowsForms>false</UseWindowsForms>
7+
<Version>4.5.0</Version>
8+
<AssemblyVersion>0.0.0.0</AssemblyVersion>
9+
<FileVersion>4.5.0.0</FileVersion>
10+
<AssemblyName>Microsoft.AppCenter</AssemblyName>
11+
<DocumentationFile>bin\Microsoft.AppCenter.xml</DocumentationFile>
12+
<SignAssembly>true</SignAssembly>
13+
<AssemblyOriginatorKeyFile>..\..\..\appcenter-public-key.snk</AssemblyOriginatorKeyFile>
14+
<DelaySign>true</DelaySign>
15+
<LangVersion>latest</LangVersion>
16+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
17+
<DefineConstants>AVALONIA;$(DefineConstants)</DefineConstants>
18+
</PropertyGroup>
19+
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
20+
<PackageId>Aigio.Avalonia.AppCenter</PackageId>
21+
<Authors>aigio + Microsoft</Authors>
22+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
23+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
24+
<Description>This package contains the basic functionalities that all App Center services use to communicate with the backend.</Description>
25+
<NeutralLanguage>en-US</NeutralLanguage>
26+
<PackageTags>app center appcenter mobilecenter avalonia avaloniaui</PackageTags>
27+
<PackageProjectUrl>https://github.com/BeyondDimension/appcenter-sdk-dotnet</PackageProjectUrl>
28+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
29+
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
30+
<Company>© Microsoft Corporation. All rights reserved.</Company>
31+
<RepositoryUrl>https://github.com/BeyondDimension/appcenter-sdk-dotnet.git</RepositoryUrl>
32+
<RepositoryType>git</RepositoryType>
33+
<NeutralLanguage>en-US</NeutralLanguage>
34+
<PackageIconUrl>https://aka.ms/k76877</PackageIconUrl>
35+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
36+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
37+
<IncludeSymbols>true</IncludeSymbols>
38+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
39+
</PropertyGroup>
40+
<Import Project="..\Microsoft.AppCenter.Windows.Shared\Microsoft.AppCenter.Windows.Shared.projitems" Label="Shared" />
41+
<Import Project="..\Microsoft.AppCenter.Shared\Microsoft.AppCenter.Shared.projitems" Label="Shared" />
42+
<ItemGroup>
43+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
44+
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.0.2" />
45+
<PackageReference Include="Avalonia" Version="0.10.11" />
46+
</ItemGroup>
47+
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
48+
<PackageReference Include="System.Management" Version="4.6.0" />
49+
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.6.0" />
50+
<!--<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.18362.2005" />-->
51+
<PackageReference Include="Microsoft.Win32.SystemEvents" Version="4.6.0" />
52+
<PackageReference Include="Microsoft.Win32.Registry" Version="4.6.0" />
53+
<PackageReference Include="System.Drawing.Common" Version="4.6.0" />
54+
</ItemGroup>
55+
<ItemGroup Condition="$(TargetFramework.EndsWith('net5.0')) OR $(TargetFramework.StartsWith('net5.0-windows'))">
56+
<PackageReference Include="System.Management" Version="5.0.0" />
57+
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
58+
<PackageReference Include="Microsoft.Win32.SystemEvents" Version="5.0.0" />
59+
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
60+
</ItemGroup>
61+
<ItemGroup Condition="$(TargetFramework.EndsWith('net6.0')) OR $(TargetFramework.StartsWith('net6.0-windows'))">
62+
<PackageReference Include="System.Management" Version="6.0.0" />
63+
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />
64+
</ItemGroup>
65+
<ItemGroup Condition="'$(TargetFramework)'=='net461'">
66+
<Reference Include="Microsoft.CSharp" />
67+
<Reference Include="System.Configuration" />
68+
<Reference Include="System.Deployment" />
69+
<Reference Include="System.Management" />
70+
<Reference Include="System.Net.Http" />
71+
<Reference Include="System.Windows.Forms" />
72+
</ItemGroup>
73+
<ItemGroup Condition="'$(TargetFramework)'=='net472'">
74+
<Reference Include="Microsoft.CSharp" />
75+
<Reference Include="System.Configuration" />
76+
<Reference Include="System.Deployment" />
77+
<Reference Include="System.Management" />
78+
<Reference Include="System.Net.Http" />
79+
</ItemGroup>
80+
<ItemGroup>
81+
<Compile Include="..\Microsoft.AppCenter.WindowsDesktop\**\*.cs" />
82+
<Compile Remove="..\Microsoft.AppCenter.WindowsDesktop\bin\**" />
83+
<Compile Remove="..\Microsoft.AppCenter.WindowsDesktop\obj\**" />
84+
<Compile Remove="..\Microsoft.AppCenter.WindowsDesktop\Utils\ApplicationLifecycleHelperWinUI.cs" />
85+
<Compile Remove="..\Microsoft.AppCenter.WindowsDesktop\Utils\WpfHelper.cs" />
86+
</ItemGroup>
87+
<ItemGroup>
88+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
89+
</ItemGroup>
90+
</Project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#if NET5_0_OR_GREATER
2+
using System.Runtime.Versioning;
3+
4+
[assembly: SupportedOSPlatform("Windows")]
5+
#endif
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
// https://github.com/dotnet/winforms/blob/v6.0.1/src/System.Windows.Forms/src/System/Windows/Forms/Application.cs
5+
6+
#if !NETFRAMEWORK
7+
using System.Diagnostics;
8+
using System.Diagnostics.CodeAnalysis;
9+
using System.IO;
10+
using System.Reflection;
11+
using System.Text;
12+
13+
// ReSharper disable once CheckNamespace
14+
namespace System.Windows.Forms
15+
{
16+
static class Application
17+
{
18+
private static string s_executablePath;
19+
private static Type s_mainType;
20+
private static object s_appFileVersion;
21+
private static string s_productVersion;
22+
private static readonly object s_internalSyncObject = new();
23+
24+
/// <summary>
25+
/// Gets the product version associated with this application.
26+
/// </summary>
27+
public static string ProductVersion
28+
{
29+
get
30+
{
31+
lock (s_internalSyncObject)
32+
{
33+
if (s_productVersion is null)
34+
{
35+
// Custom attribute
36+
Assembly entryAssembly = Assembly.GetEntryAssembly();
37+
if (entryAssembly is not null)
38+
{
39+
object[] attrs = entryAssembly.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false);
40+
if (attrs is not null && attrs.Length > 0)
41+
{
42+
s_productVersion = ((AssemblyInformationalVersionAttribute)attrs[0]).InformationalVersion;
43+
}
44+
}
45+
46+
// Win32 version info
47+
if (s_productVersion is null || s_productVersion.Length == 0)
48+
{
49+
s_productVersion = GetAppFileVersionInfo().ProductVersion;
50+
if (s_productVersion is not null)
51+
{
52+
s_productVersion = s_productVersion.Trim();
53+
}
54+
}
55+
56+
// fake it
57+
if (s_productVersion is null || s_productVersion.Length == 0)
58+
{
59+
s_productVersion = "1.0.0.0";
60+
}
61+
}
62+
}
63+
64+
return s_productVersion;
65+
}
66+
}
67+
68+
/// <summary>
69+
/// Retrieves the Type that contains the "Main" method.
70+
/// </summary>
71+
private static Type GetAppMainType()
72+
{
73+
lock (s_internalSyncObject)
74+
{
75+
if (s_mainType is null)
76+
{
77+
Assembly exe = Assembly.GetEntryAssembly();
78+
79+
// Get Main type...This doesn't work in MC++ because Main is a global function and not
80+
// a class static method (it doesn't belong to a Type).
81+
if (exe is not null)
82+
{
83+
s_mainType = exe.EntryPoint.ReflectedType;
84+
}
85+
}
86+
}
87+
88+
return s_mainType;
89+
}
90+
91+
/// <summary>
92+
/// Retrieves the FileVersionInfo associated with the main module for
93+
/// the application.
94+
/// </summary>
95+
#if NET5_0_OR_GREATER
96+
[UnconditionalSuppressMessage("SingleFile", "IL3002", Justification = "Single-file case is handled")]
97+
#endif
98+
private static FileVersionInfo GetAppFileVersionInfo()
99+
{
100+
lock (s_internalSyncObject)
101+
{
102+
if (s_appFileVersion is null)
103+
{
104+
Type t = GetAppMainType();
105+
if (t is not null && t.Assembly.Location.Length > 0)
106+
{
107+
s_appFileVersion = FileVersionInfo.GetVersionInfo(t.Module.FullyQualifiedName);
108+
}
109+
else
110+
{
111+
s_appFileVersion = FileVersionInfo.GetVersionInfo(ExecutablePath);
112+
}
113+
}
114+
}
115+
116+
return (FileVersionInfo)s_appFileVersion;
117+
}
118+
119+
/// <summary>
120+
/// Gets the path for the executable file that started the application.
121+
/// </summary>
122+
public static string ExecutablePath
123+
{
124+
get
125+
{
126+
if (s_executablePath is null)
127+
{
128+
StringBuilder sb = UnsafeNativeMethods.GetModuleFileNameLongPath(NativeMethods.NullHandleRef);
129+
s_executablePath = Path.GetFullPath(sb.ToString());
130+
}
131+
132+
return s_executablePath;
133+
}
134+
}
135+
}
136+
}
137+
#endif
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
// https://github.com/dotnet/winforms/blob/v6.0.1/src/System.Windows.Forms.Primitives/src/Interop/Interop.BOOL.cs
5+
6+
#if !NETFRAMEWORK
7+
using static Interop;
8+
9+
internal partial class Interop
10+
{
11+
/// <summary>
12+
/// Blittable version of Windows BOOL type. It is convenient in situations where
13+
/// manual marshalling is required, or to avoid overhead of regular bool marshalling.
14+
/// </summary>
15+
/// <remarks>
16+
/// Some Windows APIs return arbitrary integer values although the return type is defined
17+
/// as BOOL. It is best to never compare BOOL to TRUE. Always use bResult != BOOL.FALSE
18+
/// or bResult == BOOL.FALSE .
19+
/// </remarks>
20+
internal enum BOOL : int
21+
{
22+
FALSE = 0,
23+
TRUE = 1,
24+
}
25+
}
26+
27+
internal static class BoolExtensions
28+
{
29+
public static bool IsTrue(this BOOL b) => b != BOOL.FALSE;
30+
public static bool IsFalse(this BOOL b) => b == BOOL.FALSE;
31+
public static BOOL ToBOOL(this bool b) => b ? BOOL.TRUE : BOOL.FALSE;
32+
}
33+
#endif
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
// https://github.com/dotnet/winforms/blob/v6.0.1/src/System.Windows.Forms.Primitives/src/Interop/Gdi32/Interop.CreateDC.cs
5+
6+
#if !NETFRAMEWORK
7+
#nullable enable
8+
using System;
9+
using System.Runtime.InteropServices;
10+
11+
internal static partial class Interop
12+
{
13+
internal static partial class Gdi32
14+
{
15+
/// <remarks>
16+
/// Use <see cref="DeleteDC(HDC)"/> when finished with the returned DC.
17+
/// Calling with ("DISPLAY", null, null, IntPtr.Zero) will retrieve a DC for the entire desktop.
18+
/// </remarks>
19+
[DllImport(Libraries.Gdi32, SetLastError = true, CharSet = CharSet.Unicode)]
20+
public static extern HDC CreateDC(string lpszDriver, string? lpszDeviceName, string? lpszOutput, IntPtr devMode);
21+
}
22+
}
23+
#nullable disable
24+
#endif
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
// https://github.com/dotnet/winforms/blob/v6.0.1/src/System.Windows.Forms.Primitives/src/Interop/Gdi32/Interop.DeleteDC.cs
5+
6+
#if !NETFRAMEWORK
7+
using System.Runtime.InteropServices;
8+
9+
internal static partial class Interop
10+
{
11+
internal static partial class Gdi32
12+
{
13+
[DllImport(Libraries.Gdi32, SetLastError = true, ExactSpelling = true)]
14+
public static extern BOOL DeleteDC(Gdi32.HDC hDC);
15+
}
16+
}
17+
#endif
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
// https://github.com/dotnet/winforms/blob/v6.0.1/src/System.Windows.Forms.Primitives/src/Interop/Interop.ERROR.cs
5+
6+
#if !NETFRAMEWORK
7+
internal partial class Interop
8+
{
9+
// https://docs.microsoft.com/windows/win32/debug/system-error-codes--0-499-
10+
internal static class ERROR
11+
{
12+
//public const int ACCESS_DENIED = 0x0005;
13+
//public const int INVALID_HANDLE = 0x0006;
14+
//public const int INVALID_PARAMETER = 0x0057;
15+
public const int INSUFFICIENT_BUFFER = 0x007A;
16+
}
17+
}
18+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
// https://github.com/dotnet/winforms/blob/v6.0.1/src/System.Windows.Forms.Primitives/src/Interop/User32/Interop.EnumDisplayMonitors.cs
5+
6+
#if !NETFRAMEWORK
7+
using System;
8+
using System.Runtime.InteropServices;
9+
10+
internal static partial class Interop
11+
{
12+
internal static partial class User32
13+
{
14+
[DllImport(Libraries.User32, ExactSpelling = true)]
15+
public unsafe static extern BOOL EnumDisplayMonitors(IntPtr hdc, RECT* rcClip, MONITORENUMPROC lpfnEnum, IntPtr dwData);
16+
}
17+
}
18+
#endif

0 commit comments

Comments
 (0)