Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Convert Xamarin.Interactive.dll from PCL to .NET Standard
Browse files Browse the repository at this point in the history
Additionally, the Xamarin.Interactive.Shared project that was consumed
by each agent assembly is gone. All those types are now part of the
actual Xamarin.Interactive.dll. Same with
Xamarin.Interactive.Bootstrap.

InspectorSupport is no longer a partial class, because the shared
projects are gone now. But we need to keep the same API for Inspector
extension compatibility, and because that API is based on static
methods there's no helpful way to abstract any of it. So there is a
little duplication now.

Xamarin.Interactive.Facades is no longer necessary, and neither is the
PCL loading code in `UnifiedInspectorSupport`.

Xamarin.Forms has been bumped from 2.3.4.231 to 2.4.0.18342 for .NET
Standard 2.0 support.

`CompilationWorkspaceFactory` has to do some manual loading of
`Xamarin.Interactive.dll` and `netstandard.dll` now, but this will go
away when dotnet/roslyn#20920 gets fixed.
  • Loading branch information
sandyarmstrong committed Nov 10, 2017
1 parent 8348640 commit 2d625ed
Show file tree
Hide file tree
Showing 84 changed files with 1,428 additions and 820 deletions.
1 change: 0 additions & 1 deletion Agents/Xamarin.Interactive.Android/AndroidAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class AndroidAgent : Agent, IViewHierarchyHandler

AG.Point displaySize;
int contentId;
string deviceIpAddress;

public IActivityTracker ActivityTracker { get; set; }
internal int ContentId => contentId;
Expand Down
34 changes: 32 additions & 2 deletions Agents/Xamarin.Interactive.Android/InspectorSupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Runtime.CompilerServices;
using System.Threading;

using Android.App;
Expand All @@ -14,13 +16,14 @@

