Skip to content
This repository has been archived by the owner on Jan 16, 2022. It is now read-only.

Commit

Permalink
Improve converting plural to singular form for lambda parameter name
Browse files Browse the repository at this point in the history
  • Loading branch information
cezarypiatek committed Sep 20, 2018
1 parent 6bc83f3 commit 5ea8c60
Show file tree
Hide file tree
Showing 13 changed files with 603 additions and 39 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,28 @@
<data name="_011_IdentityFunctionMappingForCollection_FIXED" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>TestCaseData\011_IdentityFunctionMappingForCollection_FIXED.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="_012_CollectionMappingWithSingularLambdaParameterName" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>TestCaseData\012_CollectionMappingWithSingularLambdaParameterName.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="_012_CollectionMappingWithSingularLambdaParameterName_FIXED" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>TestCaseData\012_CollectionMappingWithSingularLambdaParameterName_FIXED.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="_013_CollectionMappingWithPrefixedLambdaParameterName" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>TestCaseData\013_CollectionMappingWithPrefixedLambdaParameterName.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="_013_CollectionMappingWithPrefixedLambdaParameterName_FIXED_" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>TestCaseData\013_CollectionMappingWithPrefixedLambdaParameterName_FIXED..txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="_014_CollectionMappingWithGenericName" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>TestCaseData\014_CollectionMappingWithGenericName.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="_014_CollectionMappingWithGenericName_FIXED" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>TestCaseData\014_CollectionMappingWithGenericName_FIXED.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="_015_CollectionMappingWithPostfixGenericName" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>TestCaseData\015_CollectionMappingWithPostfixGenericName.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="_015_CollectionMappingWithPostfixGenericName_FIXED" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>TestCaseData\015_CollectionMappingWithPostfixGenericName_FIXED.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,33 @@ public void should_be_able_to_generate_identity_mapping_function_for_collections
TestCodeRefactoring(_011_IdentityFunctionMappingForCollection, _011_IdentityFunctionMappingForCollection_FIXED);
}

[Test]
public void should_be_able_to_generate_collection_mapping_with_lambda_parameter_name_in_singular_form()
{
TestCodeRefactoring(_012_CollectionMappingWithSingularLambdaParameterName, _012_CollectionMappingWithSingularLambdaParameterName_FIXED);
}


[Test]
public void should_be_able_to_generate_collection_mapping_with_lambda_parameter_name_with_variable_name_as_prefix()
{
TestCodeRefactoring(_013_CollectionMappingWithPrefixedLambdaParameterName, _013_CollectionMappingWithPrefixedLambdaParameterName_FIXED_);
}


[Test]
public void should_be_able_to_generate_collection_mapping_with_lambda_parameter_from_generic_name()
{
TestCodeRefactoring(_014_CollectionMappingWithGenericName, _014_CollectionMappingWithGenericName_FIXED);
}


[Test]
public void should_be_able_to_generate_collection_mapping_with_lambda_parameter_from_postfiex_generic_name()
{
TestCodeRefactoring(_015_CollectionMappingWithPostfixGenericName, _015_CollectionMappingWithPostfixGenericName_FIXED);
}

protected override string LanguageName => LanguageNames.CSharp;

protected override CodeRefactoringProvider CreateProvider()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace TestAutoMapper.Identity.X
{
public class XX
{
public int Id { get; set; }
public string Name { get; set; }
}

public class YY
{
public int Id { get; set; }
public string Name { get; set; }
}

public static class Mapper{

public static List<YY> [|Map|](List<XX> categories)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace TestAutoMapper.Identity.X
{
public class XX
{
public int Id { get; set; }
public string Name { get; set; }
}

public class YY
{
public int Id { get; set; }
public string Name { get; set; }
}

public static class Mapper{

public static List<YY> Map(List<XX> categories)
{
return categories.Select(category => new YY()
{
Id = category.Id,
Name = category.Name
}).ToList();
}
}
}
Loading

0 comments on commit 5ea8c60

Please sign in to comment.