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

Commit

Permalink
Merge pull request #1021 from brandonh-msft/hurlburb/vsix-offline
Browse files Browse the repository at this point in the history
Pivot VSIX to use offline mode
  • Loading branch information
brandonh-msft authored Aug 10, 2022
2 parents 479561c + 4dc4129 commit e5ce3a4
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 26 deletions.
3 changes: 2 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputDrop>$(TF_BUILD_BINARIESDIRECTORY)</OutputDrop>
<NoWarn>$(NoWarn),1570,1572,1573,1574,1591,1701</NoWarn>
<NoWarn>$(NoWarn),1570,1572,1573,1574,1591,1701,MSB3275,VSTHRD010,VSTHRD100,VSTHRD101,VSSDK006</NoWarn>
<Features>IOperation;$(Features)</Features>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)\rules.ruleset</CodeAnalysisRuleSet>
<WriteVersionInfoToBuildLog>True</WriteVersionInfoToBuildLog>
Expand Down Expand Up @@ -36,6 +36,7 @@
our PRs because of the CI builds -->
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>$(NoWarn)</NoWarn>
</PropertyGroup>

<PropertyGroup>
Expand Down
18 changes: 17 additions & 1 deletion src/ApiPort/ApiPort.VisualStudio/ApiPort.VisualStudio.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,17 @@
<PackageReference Include="Microsoft.Composition" Version="1.0.31" />
<PackageReference Include="Microsoft.Tpl.Dataflow" Version="4.5.24" />
<PackageReference Include="Microsoft.VisualStudio.Shell.15.0" Version="15.4.27004" />
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="15.6.170" />
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="17.3.2092">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="VSLangProj140" Version="14.0.25030" />
<PackageReference Include="VSLangProj150" Version="15.0.26229" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyRedirectResolver.cs" />
<Compile Include="AutofacComRegisterExtensions.cs" />
<Compile Include="DependencyBuilder.Offline.cs" />
<Compile Include="Properties\Properties.cs" />
<Compile Include="Reporting\ToolbarListReportViewer.cs" />
<Compile Include="StatusBarProgressReporter.cs" />
Expand Down Expand Up @@ -122,6 +126,18 @@
<None Include="Resources\Images.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\lib\Microsoft.Fx.Portability.Offline\Microsoft.Fx.Portability.Offline.csproj">
<Project>{f3d148ca-d49d-4315-9cd6-ae7b0eea9549}</Project>
<Name>Microsoft.Fx.Portability.Offline</Name>
</ProjectReference>
<ProjectReference Include="..\..\lib\Microsoft.Fx.Portability.Reports.DGML\Microsoft.Fx.Portability.Reports.DGML.csproj">
<Project>{1b6e53a7-9180-4d79-9556-e5ce59483ea1}</Project>
<Name>Microsoft.Fx.Portability.Reports.DGML</Name>
</ProjectReference>
<ProjectReference Include="..\..\lib\Microsoft.Fx.Portability.Reports.Excel\Microsoft.Fx.Portability.Reports.Excel.csproj">
<Project>{47008779-1d31-4e0c-b21a-5f4fb84470a0}</Project>
<Name>Microsoft.Fx.Portability.Reports.Excel</Name>
</ProjectReference>
<ProjectReference Include="..\ApiPort.VisualStudio.Common\ApiPort.VisualStudio.Common.csproj">
<Project>{60798b82-b273-4d39-aa52-021c7228a0ad}</Project>
<Name>ApiPort.VisualStudio.Common</Name>
Expand Down
64 changes: 64 additions & 0 deletions src/ApiPort/ApiPort.VisualStudio/DependencyBuilder.Offline.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Autofac;

using Microsoft.Fx.Portability;
using Microsoft.Fx.Portability.Analysis;
using Microsoft.Fx.Portability.Analyzer;
using Microsoft.Fx.Portability.Reporting;

using System;
using System.IO;
using System.Reflection;

namespace ApiPort
{
internal static class DependencyBuilder
{
internal const string DefaultOutputFormatInstanceName = "DefaultOutputFormat";

public static void RegisterOfflineModule(this ContainerBuilder builder)
{
builder.RegisterType<DependencyOrderer>()
.As<IDependencyOrderer>()
.SingleInstance();

builder.RegisterType<RequestAnalyzer>()
.As<IRequestAnalyzer>()
.SingleInstance();

builder.RegisterType<AnalysisEngine>()
.As<IAnalysisEngine>()
.SingleInstance();

builder.RegisterModule(new OfflineDataModule(DefaultOutputFormatInstanceName));
LoadReportWriters(builder);
}

private static void LoadReportWriters(ContainerBuilder builder)
{
foreach (var path in Directory.EnumerateFiles(GetApplicationDirectory(), "Microsoft.Fx.Portability.Reports.*.dll"))
{
try
{
var name = new AssemblyName(Path.GetFileNameWithoutExtension(path));
var assembly = Assembly.Load(name);

builder.RegisterAssemblyTypes(assembly)
.AssignableTo<IReportWriter>()
.As<IReportWriter>()
.SingleInstance();
}
catch (Exception)
{
}
}
}

private static string GetApplicationDirectory()
{
return Path.GetDirectoryName(typeof(DependencyBuilder).GetTypeInfo().Assembly.Location);
}
}
}
15 changes: 9 additions & 6 deletions src/ApiPort/ApiPort.VisualStudio/ServiceProvider.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using ApiPort;

using ApiPortVS.Analyze;
using ApiPortVS.Contracts;
using ApiPortVS.Models;
Expand All @@ -9,8 +11,11 @@
using ApiPortVS.SourceMapping;
using ApiPortVS.ViewModels;
using ApiPortVS.Views;

using Autofac;

using EnvDTE;

using Microsoft.Fx.Portability;
using Microsoft.Fx.Portability.Analyzer;
using Microsoft.Fx.Portability.Proxy;
Expand All @@ -19,14 +24,13 @@
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

using static Microsoft.VisualStudio.VSConstants;

using Tasks = System.Threading.Tasks;

namespace ApiPortVS
Expand Down Expand Up @@ -66,10 +70,9 @@ public static async Task<ServiceProvider> CreateAsync(ApiPortVSPackage servicePr
builder.RegisterType<VisualStudioProxyProvider>()
.As<IProxyProvider>()
.SingleInstance();
builder.RegisterType<ApiPortService>()
.As<IApiPortService>()
.WithParameter(TypedParameter.From(DefaultEndpoint))
.SingleInstance();

builder.RegisterOfflineModule();

builder.RegisterType<ApiPortClient>()
.AsSelf()
.SingleInstance();
Expand Down
5 changes: 4 additions & 1 deletion src/ApiPort/ApiPort.Vsix/ApiPort.Vsix.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.SDK.VsixSuppression" Version="14.1.33" />
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="15.6.170" />
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="17.3.2092">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ApiPort.VisualStudio.2017\ApiPort.VisualStudio.2017.csproj">
Expand Down
6 changes: 5 additions & 1 deletion src/ApiPort/ApiPort.Vsix/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<Metadata>
<Identity Id="55d15546-28ca-40dc-af23-dfa503e9c5fe" Version="1.4.0" Language="en-US" Publisher="Microsoft" />
<DisplayName>.NET Portability Analyzer</DisplayName>
<Description xml:space="preserve">Evaluates portability of assemblies across .NET platforms</Description>
<Description xml:space="preserve">Evaluates portability of assemblies across .NET platforms

[IMPORTANT]
Due to an ongoing issue, this update is required to continue using Portability Analysis within Visual Studio while Engineering investigates.
This version will execute in offline mode which removes capability for HTML report output and runs the entire analysis in-memory.</Description>
<MoreInfo>https://aka.ms/dotnet-portabilityanalyzer</MoreInfo>
<License>LICENSE.txt</License>
<Icon>Resources\Package.ico</Icon>
Expand Down
2 changes: 1 addition & 1 deletion src/ApiPort/ApiPort/ApiPort.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.CommandLine" Version="0.1.0-e171125-2" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
Expand Down
22 changes: 13 additions & 9 deletions src/lib/Microsoft.Fx.Portability.Reports.DGML/ReferenceGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.Fx.Portability.ObjectModel;

using System.Collections.Generic;
using System.Linq;

Expand Down Expand Up @@ -33,20 +34,23 @@ public static ReferenceGraph CreateGraph(AnalyzeResponse response)
}

// create nodes for all the references, if non platform.
foreach (var reference in userAsem.AssemblyReferences)
if (userAsem.AssemblyReferences != null)
{
if (!(assembliesWithData.ContainsKey(reference.ToString()) || unresolvedAssemblies.Contains(reference.ToString())))
foreach (var reference in userAsem.AssemblyReferences)
{
// platform reference (not in the user specified asssemblies and not an unresolved assembly.
continue;
}
if (!(assembliesWithData.ContainsKey(reference.ToString()) || unresolvedAssemblies.Contains(reference.ToString())))
{
// platform reference (not in the user specified asssemblies and not an unresolved assembly.
continue;
}

var refNode = rg.GetOrAddNodeForAssembly(new ReferenceNode(reference.ToString()));
var refNode = rg.GetOrAddNodeForAssembly(new ReferenceNode(reference.ToString()));

// if the reference is missing, flag it as such.
refNode.IsMissing = unresolvedAssemblies.Contains(reference.ToString());
// if the reference is missing, flag it as such.
refNode.IsMissing = unresolvedAssemblies.Contains(reference.ToString());

node.AddReferenceToNode(refNode);
node.AddReferenceToNode(refNode);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Collections.Immutable" Version="1.4.0" />
Expand Down
2 changes: 1 addition & 1 deletion tests/ApiPort/ApiPortVS.Tests/ApiPortVS.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="15.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NSubstitute" Version="3.1.0" />
<PackageReference Include="System.Reflection.Metadata" Version="1.5.0" />
<PackageReference Include="xunit" Version="2.3.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="15.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NSubstitute" Version="3.1.0" />
<PackageReference Include="System.Reflection.Metadata" Version="1.5.0" />
<PackageReference Include="xunit" Version="2.3.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<!--Reference to Microsoft.NETCore.Platforms to workaround https://github.com/dotnet/cli/issues/12341. Remove the reference once build machine moves to .NET Core 3.0-->
<PackageReference Include="Microsoft.NETCore.Platforms" Version="3.0.0" />
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="15.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NSubstitute" Version="3.1.0" />
<PackageReference Include="System.Collections.Immutable" Version="1.4.0" />
<PackageReference Include="System.Diagnostics.FileVersionInfo " Version="4.3.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="15.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NSubstitute" Version="3.1.0" />
<PackageReference Include="System.Diagnostics.FileVersionInfo " Version="4.3.0" />
<PackageReference Include="xunit" Version="2.3.1" />
Expand Down

0 comments on commit e5ce3a4

Please sign in to comment.