namespace Xamarin
{
public static partial class InspectorSupport
public static class InspectorSupport
{
static readonly SynchronizationContext mainContext = Application.SynchronizationContext;
static Timer timer;
static readonly ActivityTrackerWrapper activityTracker = new ActivityTrackerWrapper ();
static Agent agent;

static partial void CreateAgent (AgentStartOptions startOptions)
static void CreateAgent (AgentStartOptions startOptions)
{
mainContext.Post (
s => {
Expand All @@ -44,5 +47,32 @@ internal static void StartBreakdance ()
1000,
Timeout.Infinite);
}

static void Start ()
{
try {
CreateAgent (new AgentStartOptions {
AgentStarted = AgentStarted,
});
} catch (Exception e) {
Console.Error.WriteLine (e);
}
}

internal static void Stop ()
{
agent?.Dispose ();
agent = null;
}

[MethodImpl (MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
static void BreakdanceStep ()
{
}

[MethodImpl (MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
internal static void AgentStarted (string agentConnectUri)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@
<Name>Xamarin.Interactive</Name>
</ProjectReference>
</ItemGroup>
<Import Project="..\Xamarin.Interactive\Xamarin.Interactive.Shared.projitems" Label="Shared" Condition="Exists('..\Xamarin.Interactive\Xamarin.Interactive.Shared.projitems')" />
<Import Project="..\..\Bootstrap\Xamarin.Interactive.Bootstrap\Xamarin.Interactive.Bootstrap.projitems" Label="Shared" Condition="Exists('..\..\Bootstrap\Xamarin.Interactive.Bootstrap\Xamarin.Interactive.Bootstrap.projitems')" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<Import Project="..\..\Build\Common.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<RootNamespace>Xamarin.Interactive.Console</RootNamespace>
<AssemblyName>Xamarin.Interactive.Console</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<!-- Work around https://bugzilla.xamarin.com/show_bug.cgi?id=58866 -->
<ImplicitlyExpandNETStandardFacades>False</ImplicitlyExpandNETStandardFacades>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -55,11 +54,6 @@
<Name>Xamarin.Interactive</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="MonoTouch.Hosting\" />
</ItemGroup>
<Import Project="..\Xamarin.Interactive\Xamarin.Interactive.Shared.projitems" Label="Shared" Condition="Exists('..\Xamarin.Interactive\Xamarin.Interactive.Shared.projitems')" />
<Import Project="..\..\Bootstrap\Xamarin.Interactive.Bootstrap\Xamarin.Interactive.Bootstrap.projitems" Label="Shared" Condition="Exists('..\..\Bootstrap\Xamarin.Interactive.Bootstrap\Xamarin.Interactive.Bootstrap.projitems')" />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="Build.targets" />
<Import Project="..\..\Build\Common.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Compile Include="..\Xamarin.Interactive.Console\MacIntegration.cs" Link="MacIntegration.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Xamarin.Interactive.NetStandard\Xamarin.Interactive.NetStandard.csproj" />
<ProjectReference Include="..\Xamarin.Interactive\Xamarin.Interactive.csproj" />
</ItemGroup>
<Import Project="..\..\Build\Common.targets" />
</Project>
16 changes: 0 additions & 16 deletions Agents/Xamarin.Interactive.Facades/Facades.cs

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void ResetStateHandler ()
{
var activity = realAgent.ActivityTracker?.StartedActivities?.FirstOrDefault ();
var formsView = Xamarin.Forms.Application.Current.MainPage;
var nativeViewGroup = Platform.GetRenderer (formsView).ViewGroup;
var nativeViewGroup = Platform.GetRenderer (formsView).View;
var parentToRestore = (ViewGroup) nativeViewGroup.Parent;

while (parentToRestore.Parent != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public AndroidFormsInspectView (Page page, bool useNativeViewBounds = false, boo
PopulateTypeInformationFromObject (page);

// TODO: Pull the ClassId or some user-set property as the description?
var nativeView = Platform.GetRenderer (page).ViewGroup;
var nativeView = Platform.GetRenderer (page).View;
if (!useNativeViewBounds) {
Transform = XIVR.GetViewTransform (nativeView);
if (Transform == null) {
Expand Down Expand Up @@ -169,7 +169,7 @@ public AndroidFormsInspectView (Element element, bool withSubviews = true)

var velement = element as VisualElement;
if (velement != null) {
var nativeView = Platform.GetRenderer (velement).ViewGroup;
var nativeView = Platform.GetRenderer (velement).View;

DisplayName = element.GetType ().Name;
try {
Expand Down Expand Up @@ -206,7 +206,7 @@ protected override void UpdateCapturedImage ()
// If the VisualElement is a view and is not a layout, snapshot its children,
// as we've reached the leaf of the tree. Otherwise, skip children.
var skipChildren = !(ve is View && !(ve is Layout));
var nativeView = Platform.GetRenderer (ve).ViewGroup;
var nativeView = Platform.GetRenderer (ve).View;
if (nativeView != null)
CapturedImage = XIVR.RenderAsPng (nativeView, skipChildren);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public AndroidFormsViewHierarchyHandler (AndroidAgent agent)

Rectangle GetNativeViewBounds (VisualElement visualElement)
{
var nativeView = Platform.GetRenderer (visualElement).ViewGroup;
var nativeView = Platform.GetRenderer (visualElement).View;
var location = new int [2];
nativeView.GetLocationOnScreen (location);

Expand All @@ -54,7 +54,7 @@ void ResetHighlightOnView ()

void DrawHighlightOnView (VisualElement element)
{
var view = Platform.GetRenderer (element).ViewGroup;
var view = Platform.GetRenderer (element).View;

highlightedView = view;
highlightedViewOriginalBackground = highlightedView.Background;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms">
<Version>2.3.4.231</Version>
<Version>2.4.0.38779</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms">
<Version>2.3.4.231</Version>
<Version>2.4.0.38779</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
58 changes: 7 additions & 51 deletions Agents/Xamarin.Interactive.Forms/Xamarin.Interactive.Forms.csproj
Original file line number Diff line number Diff line change
@@ -1,59 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<ProjectGuid>{932D2C61-5DBE-4D82-A4D6-1EA7401F10D3}</ProjectGuid>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<UseMSBuildEngine>true</UseMSBuildEngine>
<OutputType>Library</OutputType>
<RootNamespace>Xamarin.Interactive.Forms</RootNamespace>
<AssemblyName>Xamarin.Interactive.Forms</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile111</TargetFrameworkProfile>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms">
<Version>2.3.4.231</Version>
</PackageReference>
</ItemGroup>

<ItemGroup>
<Compile Include="FormsInspectViewHelper.cs" />
<Compile Include="FormsRepresentationProvider.cs" />
<Compile Include="WorkbookApplication.cs" />
<PackageReference Include="Xamarin.Forms" Version="2.4.0.38779" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Xamarin.Interactive\Xamarin.Interactive.csproj">
<Project>{955F473A-04EC-4716-B75E-509BA892499B}</Project>
<Name>Xamarin.Interactive</Name>
</ProjectReference>
<ProjectReference Include="..\Xamarin.Interactive\Xamarin.Interactive.csproj" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />

<Import Project="..\..\Build\Common.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
<Reference Include="System.Core" />
<Reference Include="Xamarin.Mac" />
</ItemGroup>
<Import Project="..\Xamarin.Interactive\Xamarin.Interactive.Shared.projitems" Label="Shared" Condition="Exists('..\Xamarin.Interactive\Xamarin.Interactive.Shared.projitems')" />
<Import Project="..\..\Bootstrap\Xamarin.Interactive.Bootstrap\Xamarin.Interactive.Bootstrap.projitems" Label="Shared" Condition="Exists('..\..\Bootstrap\Xamarin.Interactive.Bootstrap\Xamarin.Interactive.Bootstrap.projitems')" />
<Import Project="..\Xamarin.Interactive.Mac\Xamarin.Interactive.Mac.projitems" Label="Shared" Condition="Exists('..\Xamarin.Interactive.Mac\Xamarin.Interactive.Mac.projitems')" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.CSharp.targets" />
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
<Reference Include="System.Core" />
<Reference Include="Xamarin.Mac" />
</ItemGroup>
<Import Project="..\Xamarin.Interactive\Xamarin.Interactive.Shared.projitems" Label="Shared" Condition="Exists('..\Xamarin.Interactive\Xamarin.Interactive.Shared.projitems')" />
<Import Project="..\..\Bootstrap\Xamarin.Interactive.Bootstrap\Xamarin.Interactive.Bootstrap.projitems" Label="Shared" Condition="Exists('..\..\Bootstrap\Xamarin.Interactive.Bootstrap\Xamarin.Interactive.Bootstrap.projitems')" />
<Import Project="..\Xamarin.Interactive.Mac\Xamarin.Interactive.Mac.projitems" Label="Shared" Condition="Exists('..\Xamarin.Interactive.Mac\Xamarin.Interactive.Mac.projitems')" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.CSharp.targets" />
<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions Agents/Xamarin.Interactive.Mac/MacAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using Xamarin.Interactive.Inspection;
using Xamarin.Interactive.Logging;
using Xamarin.Interactive.Remote;
using Xamarin.Interactive.Unified;

namespace Xamarin.Interactive.Mac
{
Expand Down Expand Up @@ -51,6 +52,7 @@ public MacAgent ()
NSBundle.MainBundle.InfoDictionary ["CFBundleName"] as NSString);

RepresentationManager.AddProvider (new MacRepresentationProvider ());
new UnifiedNativeHelper ().Initialize ();

ViewHierarchyHandlerManager.AddViewHierarchyHandler ("AppKit", this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@
// Licensed under the MIT License.

using System;

#if IOS || MAC

using System.Runtime.InteropServices;

using ObjCRuntime;
using Foundation;

#endif

namespace Xamarin.Interactive
namespace Xamarin.Interactive.Unified
{
static class NativeExceptionHandler
{
Expand All @@ -28,18 +23,15 @@ struct Disposable : IDisposable

public class TrappedNativeException : Exception
{
#if IOS || MAC
public NSException NativeException { get; }

public TrappedNativeException (NSException realException) :
base ($"A native exception was thrown: {realException.Description}")
public TrappedNativeException (NSException realException) :
base ($"A native exception was thrown: {realException.Description}")
{
NativeException = realException;
}
#endif
}

#if IOS || MAC
[DllImport (Constants.ObjectiveCLibrary)]
static extern IntPtr objc_setExceptionPreprocessor (IntPtr handler);

Expand Down Expand Up @@ -73,13 +65,5 @@ public static void Release ()
originalHandler = IntPtr.Zero;
}
}
#else
public static IDisposable Trap ()
=> new Disposable ();

public static void Release ()
{
}
#endif
}
}
Loading

0 comments on commit 2d625ed

Please sign in to comment.