Add analyzer bootstrap phase (#2540)
The existing integration test build will now also use the live analyzer built first.
This commit is contained in:
Родитель
2999a6a9dd
Коммит
5fca8b890c
|
@ -1,2 +1,2 @@
|
||||||
@echo off
|
@echo off
|
||||||
powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\common\Build.ps1""" -restore -build %*"
|
powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\Build.ps1""" -restore -build %*"
|
||||||
|
|
|
@ -4,4 +4,16 @@
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="$(MicrosoftCodeAnalysisCSharpCodeStyleVersion)" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="$(MicrosoftCodeAnalysisCSharpCodeStyleVersion)" PrivateAssets="all" />
|
||||||
<!-- <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.205" PrivateAssets="all" /> -->
|
<!-- <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.205" PrivateAssets="all" /> -->
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Import Project="$(BootstrapBuildPath)/Microsoft.NET.ILLink.Analyzers.props" Condition="'$(BootstrapBuildPath)' != ''" />
|
||||||
|
|
||||||
|
<!-- Don't enable for Cecil, as they can't be suppressed -->
|
||||||
|
<PropertyGroup Condition="'$(BootstrapBuildPath)' != '' and '$(MSBuildProjectName)' != 'Mono.Cecil.Pdb'">
|
||||||
|
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(BootstrapBuildPath)' != ''">
|
||||||
|
<Analyzer Include="$(BootstrapBuildPath)/ILLink.RoslynAnalyzer.dll" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<Project Sdk="Microsoft.DotNet.Arcade.Sdk">
|
||||||
|
|
||||||
|
<Target Name="Build">
|
||||||
|
<MSBuild Projects="../src/ILLink.RoslynAnalyzer/ILLink.RoslynAnalyzer.csproj"
|
||||||
|
Targets="Restore" />
|
||||||
|
<MSBuild Projects="../src/ILLink.RoslynAnalyzer/ILLink.RoslynAnalyzer.csproj"
|
||||||
|
Properties="OutDir=$(ArtifactsDir)/bootstrap"
|
||||||
|
Targets="Build" />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
|
@ -0,0 +1,17 @@
|
||||||
|
[CmdletBinding(PositionalBinding=$false)]
|
||||||
|
Param(
|
||||||
|
[switch] $integrationTest,
|
||||||
|
[Parameter(ValueFromRemainingArguments=$true)][String[]]$remaining
|
||||||
|
)
|
||||||
|
|
||||||
|
. (Join-Path $PSScriptRoot "common/tools.ps1")
|
||||||
|
|
||||||
|
$args = $remaining.Clone()
|
||||||
|
|
||||||
|
if ($integrationTest) {
|
||||||
|
dotnet build (Join-Path $PSScriptRoot bootstrap.proj)
|
||||||
|
$args += "-integrationTest"
|
||||||
|
$args += "/p:BootstrapBuildPath=$ArtifactsDir/bootstrap"
|
||||||
|
}
|
||||||
|
|
||||||
|
powershell -ExecutionPolicy ByPass -NoProfile (Join-Path $PSScriptRoot "common/build.ps1") @args
|
|
@ -175,10 +175,10 @@ namespace ILLink.RoslynAnalyzer
|
||||||
for (int i = 0; i < typeParams.Length; i++) {
|
for (int i = 0; i < typeParams.Length; i++) {
|
||||||
var typeParam = typeParams[i];
|
var typeParam = typeParams[i];
|
||||||
var typeArg = typeArgs[i];
|
var typeArg = typeArgs[i];
|
||||||
if (!typeParam.HasConstructorConstraint)
|
if (!typeParam.HasConstructorConstraint ||
|
||||||
|
typeArg is not INamedTypeSymbol { InstanceConstructors: { } typeArgCtors })
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var typeArgCtors = ((INamedTypeSymbol) typeArg).InstanceConstructors;
|
|
||||||
foreach (var instanceCtor in typeArgCtors) {
|
foreach (var instanceCtor in typeArgCtors) {
|
||||||
if (instanceCtor.Arity > 0)
|
if (instanceCtor.Arity > 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -174,8 +174,11 @@ namespace Mono.Linker.Steps
|
||||||
|
|
||||||
using (var fs = File.Open (Path.Combine (Context.OutputDirectory, Context.PInvokesListFile), FileMode.Create)) {
|
using (var fs = File.Open (Path.Combine (Context.OutputDirectory, Context.PInvokesListFile), FileMode.Create)) {
|
||||||
var values = Context.PInvokes.Distinct ().OrderBy (l => l);
|
var values = Context.PInvokes.Distinct ().OrderBy (l => l);
|
||||||
|
// Ignore warning, since we're just enabling analyzer for dogfooding
|
||||||
|
#pragma warning disable IL2026
|
||||||
var jsonSerializer = new DataContractJsonSerializer (typeof (List<PInvokeInfo>));
|
var jsonSerializer = new DataContractJsonSerializer (typeof (List<PInvokeInfo>));
|
||||||
jsonSerializer.WriteObject (fs, values);
|
jsonSerializer.WriteObject (fs, values);
|
||||||
|
#pragma warning restore IL2026
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -832,7 +832,11 @@ namespace Mono.Linker
|
||||||
if (File.Exists (assemblyPath)) {
|
if (File.Exists (assemblyPath)) {
|
||||||
// The CLR will return the already-loaded assembly if the same path is requested multiple times
|
// The CLR will return the already-loaded assembly if the same path is requested multiple times
|
||||||
// (or even if a different path specifies the "same" assembly, based on the MVID).
|
// (or even if a different path specifies the "same" assembly, based on the MVID).
|
||||||
|
|
||||||
|
// Ignore warning, since we're just enabling analyzer for dogfooding
|
||||||
|
#pragma warning disable IL2026
|
||||||
return AssemblyLoadContext.Default.LoadFromAssemblyPath (assemblyPath);
|
return AssemblyLoadContext.Default.LoadFromAssemblyPath (assemblyPath);
|
||||||
|
#pragma warning restore IL2026
|
||||||
}
|
}
|
||||||
Context.LogError (null, DiagnosticId.AssemblyInCustomStepOptionCouldNotBeFound, arg);
|
Context.LogError (null, DiagnosticId.AssemblyInCustomStepOptionCouldNotBeFound, arg);
|
||||||
} else
|
} else
|
||||||
|
@ -992,7 +996,10 @@ namespace Mono.Linker
|
||||||
|
|
||||||
Type? ResolveStepType (string type, Assembly assembly)
|
Type? ResolveStepType (string type, Assembly assembly)
|
||||||
{
|
{
|
||||||
|
// Ignore warning, since we're just enabling analyzer for dogfooding
|
||||||
|
#pragma warning disable IL2026
|
||||||
Type? step = assembly != null ? assembly.GetType (type) : Type.GetType (type, false);
|
Type? step = assembly != null ? assembly.GetType (type) : Type.GetType (type, false);
|
||||||
|
#pragma warning restore IL2026
|
||||||
|
|
||||||
if (step == null) {
|
if (step == null) {
|
||||||
Context.LogError (null, DiagnosticId.CustomStepTypeCouldNotBeFound, type);
|
Context.LogError (null, DiagnosticId.CustomStepTypeCouldNotBeFound, type);
|
||||||
|
@ -1004,7 +1011,10 @@ namespace Mono.Linker
|
||||||
|
|
||||||
TStep? ResolveStep<TStep> (string type, Assembly assembly) where TStep : class
|
TStep? ResolveStep<TStep> (string type, Assembly assembly) where TStep : class
|
||||||
{
|
{
|
||||||
|
// Ignore warning, since we're just enabling analyzer for dogfooding
|
||||||
|
#pragma warning disable IL2026
|
||||||
Type? step = assembly != null ? assembly.GetType (type) : Type.GetType (type, false);
|
Type? step = assembly != null ? assembly.GetType (type) : Type.GetType (type, false);
|
||||||
|
#pragma warning restore IL2026
|
||||||
|
|
||||||
if (step == null) {
|
if (step == null) {
|
||||||
Context.LogError (null, DiagnosticId.CustomStepTypeCouldNotBeFound, type);
|
Context.LogError (null, DiagnosticId.CustomStepTypeCouldNotBeFound, type);
|
||||||
|
|
|
@ -5,6 +5,8 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
@ -190,9 +192,13 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
|
||||||
|
|
||||||
class TestType { }
|
class TestType { }
|
||||||
|
|
||||||
|
static T MakeNew<T> () where T : new() => new T ();
|
||||||
|
static T MakeNew2<T> () where T : new() => MakeNew<T> ();
|
||||||
|
|
||||||
public static void Test ()
|
public static void Test ()
|
||||||
{
|
{
|
||||||
GenericTypeWithStaticMethodViaLdftn ();
|
GenericTypeWithStaticMethodViaLdftn ();
|
||||||
|
MakeNew2<TestType> ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче