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 clean: all
pool: pool:
name: Default vmImage: 'ubuntu-18.04'
demands:
- agent.os -equals Linux
variables: variables:
NUGET_PACKAGES: $(Agent.WorkFolder)/.nuget NUGET_PACKAGES: $(Agent.WorkFolder)/.nuget

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

@ -7,7 +7,7 @@ published nuget package (in nuget.org) and a local NuGet package.
## Installing ## 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 dotnet tool install --global Uno.PackageDiff
@ -32,22 +32,22 @@ Here's the format:
<IgnoreSets> <IgnoreSets>
<IgnoreSet baseVersion="1.0.0"> <IgnoreSet baseVersion="1.0.0">
<Types> <Types>
<Member fullName="MyNamespace.MyMissingClass"/> <Member fullName="MyNamespace.MyMissingClass" />
</Types> </Types>
<Properties> <Properties>
<Member fullName="MyNamespace.MyClass.MyProperty"/> <Member fullName="MyNamespace.MyClass.MyProperty" />
</Properties> </Properties>
<Fields> <Fields>
<Member fullName="MyNamespace.MyClass.myField"/> <Member fullName="MyNamespace.MyClass.myField" />
</Fields> </Fields>
<Events> <Events>
<Member fullName="MyNamespace.MyClass.MyEvent"/> <Member fullName="MyNamespace.MyClass.MyEvent" />
</Events> </Events>
<Methods> <Methods>
<Member fullName="MyNamespace.MyClass.MyMethod"/> <Member fullName="MyNamespace.MyClass.MyMethod" />
</Methods> </Methods>
<Methods> <Methods>
<Member fullName="MyNamespace.MyClass.MyMethod"/> <Member fullName="MyNamespace.MyClass.MyMethod" />
</Methods> </Methods>
</IgnoreSet> </IgnoreSet>
</IgnoreSets> </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 `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::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()); 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 where !type.sourceType.Methods
.Any(sourceMethod => .Any(sourceMethod =>
sourceMethod.Name == targetMethod.Name sourceMethod.Name == targetMethod.Name
&& targetMethod.ReturnType.FullName == sourceMethod.ReturnType.FullName
&& targetMethodParams.SequenceEqual(getMethodParamsSignature(sourceMethod)) && targetMethodParams.SequenceEqual(getMethodParamsSignature(sourceMethod))
&& IsVisibleMethod(sourceMethod) && IsVisibleMethod(sourceMethod)
&& targetMethod.IsVirtual == sourceMethod.IsVirtual) && targetMethod.IsVirtual == sourceMethod.IsVirtual)