Skip to content

Commit

Permalink
add test for reported bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianSauer committed Jan 30, 2024
1 parent e333949 commit af90e62
Show file tree
Hide file tree
Showing 3 changed files with 1,371 additions and 1,303 deletions.
1 change: 1 addition & 0 deletions AutomaticInterface/AutomaticInterface.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=inheritdoc/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ttype/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Usings/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=usings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
60 changes: 31 additions & 29 deletions AutomaticInterface/AutomaticInterface/Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,38 +55,40 @@ InterfaceBuilder codeGenerator
.ToList()
.ForEach(method =>
{
var returnType = method.ReturnType;
var name = method.Name;
var hasNullableParameter = method.Parameters.Any(x =>
x.NullableAnnotation == NullableAnnotation.Annotated
);
var hasNullableReturn =
method.ReturnType.NullableAnnotation == NullableAnnotation.Annotated;
if (hasNullableParameter || hasNullableReturn)
{
codeGenerator.HasNullable = true;
}
var paramResult = new HashSet<string>();
method
.Parameters.Select(GetMethodSignature)
.ToList()
.ForEach(x => paramResult.Add(x));
var typedArgs = method
.TypeParameters.Select(arg => (arg.ToDisplayString(), arg.GetWhereStatement()))
.ToList();
codeGenerator.AddMethodToInterface(
name,
returnType.ToDisplayString(),
InheritDoc,
paramResult,
typedArgs
);
AddMethod(codeGenerator, method);
});
}

private static void AddMethod(InterfaceBuilder codeGenerator, IMethodSymbol method)
{
var returnType = method.ReturnType;
var name = method.Name;

var hasNullableParameter = method.Parameters.Any(x =>
x.NullableAnnotation == NullableAnnotation.Annotated
);
var hasNullableReturn =
method.ReturnType.NullableAnnotation == NullableAnnotation.Annotated;
if (hasNullableParameter || hasNullableReturn)
{
codeGenerator.HasNullable = true;
}

var paramResult = new HashSet<string>();
method.Parameters.Select(GetMethodSignature).ToList().ForEach(x => paramResult.Add(x));

var typedArgs = method
.TypeParameters.Select(arg => (arg.ToDisplayString(), arg.GetWhereStatement()))
.ToList();
codeGenerator.AddMethodToInterface(
name,
returnType.ToDisplayString(),
InheritDoc,
paramResult,
typedArgs
);
}

private static void AddEventsToInterface(
ITypeSymbol classSymbol,
InterfaceBuilder codeGenerator
Expand Down
Loading

0 comments on commit af90e62

Please sign in to comment.