-
Notifications
You must be signed in to change notification settings - Fork 29
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
Include operators in api generation #49
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using PublicApiGeneratorTests.Examples; | ||
using Xunit; | ||
|
||
namespace PublicApiGeneratorTests | ||
{ | ||
public class Operator_order : ApiGeneratorTestsBase | ||
{ | ||
[Fact] | ||
public void Should_show_custom_operators() | ||
{ | ||
AssertPublicApi<ClassWithUnaryOperators>( | ||
@"namespace PublicApiGeneratorTests.Examples | ||
{ | ||
public class ClassWithUnaryOperators | ||
{ | ||
public ClassWithUnaryOperators() { } | ||
public static PublicApiGeneratorTests.Examples.ClassWithUnaryOperators op_Addition(PublicApiGeneratorTests.Examples.ClassWithUnaryOperators first, PublicApiGeneratorTests.Examples.ClassWithUnaryOperators second) { } | ||
public static PublicApiGeneratorTests.Examples.ClassWithUnaryOperators op_Decrement(PublicApiGeneratorTests.Examples.ClassWithUnaryOperators first) { } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to have a translation table that translates comnon well known ops into the corresponding operator code? Would be a bit more readable in the output I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. I looked into why the full type name was being generated but, likely due to operators being static, it appears they are seen as "unnested" types which causes the Handling the operators in a more special manner would definitely allow me to more cleanly format them (since the problematic area only knows the
Or are you looking to further condense the signature? |
||
public static PublicApiGeneratorTests.Examples.ClassWithUnaryOperators op_Division(PublicApiGeneratorTests.Examples.ClassWithUnaryOperators first, PublicApiGeneratorTests.Examples.ClassWithUnaryOperators second) { } | ||
public static bool op_False(PublicApiGeneratorTests.Examples.ClassWithUnaryOperators first) { } | ||
public static PublicApiGeneratorTests.Examples.ClassWithUnaryOperators op_Increment(PublicApiGeneratorTests.Examples.ClassWithUnaryOperators first) { } | ||
public static PublicApiGeneratorTests.Examples.ClassWithUnaryOperators op_LogicalNot(PublicApiGeneratorTests.Examples.ClassWithUnaryOperators first) { } | ||
public static PublicApiGeneratorTests.Examples.ClassWithUnaryOperators op_Multiply(PublicApiGeneratorTests.Examples.ClassWithUnaryOperators first, PublicApiGeneratorTests.Examples.ClassWithUnaryOperators second) { } | ||
public static PublicApiGeneratorTests.Examples.ClassWithUnaryOperators op_OnesComplement(PublicApiGeneratorTests.Examples.ClassWithUnaryOperators first) { } | ||
public static PublicApiGeneratorTests.Examples.ClassWithUnaryOperators op_Subtraction(PublicApiGeneratorTests.Examples.ClassWithUnaryOperators first, PublicApiGeneratorTests.Examples.ClassWithUnaryOperators second) { } | ||
public static bool op_True(PublicApiGeneratorTests.Examples.ClassWithUnaryOperators first) { } | ||
} | ||
}"); | ||
} | ||
} | ||
|
||
namespace Examples | ||
{ | ||
public class ClassWithUnaryOperators | ||
{ | ||
public static ClassWithUnaryOperators operator +(ClassWithUnaryOperators first, ClassWithUnaryOperators second) => second; | ||
public static ClassWithUnaryOperators operator -(ClassWithUnaryOperators first, ClassWithUnaryOperators second) => second; | ||
public static ClassWithUnaryOperators operator /(ClassWithUnaryOperators first, ClassWithUnaryOperators second) => second; | ||
public static ClassWithUnaryOperators operator *(ClassWithUnaryOperators first, ClassWithUnaryOperators second) => second; | ||
public static ClassWithUnaryOperators operator !(ClassWithUnaryOperators first) => first; | ||
public static ClassWithUnaryOperators operator ~(ClassWithUnaryOperators first) => first; | ||
public static ClassWithUnaryOperators operator ++(ClassWithUnaryOperators first) => first; | ||
public static ClassWithUnaryOperators operator --(ClassWithUnaryOperators first) => first; | ||
public static bool operator true(ClassWithUnaryOperators first) => true; | ||
public static bool operator false(ClassWithUnaryOperators first) => false; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using PublicApiGeneratorTests.Examples; | ||
using Xunit; | ||
|
||
namespace PublicApiGeneratorTests | ||
{ | ||
public class Operator_visibility : ApiGeneratorTestsBase | ||
{ | ||
[Fact] | ||
public void Should_show_custom_operators() | ||
{ | ||
AssertPublicApi<ClassWithOperator>( | ||
@"namespace PublicApiGeneratorTests.Examples | ||
{ | ||
public class ClassWithOperator | ||
{ | ||
public ClassWithOperator() { } | ||
public static PublicApiGeneratorTests.Examples.ClassWithOperator op_Addition(PublicApiGeneratorTests.Examples.ClassWithOperator first, PublicApiGeneratorTests.Examples.ClassWithOperator second) { } | ||
} | ||
}"); | ||
} | ||
} | ||
|
||
namespace Examples | ||
{ | ||
public class ClassWithOperator | ||
{ | ||
public static ClassWithOperator operator +(ClassWithOperator first, ClassWithOperator second) => second; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we inline this so that it is only evaluated with IsSpecialName?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely.