提交 0b0b076c 编写于 作者: L Lucas Meijer

Add feature that warns us whenever we build the unity_web profile, and we do...

Add feature that warns us whenever we build the unity_web profile, and we do not ship a type that we did ship before. Prevents us form accidentally breaking bw compatibility.
上级 070b1086
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Mono.Cecil;
using Mono.Linker.Steps;
namespace UnityProfileShaper
{
internal class FailIfWeMissTypesThatWeShippedInAPreviousVersionStep : BaseStep
{
protected override void ProcessAssembly(AssemblyDefinition assembly)
{
IEnumerable<string> typenames;
try
{
var path = Path.Combine(Tools.GetTuningFolder(),"TuningInput/PreviouslyShipped/" + assembly.Name.Name + ".dll");
var previousShippedVersion =
AssemblyFactory.GetAssembly(path);
typenames = previousShippedVersion.MainModule.Types.Cast<TypeDefinition>().Where(t=>t.IsPublic).Select(t => t.FullName);
} catch (FileNotFoundException)
{
//that's cool.
return;
}
var types = assembly.MainModule.Types;
foreach (var requiredtype in typenames.Where(requiredtype => !types.Cast<TypeDefinition>().Any(type => type.FullName == requiredtype)))
{
throw new Exception("The type "+requiredtype+" was shipped in a previous version of Unity, but is currently being linked away");
}
}
}
}
\ No newline at end of file
......@@ -33,8 +33,9 @@ using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using Mono.Cecil;
using Mono.Cecil;
using UnityProfileShaper;
namespace Mono.Linker.Steps
{
public class MarkPublicApiExceptStep : ResolveStep
......@@ -88,33 +89,18 @@ namespace Mono.Linker.Steps
{
if (s_ExceptionListRegexes==null)
{
var lines = ReadLinesFromDataFileWithoutPlus("MarkEverythingExceptTheseTypes.txt");
var lines = Tools.ReadLinesFromDataFileWithoutPlus("MarkEverythingExceptTheseTypes.txt");
s_ExceptionListRegexes = CreateRegexes(new List<string>(lines));
}
return s_ExceptionListRegexes;
}
static private IEnumerable<string> ReadLinesFromDataFileWithPlus(string file)
{
return ReadLinesFromDataFile(file).Where(l => l.StartsWith("+")).Select(l => l.Substring(1));
}
static private IEnumerable<string> ReadLinesFromDataFileWithoutPlus(string file)
{
return ReadLinesFromDataFile(file).Where(l => !l.StartsWith("+"));
}
static private string[] ReadLinesFromDataFile(string filename)
{
var fileinfo = new FileInfo(Assembly.GetExecutingAssembly().Location);
var datafile = Path.Combine(fileinfo.Directory.Parent.Parent.Parent.FullName, "TuningInput/"+filename);
return File.ReadAllLines(datafile).Where(l => !l.StartsWith("#")).ToArray();
}
}
private static List<Regex> s_ExceptionListOverrideRegexes;
List<Regex> GetExceptionListOverrideRegexes()
{
if (s_ExceptionListOverrideRegexes == null)
{
s_ExceptionListOverrideRegexes = CreateRegexes(new List<string>(ReadLinesFromDataFileWithPlus("MarkEverythingExceptTheseTypes.txt")));
s_ExceptionListOverrideRegexes = CreateRegexes(new List<string>(Tools.ReadLinesFromDataFileWithPlus("MarkEverythingExceptTheseTypes.txt")));
}
return s_ExceptionListOverrideRegexes;
}
......
......@@ -65,6 +65,7 @@ namespace UnityProfileShaper
p.AppendStep(new RegenerateGuidStep());
p.AppendStep(new OutputStep());
p.AppendStep(new OutputMarkBacktraceReportStep());
p.AppendStep(new FailIfWeMissTypesThatWeShippedInAPreviousVersionStep());
LinkContext context = new LinkContext(p);
context.CoreAction = AssemblyAction.Link;
......
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
namespace UnityProfileShaper
{
class Tools
{
internal static IEnumerable<string> ReadLinesFromDataFileWithPlus(string file)
{
return ReadLinesFromDataFile(file).Where(l => l.StartsWith("+")).Select(l => l.Substring(1));
}
internal static IEnumerable<string> ReadLinesFromDataFileWithoutPlus(string file)
{
return ReadLinesFromDataFile(file).Where(l => !l.StartsWith("+"));
}
internal static string[] ReadLinesFromDataFile(string filename)
{
string tuningFolder = GetTuningFolder();
var datafile = Path.Combine(tuningFolder, "TuningInput/"+filename);
return File.ReadAllLines(datafile).Where(l => !l.StartsWith("#")).ToArray();
}
internal static string GetTuningFolder()
{
var fileinfo = new FileInfo(Assembly.GetExecutingAssembly().Location);
return fileinfo.Directory.Parent.Parent.Parent.FullName;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
......@@ -50,10 +50,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FailIfWeMissTypesThatWeShippedInAPreviousVersionStep.cs" />
<Compile Include="MarkPublicAPIExceptStep.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="MarkAllFieldsOfSerializableTypes.cs" />
<Compile Include="Tools.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\mcs\class\Mono.Cecil\Mono.Cecil.csproj">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册