Skip to content

Commit

Permalink
feat: Upgrade UWPSyncGenerator to Roslyn 3.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Jun 10, 2020
1 parent 9ba1537 commit 3a8f8b9
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 39 deletions.
4 changes: 2 additions & 2 deletions build/Uno.UI.Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@
</Target>

<Target Name="GenerateDoc" DependsOnTargets="BuildSyncGenerator">
<Exec Command="..\src\Uno.UWPSyncGenerator\Bin\Release\net461\Uno.UWPSyncGenerator.exe &quot;doc&quot;" />
<Exec Command="..\src\Uno.UWPSyncGenerator\Bin\Release\Uno.UWPSyncGenerator.exe &quot;doc&quot;" />
<Exec Command="$(Pkgdocfx_console)\tools\docfx.exe ..\doc\docfx.json -o $(OutputDir)\doc" />
</Target>

<Target Name="RunAPISyncTool" DependsOnTargets="BuildSyncGenerator">

<Exec Command="..\src\Uno.UWPSyncGenerator\Bin\Release\net461\Uno.UWPSyncGenerator.exe &quot;sync&quot;" />
<Exec Command="..\src\Uno.UWPSyncGenerator\Bin\Release\Uno.UWPSyncGenerator.exe &quot;sync&quot;" />
</Target>

<Target Name="PublishVisx" Condition="'$(UNO_UWP_BUILD)'=='true'">
Expand Down
1 change: 1 addition & 0 deletions src/AddIns/Uno.UI.Lottie/WasmScripts/uno-lottie.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare const require: any;
declare const config: any;
declare namespace Uno.UI {
import AnimationData = Lottie.AnimationData;
interface LottieAnimationProperties {
Expand Down
2 changes: 1 addition & 1 deletion src/AddIns/Uno.UI.Lottie/WasmScripts/uno-lottie.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ var Uno;
action(Lottie._player);
}
else {
require(["lottie"], (p) => {
require([`${config.uno_app_base}/lottie`], (p) => {
if (!Lottie._player) {
Lottie._player = p;
}
Expand Down
3 changes: 2 additions & 1 deletion src/AddIns/Uno.UI.Lottie/ts/Uno.UI.Lottie.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare const require: any;
declare const config: any;

namespace Uno.UI {
import AnimationData = Lottie.AnimationData;
Expand Down Expand Up @@ -242,7 +243,7 @@ namespace Uno.UI {
if (Lottie._player) {
action(Lottie._player);
} else {
require(["lottie"], (p: LottiePlayer) => {
require([`${config.uno_app_base}/lottie`], (p: LottiePlayer) => {
if (!Lottie._player) {
Lottie._player = p;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI.Wasm.Tests/WasmScripts/UnitTests.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require(["Uno.UI"], () => {
require([`${config.uno_app_base}/Uno.UI`], () => {
MonoSupport.jsCallDispatcher.registerScope("TSBindingsUnitTests", new TSBindingsTests());
});
class TSBindingsTests {
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI.Wasm.Tests/ts/TSBindingsTests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require(["Uno.UI"], () => {
require([`${config.uno_app_base}/Uno.UI`], () => {

MonoSupport.jsCallDispatcher.registerScope("TSBindingsUnitTests", new TSBindingsTests());

Expand Down
1 change: 1 addition & 0 deletions src/Uno.UI.Wasm/WasmScripts/Uno.UI.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ declare namespace MonoSupport {
private static getMethodMapId;
}
}
declare const config: any;
declare namespace Uno.UI {
class WindowManager {
private containerElementId;
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI.Wasm/WasmScripts/Uno.UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -1734,7 +1734,7 @@ var Uno;
WindowManager.MAX_HEIGHT = `${Number.MAX_SAFE_INTEGER}vh`;
UI.WindowManager = WindowManager;
if (typeof define === "function") {
define(["AppManifest"], () => {
define([`${config.uno_app_base}/AppManifest`], () => {
});
}
else {
Expand Down
5 changes: 3 additions & 2 deletions src/Uno.UI.Wasm/ts/WindowManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

declare const config: any;

// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Uno.UI {

Expand Down Expand Up @@ -1829,7 +1830,7 @@ namespace Uno.UI {

if (typeof define === "function") {
define(
["AppManifest"],
[`${config.uno_app_base}/AppManifest`],
() => {
}
);
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UWPSyncGenerator/DocGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Uno.UWPSyncGenerator
/// </summary>
class DocGenerator : Generator
{
private const string DocPath = @"..\..\..\..\..\doc\articles";
private const string DocPath = @"..\..\..\..\doc\articles";
private const string ImplementedViewsFileName = "implemented-views.md";
private const string ImplementedPath = @"./implemented/";

Expand Down
29 changes: 19 additions & 10 deletions src/Uno.UWPSyncGenerator/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public virtual void Build(string basePath, string baseName, string sourceAssembl

Console.WriteLine($"Generating for {baseName} {sourceAssembly}");

_referenceCompilation = LoadProject(@"..\..\..\..\Uno.UWPSyncGenerator.Reference\Uno.UWPSyncGenerator.Reference.csproj");
_referenceCompilation = LoadProject(@"..\..\..\Uno.UWPSyncGenerator.Reference\Uno.UWPSyncGenerator.Reference.csproj");
_iOSCompilation = LoadProject($@"{basePath}\{baseName}.csproj", "xamarinios10");
_androidCompilation = LoadProject($@"{basePath}\{baseName}.csproj", "MonoAndroid10.0");
_net461Compilation = LoadProject($@"{basePath}\{baseName}.csproj", "net461");
Expand Down Expand Up @@ -162,7 +162,7 @@ protected string GetNamespaceBasePath(INamedTypeSymbol type)
{
if (type.ContainingAssembly.Name == "Windows.Foundation.FoundationContract")
{
return @"..\..\..\..\Uno.Foundation\Generated\2.0.0.0";
return @"..\..\..\Uno.Foundation\Generated\2.0.0.0";
}
else if (!(
type.ContainingNamespace.ToString().StartsWith("Windows.UI.Xaml")
Expand All @@ -173,11 +173,11 @@ protected string GetNamespaceBasePath(INamedTypeSymbol type)
#endif
))
{
return @"..\..\..\..\Uno.UWP\Generated\3.0.0.0";
return @"..\..\..\Uno.UWP\Generated\3.0.0.0";
}
else
{
return @"..\..\..\..\Uno.UI\Generated\3.0.0.0";
return @"..\..\..\Uno.UI\Generated\3.0.0.0";
}
}

Expand Down Expand Up @@ -304,14 +304,22 @@ protected PlatformSymbols<INamedTypeSymbol> GetAllSymbols(INamedTypeSymbol uapTy
}

private PlatformSymbols<ISymbol> GetAllGetNonGeneratedMembers(PlatformSymbols<INamedTypeSymbol> types, string name, Func<IEnumerable<ISymbol>, ISymbol> filter, ISymbol uapSymbol = null)
=> new PlatformSymbols<ISymbol>(
filter(GetNonGeneratedMembers(types.AndroidSymbol, name)),
filter(GetNonGeneratedMembers(types.IOSSymbol, name)),
filter(GetNonGeneratedMembers(types.MacOSSymbol, name)),
filter(GetNonGeneratedMembers(types.net461ymbol, name)),
filter(GetNonGeneratedMembers(types.WasmSymbol, name)),
{
var android = GetNonGeneratedMembers(types.AndroidSymbol, name);
var ios = GetNonGeneratedMembers(types.IOSSymbol, name);
var macOS = GetNonGeneratedMembers(types.MacOSSymbol, name);
var net461 = GetNonGeneratedMembers(types.net461ymbol, name);
var wasm = GetNonGeneratedMembers(types.WasmSymbol, name);

return new PlatformSymbols<ISymbol>(
filter(android),
filter(ios),
filter(macOS),
filter(net461),
filter(wasm),
uapType: uapSymbol
);
}

protected PlatformSymbols<IMethodSymbol> GetAllMatchingMethods(PlatformSymbols<INamedTypeSymbol> types, IMethodSymbol method)
=> new PlatformSymbols<IMethodSymbol>(
Expand Down Expand Up @@ -1484,6 +1492,7 @@ private static Compilation InnerLoadProject(string projectFile, string targetFra
//{ "BuildingInsideVisualStudio", "true" },
{ "SkipUnoResourceGeneration", "true" }, // Required to avoid loading a non-existent task
{ "DocsGeneration", "true" }, // Detect that source generation is running
{ "LangVersion", "8.0" },
//{ "DesignTimeBuild", "true" },
//{ "UseHostCompilerIfAvailable", "false" },
//{ "UseSharedCompilation", "false" },
Expand Down
1 change: 1 addition & 0 deletions src/Uno.UWPSyncGenerator/Helpers/ProjectLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public static ProjectDetails LoadProjectDetails(string projectFile, string confi
properties["Configuration"] = configuration;
properties["UseHostCompilerIfAvailable"] = "true";
properties["UseSharedCompilation"] = "true";
properties["LangVersion"] = "8.0";

// Platform is intentionally kept as not defined, to avoid having
// dependent projects being loaded with a platform they don't support.
Expand Down
20 changes: 10 additions & 10 deletions src/Uno.UWPSyncGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,26 @@ static void Main(string[] args)

if (mode == SyncMode || mode == AllMode)
{
new SyncGenerator().Build(@"..\..\..\..\Uno.Foundation", "Uno.Foundation", "Windows.Foundation.FoundationContract");
new SyncGenerator().Build(@"..\..\..\..\Uno.UWP", "Uno", "Windows.Foundation.UniversalApiContract");
new SyncGenerator().Build(@"..\..\..\..\Uno.UWP", "Uno", "Windows.Phone.PhoneContract");
new SyncGenerator().Build(@"..\..\..\..\Uno.UWP", "Uno", "Windows.Networking.Connectivity.WwanContract");
new SyncGenerator().Build(@"..\..\..\..\Uno.UWP", "Uno", "Windows.ApplicationModel.Calls.CallsPhoneContract");
new SyncGenerator().Build(@"..\..\..\Uno.Foundation", "Uno.Foundation", "Windows.Foundation.FoundationContract");
new SyncGenerator().Build(@"..\..\..\Uno.UWP", "Uno", "Windows.Foundation.UniversalApiContract");
new SyncGenerator().Build(@"..\..\..\Uno.UWP", "Uno", "Windows.Phone.PhoneContract");
new SyncGenerator().Build(@"..\..\..\Uno.UWP", "Uno", "Windows.Networking.Connectivity.WwanContract");
new SyncGenerator().Build(@"..\..\..\Uno.UWP", "Uno", "Windows.ApplicationModel.Calls.CallsPhoneContract");

#if HAS_UNO_WINUI
new SyncGenerator().Build(@"..\..\..\..\Uno.UI", "Uno.UI", "Microsoft.UI");
new SyncGenerator().Build(@"..\..\..\..\Uno.UI", "Uno.UI", "Microsoft.System");
new SyncGenerator().Build(@"..\..\..\Uno.UI", "Uno.UI", "Microsoft.UI");
new SyncGenerator().Build(@"..\..\..\Uno.UI", "Uno.UI", "Microsoft.System");
#else
new SyncGenerator().Build(@"..\..\..\..\Uno.UI", "Uno.UI", "Windows.Foundation.UniversalApiContract");
new SyncGenerator().Build(@"..\..\..\Uno.UI", "Uno.UI", "Windows.Foundation.UniversalApiContract");
#endif
}

if (mode == DocMode || mode == AllMode)
{
#if HAS_UNO_WINUI
new DocGenerator().Build(@"..\..\..\..\Uno.UI", "Uno.UI", "Microsoft.UI");
new DocGenerator().Build(@"..\..\..\Uno.UI", "Uno.UI", "Microsoft.UI");
#else
new DocGenerator().Build(@"..\..\..\..\Uno.UI", "Uno.UI", "Windows.Foundation.UniversalApiContract");
new DocGenerator().Build(@"..\..\..\Uno.UI", "Uno.UI", "Windows.Foundation.UniversalApiContract");
#endif
}
}
Expand Down
19 changes: 10 additions & 9 deletions src/Uno.UWPSyncGenerator/Uno.UWPSyncGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net461</TargetFramework>
<TargetFramework>net472</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
Expand All @@ -29,27 +30,27 @@
<Version>15.8.166</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis">
<Version>2.9.0</Version>
<Version>3.6.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.Common">
<Version>2.9.0</Version>
<Version>3.6.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp">
<Version>2.9.0</Version>
<Version>3.6.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces">
<Version>2.9.0</Version>
<Version>3.6.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic">
<Version>2.9.0</Version>
<Version>3.6.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces">
<Version>2.9.0</Version>
<Version>3.6.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common">
<Version>2.9.0</Version>
<Version>3.6.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="2.9.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="3.6.0" />
<PackageReference Include="Microsoft.Tpl.Dataflow">
<Version>4.5.24</Version>
</PackageReference>
Expand Down

0 comments on commit 3a8f8b9

Please sign in to comment.