Merge pull request #6 from unoplatform/dev/jela/fix-return-type

Fix return type validation
This commit is contained in:
Jérôme Laban 2019-12-03 13:26:26 -05:00 коммит произвёл GitHub
Родитель df62011100 0849b539e6
Коммит 80d22b3228
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 55 добавлений и 11 удалений

Просмотреть файл

@ -71,9 +71,7 @@ jobs:
clean: all
pool:
name: Default
demands:
- agent.os -equals Linux
vmImage: 'ubuntu-18.04'
variables:
NUGET_PACKAGES: $(Agent.WorkFolder)/.nuget

Просмотреть файл

@ -7,7 +7,7 @@ published nuget package (in nuget.org) and a local NuGet package.
## Installing
Run the following command from commandline (requires .NET Core 2.1 installed):
Run the following command from command line (requires .NET Core 2.1 installed):
```
dotnet tool install --global Uno.PackageDiff
@ -32,22 +32,22 @@ Here's the format:
<IgnoreSets>
<IgnoreSet baseVersion="1.0.0">
<Types>
<Member fullName="MyNamespace.MyMissingClass"/>
<Member fullName="MyNamespace.MyMissingClass" />
</Types>
<Properties>
<Member fullName="MyNamespace.MyClass.MyProperty"/>
<Member fullName="MyNamespace.MyClass.MyProperty" />
</Properties>
<Fields>
<Member fullName="MyNamespace.MyClass.myField"/>
<Member fullName="MyNamespace.MyClass.myField" />
</Fields>
<Events>
<Member fullName="MyNamespace.MyClass.MyEvent"/>
<Member fullName="MyNamespace.MyClass.MyEvent" />
</Events>
<Methods>
<Member fullName="MyNamespace.MyClass.MyMethod"/>
<Member fullName="MyNamespace.MyClass.MyMethod" />
</Methods>
<Methods>
<Member fullName="MyNamespace.MyClass.MyMethod"/>
<Member fullName="MyNamespace.MyClass.MyMethod" />
</Methods>
</IgnoreSet>
</IgnoreSets>
@ -56,4 +56,4 @@ Here's the format:
The `baseVersion` attribute denotes the version for which the Ignore Set has been authored. This enables for the automatic discarding of existing sets when a new package version is published in nuget.org.
The `fullname` of members should be the exact string provided in the markdown file when a difference is identified.
The `fullname` of members should be the exact string provided in the markdown file when a difference is identified.

Просмотреть файл

@ -81,5 +81,22 @@ namespace Uno.PackageDiff.Tests
Assert.AreEqual("System.Void Uno.PackageDiff.Tests.Sources.When_Target_Internal::set_MyProperty(System.Int32)", r.InvalidMethods.ElementAt(1).ToString());
Assert.AreEqual("System.Void Uno.PackageDiff.Tests.Sources.When_Target_Internal::MyMethod()", r.InvalidMethods.ElementAt(2).ToString());
}
[TestMethod]
public void When_Target_Method_ChangedReturnType()
{
var context = _builder.BuildAssemblies();
var r = AssemblyComparer.CompareTypes(context.BaseAssembly, context.TargetAssembly);
Assert.AreEqual(0, r.InvalidTypes.Length);
Assert.AreEqual(0, r.InvalidEvents.Length);
Assert.AreEqual(0, r.InvalidFields.Length);
Assert.AreEqual(1, r.InvalidMethods.Length);
Assert.AreEqual(0, r.InvalidProperties.Length);
Assert.AreEqual("TestMethod", r.InvalidMethods.ElementAt(0).Name);
Assert.AreEqual("System.Threading.Tasks.Task Uno.PackageDiff.Tests.Sources.When_Target_Method_ChangedReturnType::TestMethod()", r.InvalidMethods.ElementAt(0).ToString());
}
}
}

Просмотреть файл

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace Uno.PackageDiff.Tests.Sources
{
public class When_Target_Method_ChangedReturnType
{
public void VoidMethod() { }
public int IntMethod() => 0;
public async Task TestMethod() { }
}
}

Просмотреть файл

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace Uno.PackageDiff.Tests.Sources
{
public class When_Target_Method_ChangedReturnType
{
public void VoidMethod() { }
public int IntMethod() => 0;
public async Task<bool> TestMethod() { return false; }
}
}

Просмотреть файл

@ -73,6 +73,7 @@ namespace Uno.PackageDiff
where !type.sourceType.Methods
.Any(sourceMethod =>
sourceMethod.Name == targetMethod.Name
&& targetMethod.ReturnType.FullName == sourceMethod.ReturnType.FullName
&& targetMethodParams.SequenceEqual(getMethodParamsSignature(sourceMethod))
&& IsVisibleMethod(sourceMethod)
&& targetMethod.IsVirtual == sourceMethod.IsVirtual)