Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authoring Support: Add WinRT Diagnostics #615

Merged
merged 57 commits into from
Dec 30, 2020
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
00287ad
think i have it blocking winmds
j0shuams Oct 30, 2020
6f2bfbf
working diagnostic test app, blocking winmd generator via return as g…
j0shuams Nov 2, 2020
0e6538e
trying the generic interfacen ow
j0shuams Nov 3, 2020
a79e6f9
Merge branch 'master' into jlarkin/adding-diagnostics
j0shuams Nov 4, 2020
b95eb82
updating starter log message
j0shuams Nov 4, 2020
e09ba9d
raising diagnostics for all async interfaces
j0shuams Nov 4, 2020
52d66bd
add diagnostic for multiple constructors of same arity
j0shuams Nov 5, 2020
b71cb02
refactor rules used when reporting diagnostics
j0shuams Nov 5, 2020
69995d1
printing details in diagnostic rule such as erroneous class name
j0shuams Nov 5, 2020
e6d6a36
diagnostic for method parameter literally named value
j0shuams Nov 5, 2020
0d0f1c3
fix return value name
j0shuams Nov 12, 2020
9eba047
Merge branch 'master' into jlarkin/adding-diagnostics
j0shuams Nov 12, 2020
ff313a6
starting struct scenario tests
j0shuams Nov 13, 2020
61ca90a
adding structure fields diagnostic - temp
j0shuams Nov 16, 2020
9550bf2
adding struct field diagnostic 90percent
j0shuams Nov 16, 2020
398b27e
Merge branch 'master' into jlarkin/adding-diagnostics
j0shuams Nov 18, 2020
329580f
Merge branch 'master' into jlarkin/adding-diagnostics
j0shuams Nov 20, 2020
ec4e4b4
Merge branch 'jlarkin/adding-diagnostics' of https://github.com/micro…
j0shuams Nov 20, 2020
2e4f0c0
restructure diagnostics into separate file, context passed by ref so …
j0shuams Nov 20, 2020
723a560
full diagnostics for struct fields
j0shuams Nov 20, 2020
0ea8885
adding operator overload diagnostic and method overload, the latter n…
j0shuams Nov 21, 2020
4c37084
tinkering still
j0shuams Nov 21, 2020
0430734
finished work on checking overloaded methods
j0shuams Nov 23, 2020
0bf786a
moving to multiple test files
j0shuams Nov 24, 2020
4f337f8
adding more array signature tests, fixing up other tests
j0shuams Nov 24, 2020
834d96b
update tests for array method signature; add diagnostics for return t…
j0shuams Nov 25, 2020
2930117
Merge branch 'master' into jlarkin/adding-diagnostics
j0shuams Nov 25, 2020
35a7e01
only looking at public methods, starting on param checking
j0shuams Nov 25, 2020
461ec53
fix bug in sln file
j0shuams Nov 30, 2020
115b28b
checking array types in signatures
j0shuams Nov 30, 2020
94fda2c
raising all diagnostics for array signatures
j0shuams Dec 1, 2020
89cdd83
cleanup before PR
j0shuams Dec 1, 2020
85d7262
more cleanup
j0shuams Dec 1, 2020
8323ed2
Merge branch 'master' into jlarkin/adding-diagnostics
j0shuams Dec 1, 2020
f283c95
Merge branch 'master' into jlarkin/adding-diagnostics
j0shuams Dec 1, 2020
929e94e
Merge branch 'master' into jlarkin/adding-diagnostics
j0shuams Dec 2, 2020
bcb00bc
Add array param diagnostics (#624)
j0shuams Dec 8, 2020
a620cb0
Merge branch 'master' into jlarkin/adding-diagnostics
j0shuams Dec 8, 2020
622b87b
Merge branch 'master' into jlarkin/adding-diagnostics
j0shuams Dec 9, 2020
ea9bfc5
midway through changing unittests
j0shuams Dec 15, 2020
6a39c77
Merge branch 'master' into jlarkin/adding-diagnostics
j0shuams Dec 15, 2020
42e8b87
finish unittest migration
j0shuams Dec 15, 2020
37316ae
all unit tests passing
j0shuams Dec 15, 2020
d2fc46e
PR feedback 1 of 2
j0shuams Dec 15, 2020
33fff32
remove old test project
j0shuams Dec 15, 2020
6a5b4df
working on new class name issue for struct fields
j0shuams Dec 15, 2020
1b1ecb0
Address feedback + missing some tests (#641)
j0shuams Dec 17, 2020
67f7784
Merge branch 'jlarkin/adding-diagnostics' of https://github.com/micro…
j0shuams Dec 17, 2020
564bbbf
cleanup data
j0shuams Dec 17, 2020
c41b59b
Merge branch 'master' into jlarkin/adding-diagnostics
j0shuams Dec 17, 2020
8231eb6
remove workarounds
j0shuams Dec 17, 2020
b6f3fac
clean the diagnostic rules
j0shuams Dec 17, 2020
90017eb
Merge branch 'master' into jlarkin/adding-diagnostics
j0shuams Dec 17, 2020
0f6f61a
Merge branch 'master' into jlarkin/adding-diagnostics
j0shuams Dec 23, 2020
70ec2bc
Add final diagnostics, refactoring (#643)
j0shuams Dec 30, 2020
0c8d754
uncomment cswinrt component
j0shuams Dec 30, 2020
d91f1f5
cruft
j0shuams Dec 30, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions src/Authoring/TestDiagnostics/ArrayParameterTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
using System.Runtime.InteropServices;

namespace TestDiagnostics
{
/* TODO:
* what happens if you put another random attribute on an array param?
* check in WRC3 project ...
*/
public class ReadOnlyArray : System.Attribute
j0shuams marked this conversation as resolved.
Show resolved Hide resolved
{
public ReadOnlyArray() { }
}

public class WriteOnlyArray : System.Attribute
{
public WriteOnlyArray() { }
}

/*
public interface IHaveAMethodNamedArray_Valid
j0shuams marked this conversation as resolved.
Show resolved Hide resolved
{
void Array(int i);
int[] Foo(out int[] arr);
}

public sealed class OutParam_Valid
{
public void Foo(out int[] arr) { arr = new int[] { }; }
}

// method with `ref` param
public sealed class OnlyParam
{
// array param with both attributes
public void BothAttributes_Separate([WriteOnlyArray()][ReadOnlyArray()] int[] arr) { }

public void BothAttributes_Together([WriteOnlyArray(), ReadOnlyArray()] int[] arr) { }

// array marked `out` but marked with ReadOnlyArray Attribute
public void MarkedOutAndReadOnly([ReadOnlyArray()] out int[] arr) { arr = new int[] { }; }
public void MarkedReadOnly_Valid([ReadOnlyArray()] int[] arr) { }

// Valid WriteOnlyArray Tests
public void MarkedWriteOnly_Valid([WriteOnlyArray()] int[] arr) { }
public void MarkedOutAndWriteOnly_Valid([WriteOnlyArray()] out int[] arr) { arr = new int[] { }; }
public void MarkedOutOnly_Valid(out int[] arr) { arr = new int[] { }; }

// param is array, and marked either InAttribute or OutAttribute
// must have ReadOnlyArray or WriteOnlyArray
public void ArrayMarkedIn([In] int[] arr) { }
public void ArrayMarkedOut([Out] int[] arr) { }

// method has param marked with ReadOnlyArray / WriteOnlyArray
// but param isnt array
public void NonArrayMarkedReadOnly([ReadOnlyArray()] int arr) { }
public void NonArrayMarkedWriteOnly([WriteOnlyArray()] int arr) { }

// param marked InAttribute or OutAttribute , disallowed in total
public void ParamMarkedIn([In] int arr) { }
public void ParamMarkedOut([Out] int arr) { }

// array as param but not marked either way
public void ArrayNotMarked(int[] arr) { }

public void ArrayNotMarked_Valid(out int[] arr) { arr = new int[] { }; }
}

public sealed class TwoParam
{
public void BothAttributes(int i, [WriteOnlyArray()][ReadOnlyArray()] int[] arr) { }
// array marked `out` but marked with ReadOnlyArray Attribute
public void MarkedOutAndReadOnly(int i, [ReadOnlyArray()] out int[] arr) { arr = new int[] { }; }
public void MarkedReadOnly_Valid(int i, [ReadOnlyArray()] int[] arr) { }

// Valid WriteOnlyArray Tests
public void MarkedWriteOnly_Valid(int i, [WriteOnlyArray()] int[] arr) { }
public void MarkedOutAndWriteOnly_Valid(int i, [WriteOnlyArray()] out int[] arr) { arr = new int[] { }; }
public void MarkedOut_Valid(int i, out int[] arr) { arr = new int[] { }; }

// param is array, and marked either InAttribute or OutAttribute
// must have ReadOnlyArray or WriteOnlyArray
public void ArrayMarkedIn(int i, [In] int[] arr) { }
public void ArrayMarkedOut(int i, [Out] int[] arr) { }

// method has param marked with ReadOnlyArray / WriteOnlyArray
// but param isnt array
public void NonArrayMarkedReadOnly(int i, [ReadOnlyArray()] int arr) { }
public void NonArrayMarkedWriteOnly(int i, [WriteOnlyArray()] int arr) { }

// param marked InAttribute or OutAttribute , disallowed in total
public void ParamMarkedIn(int i, [In] int arr) { } // hey!
public void ParamMarkedOut(int i, [Out] int arr) { }

// array as param but not marked either way
public void ArrayNotMarked(int i, int[] arr) { }
}

public sealed class TwoArrays
{
public void OneValidOneInvalid_1([WriteOnlyArray] int[] xs, [WriteOnlyArray()][ReadOnlyArray()] int[] ys) { }
public void OneValidOneInvalid_2([WriteOnlyArray][ReadOnlyArray()] int[] xs, [WriteOnlyArray()] int[] ys) { }

// array marked `out` but marked with ReadOnlyArray Attribute
public void MarkedOutAndReadOnly([ReadOnlyArray()] int[] xs, [ReadOnlyArray()] out int[] arr) { arr = new int[] { }; }
public void MarkedReadOnly_Valid([ReadOnlyArray()] int[] xs, [ReadOnlyArray()] int[] arr) { }

// Valid WriteOnlyArray Tests
public void MarkedWriteOnly_Valid([ReadOnlyArray()] int[] xs, [WriteOnlyArray()] int[] arr) { }
public void MarkedOutAndWriteOnly_Valid([ReadOnlyArray()] int[] xs, [WriteOnlyArray()] out int[] arr) { arr = new int[] { }; }
public void MarkedOut_Valid([WriteOnlyArray()] int[] xs, out int[] arr) { arr = new int[] { }; }

// param is array, and marked either InAttribute or OutAttribute
// must have ReadOnlyArray or WriteOnlyArray
public void ArrayMarkedIn(int i, [In] int[] arr) { }
public void ArrayMarkedIn2([ReadOnlyArray()] int[] xs, [In] int[] arr) { }
public void ArrayMarkedOut([ReadOnlyArray()] int[] xs, [Out] int[] arr) { }

// method has param marked with ReadOnlyArray / WriteOnlyArray but param isnt array
public void NonArrayMarkedReadOnly([ReadOnlyArray()] int[] xs, [ReadOnlyArray()] int i) { }
public void NonArrayMarkedWriteOnly([ReadOnlyArray()] int[] xs, [WriteOnlyArray()] int i) { }
public void NonArrayMarkedWriteOnly2([ReadOnlyArray()] int i, [WriteOnlyArray()] int[] arr) { }

// param marked InAttribute or OutAttribute , disallowed in total
public void ParamMarkedIn([ReadOnlyArray()] int[] xs, [In] int arr) { }
public void ParamMarkedOut([ReadOnlyArray()] int[] xs, [Out] int arr) { }
public void ParamMarkedOut2([Out] int arr, [ReadOnlyArray()] int[] xs) { }

// array as param but not marked either way
public void ArrayNotMarked([ReadOnlyArray()] int[] xs, int[] arr) { }
}
*/
}
127 changes: 127 additions & 0 deletions src/Authoring/TestDiagnostics/AsyncInterfaceTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Foundation;

namespace TestDiagnostics
{
/*
public sealed class AsyAction : IAsyncAction, IAsyncActionWithProgress<int>
{
public AsyncActionCompletedHandler Completed { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

public Exception ErrorCode => throw new NotImplementedException();

public uint Id => throw new NotImplementedException();

public AsyncStatus Status => throw new NotImplementedException();

AsyncActionProgressHandler<int> IAsyncActionWithProgress<int>.Progress { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
AsyncActionWithProgressCompletedHandler<int> IAsyncActionWithProgress<int>.Completed { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

Exception IAsyncInfo.ErrorCode => throw new NotImplementedException();

uint IAsyncInfo.Id => throw new NotImplementedException();

AsyncStatus IAsyncInfo.Status => throw new NotImplementedException();

public void Cancel()
{
throw new NotImplementedException();
}

public void Close()
{
throw new NotImplementedException();
}

public void GetResults()
{
throw new NotImplementedException();
}

}

public class ActionWithProgress : IAsyncActionWithProgress<int>
{
AsyncActionProgressHandler<int> IAsyncActionWithProgress<int>.Progress { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
AsyncActionWithProgressCompletedHandler<int> IAsyncActionWithProgress<int>.Completed { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

Exception IAsyncInfo.ErrorCode => throw new NotImplementedException();

uint IAsyncInfo.Id => throw new NotImplementedException();

AsyncStatus IAsyncInfo.Status => throw new NotImplementedException();

void IAsyncInfo.Cancel()
{
throw new NotImplementedException();
}

void IAsyncInfo.Close()
{
throw new NotImplementedException();
}

void IAsyncActionWithProgress<int>.GetResults()
{
throw new NotImplementedException();
}
}

public sealed class OpWithProgress : IAsyncOperationWithProgress<int, bool>
{
AsyncOperationProgressHandler<int, bool> IAsyncOperationWithProgress<int, bool>.Progress { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
AsyncOperationWithProgressCompletedHandler<int, bool> IAsyncOperationWithProgress<int, bool>.Completed { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

Exception IAsyncInfo.ErrorCode => throw new NotImplementedException();

uint IAsyncInfo.Id => throw new NotImplementedException();

AsyncStatus IAsyncInfo.Status => throw new NotImplementedException();

void IAsyncInfo.Cancel()
{
throw new NotImplementedException();
}

void IAsyncInfo.Close()
{
throw new NotImplementedException();
}

int IAsyncOperationWithProgress<int, bool>.GetResults()
{
throw new NotImplementedException();
}
}

public sealed class Op : IAsyncOperation<int>
{
AsyncOperationCompletedHandler<int> IAsyncOperation<int>.Completed { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

Exception IAsyncInfo.ErrorCode => throw new NotImplementedException();

uint IAsyncInfo.Id => throw new NotImplementedException();

AsyncStatus IAsyncInfo.Status => throw new NotImplementedException();

void IAsyncInfo.Cancel()
{
throw new NotImplementedException();
}

void IAsyncInfo.Close()
{
throw new NotImplementedException();
}

int IAsyncOperation<int>.GetResults()
{
throw new NotImplementedException();
}
}
*/
}
9 changes: 9 additions & 0 deletions src/Authoring/TestDiagnostics/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >

<PropertyGroup>
<SimulateCsWinRTNugetReference>true</SimulateCsWinRTNugetReference>
</PropertyGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

</Project>
9 changes: 9 additions & 0 deletions src/Authoring/TestDiagnostics/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<Target Name="CopyWinMD" AfterTargets="AfterBuild">
<Copy SourceFiles="$(GeneratedFilesDir)$(AssemblyName).winmd" DestinationFolder="$(OutputPath)" />
</Target>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />

</Project>
Loading