Permalink
Browse files

update libraries to 4.5; change framework to 4.5; fix resharper 8 issues

  • Loading branch information...
1 parent 4fd7160 commit d21ce0d3909a05c6c5c3ce9aa3b2bd67a549cb10 @handcraftsman handcraftsman committed Aug 13, 2013
View
20 RakeFile
@@ -1,7 +1,7 @@
require 'albacore'
PRODUCT_NAME = "LinqToHtml"
-CLR_TOOLS_VERSION = "v3.5"
+CLR_TOOLS_VERSION = "v4.0"
DEFAULT_BUILD_NUMBER = "1.0.0"
COMPANY_NAME = "MVBA, P.C."
COPYRIGHT = "MVBA, P.C. (c) 2009-2013"
@@ -62,8 +62,24 @@ assemblyinfo :assemblyinfo do |asm|
asm.output_file = "src/CommonAssemblyInfo.cs"
end
+desc "Add Resharper escapes to CommonAssemblyInfo.cs file"
+task :resharperAssemblyInfo do
+ puts
+ puts "adding Resharper escapes to src/CommonAssemblyInfo.cs"
+ puts
+
+ File.open('src/CommonAssemblyInfo.cs', 'r+') do |f|
+ contents = f.read
+ f.rewind
+
+ f.puts "// ReSharper disable RedundantUsingDirective"
+ f.puts contents
+ f.puts "// ReSharper enable RedundantUsingDirective"
+ end
+end
+
desc "Builds the #{PRODUCT_NAME} solution"
-msbuild :build => [:clean, :assemblyinfo] do |msb|
+msbuild :build => [:clean, :assemblyinfo, :resharperAssemblyInfo] do |msb|
puts "Compiling #{PRODUCT_NAME} in #{settings[:compile_target]} mode..."
msb.properties :configuration => settings[:compile_target]
msb.targets :Clean, :Build
View
BIN lib/FluentAssert/FluentAssert.dll
Binary file not shown.
View
BIN lib/FluentAssert/FluentAssert.pdb
Binary file not shown.
View
434 src/LinqToHtml.Tests/HTMLDocumentTests.cs
@@ -7,201 +7,204 @@
namespace LinqToHtml.Tests
{
- public class HTMLDocumentTests
- {
- public class Person
- {
- public int Age { get; set; }
- public char Gender { get; set; }
- public string Given { get; set; }
- public string Surname { get; set; }
-
- public override string ToString()
- {
- return Given + " " + Surname + " Age: " + Age + " Gender: " + Gender;
- }
- }
-
- [TestFixture]
- public class When_asked_for_its_descendant_tags
- {
- private int _expectedTagCount;
- private string _html;
- private List<HTMLTag> _result;
-
- [Test]
- public void Given_a_basic_html_document()
- {
- Test.Verify(
- with_a_basic_html_document,
- when_asked_for_its_descendant_tags,
- should_not_return_null,
- should_not_return_an_empty_list,
- should_return_the_correct_number_of_tags,
- should_return_the_head_tag,
- should_return_the_title_tag,
- should_return_the_body_tag
- );
- }
-
- private void should_not_return_an_empty_list()
- {
- _result.Count.ShouldNotBeEqualTo(0);
- }
-
- private void should_not_return_null()
- {
- _result.ShouldNotBeNull();
- }
-
- private void should_return_the_body_tag()
- {
- _result.Single(x => x.Type == "body");
- }
-
- private void should_return_the_correct_number_of_tags()
- {
- _result.Count.ShouldBeEqualTo(_expectedTagCount);
- }
-
- private void should_return_the_head_tag()
- {
- _result.Single(x => x.Type == "head");
- }
-
- private void should_return_the_title_tag()
- {
- _result.Single(x => x.Type == "title");
- }
-
- private void when_asked_for_its_descendant_tags()
- {
- _result = HTMLParser.Parse(_html)
- .DescendantTags.ToList();
- }
-
- private void with_a_basic_html_document()
- {
- _html = "<html><head><title>The Title</title></head><body>Hello World</body></html>";
- _expectedTagCount = 3; // head, title, body
- }
- }
-
- [TestFixture]
- public class When_asked_for_the_BODY_tag
- {
- private string _html;
- private HTMLTag _result;
-
- [Test]
- public void Given_an_html_document_that_has_a_child_BODY_tag()
- {
- Test.Verify(
- with_a_document_that_has_a_child_BODY_tag,
- when_asked_for_the_BODY_tag,
- should_not_return_null,
- should_return_the_BODY_tag
- );
- }
-
- [Test]
- public void Given_only_a_BODY_tag()
- {
- Test.Verify(
- with_only_a_BODY_tag,
- when_asked_for_the_BODY_tag,
- should_not_return_null,
- should_return_the_BODY_tag
- );
- }
-
- private void should_not_return_null()
- {
- _result.ShouldNotBeNull();
- }
-
- private void should_return_the_BODY_tag()
- {
- _result.TypeEqualsIgnoreCase("BODY").ShouldBeTrue();
- }
-
- private void when_asked_for_the_BODY_tag()
- {
- _result = HTMLParser.Parse(_html).Body;
- }
-
- private void with_a_document_that_has_a_child_BODY_tag()
- {
- _html = "<html><body></body></html>";
- }
-
- private void with_only_a_BODY_tag()
- {
- _html = "<body></body>";
- }
- }
-
- [TestFixture]
- public class When_asked_for_the_HEAD_tag
- {
- private string _html;
- private HTMLTag _result;
-
- [Test]
- public void Given_an_html_document_that_has_a_child_HEAD_tag()
- {
- Test.Verify(
- with_a_document_that_has_a_child_HEAD_tag,
- when_asked_for_the_HEAD_tag,
- should_not_return_null,
- should_return_the_HEAD_tag
- );
- }
-
- [Test]
- public void Given_only_a_HEAD_tag()
- {
- Test.Verify(
- with_only_a_HEAD_tag,
- when_asked_for_the_HEAD_tag,
- should_not_return_null,
- should_return_the_HEAD_tag
- );
- }
-
- private void should_not_return_null()
- {
- _result.ShouldNotBeNull();
- }
-
- private void should_return_the_HEAD_tag()
- {
- _result.TypeEqualsIgnoreCase("HEAD").ShouldBeTrue();
- }
-
- private void when_asked_for_the_HEAD_tag()
- {
- _result = HTMLParser.Parse(_html).Head;
- }
-
- private void with_a_document_that_has_a_child_HEAD_tag()
- {
- _html = "<html><head></head></html>";
- }
-
- private void with_only_a_HEAD_tag()
- {
- _html = "<head></head>";
- }
- }
-
- [TestFixture]
- public class When_asked_to_parse_XML
- {
- [Test]
- public void Should_parse_the_content_correctly()
- {
- const string html = @"<?xml version='1.0' encoding='utf-8' ?>
+ public class HTMLDocumentTests
+ {
+ public class Person
+ {
+ public int Age { get; set; }
+ public char Gender { get; set; }
+ public string Given { get; set; }
+ public string Surname { get; set; }
+
+ public override string ToString()
+ {
+ return Given + " " + Surname + " Age: " + Age + " Gender: " + Gender;
+ }
+ }
+
+ [TestFixture]
+ public class When_asked_for_its_descendant_tags
+ {
+ private int _expectedTagCount;
+ private string _html;
+ private List<HTMLTag> _result;
+
+ [Test]
+ public void Given_a_basic_html_document()
+ {
+ Test.Verify(
+ with_a_basic_html_document,
+ when_asked_for_its_descendant_tags,
+ should_not_return_null,
+ should_not_return_an_empty_list,
+ should_return_the_correct_number_of_tags,
+ should_return_the_head_tag,
+ should_return_the_title_tag,
+ should_return_the_body_tag
+ );
+ }
+
+ private void should_not_return_an_empty_list()
+ {
+ _result.Count.ShouldNotBeEqualTo(0);
+ }
+
+ private void should_not_return_null()
+ {
+ _result.ShouldNotBeNull();
+ }
+
+ private void should_return_the_body_tag()
+ {
+// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
+ _result.Single(x => x.Type == "body");
+ }
+
+ private void should_return_the_correct_number_of_tags()
+ {
+ _result.Count.ShouldBeEqualTo(_expectedTagCount);
+ }
+
+ private void should_return_the_head_tag()
+ {
+// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
+ _result.Single(x => x.Type == "head");
+ }
+
+ private void should_return_the_title_tag()
+ {
+// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
+ _result.Single(x => x.Type == "title");
+ }
+
+ private void when_asked_for_its_descendant_tags()
+ {
+ _result = HTMLParser.Parse(_html)
+ .DescendantTags.ToList();
+ }
+
+ private void with_a_basic_html_document()
+ {
+ _html = "<html><head><title>The Title</title></head><body>Hello World</body></html>";
+ _expectedTagCount = 3; // head, title, body
+ }
+ }
+
+ [TestFixture]
+ public class When_asked_for_the_BODY_tag
+ {
+ private string _html;
+ private HTMLTag _result;
+
+ [Test]
+ public void Given_an_html_document_that_has_a_child_BODY_tag()
+ {
+ Test.Verify(
+ with_a_document_that_has_a_child_BODY_tag,
+ when_asked_for_the_BODY_tag,
+ should_not_return_null,
+ should_return_the_BODY_tag
+ );
+ }
+
+ [Test]
+ public void Given_only_a_BODY_tag()
+ {
+ Test.Verify(
+ with_only_a_BODY_tag,
+ when_asked_for_the_BODY_tag,
+ should_not_return_null,
+ should_return_the_BODY_tag
+ );
+ }
+
+ private void should_not_return_null()
+ {
+ _result.ShouldNotBeNull();
+ }
+
+ private void should_return_the_BODY_tag()
+ {
+ _result.TypeEqualsIgnoreCase("BODY").ShouldBeTrue();
+ }
+
+ private void when_asked_for_the_BODY_tag()
+ {
+ _result = HTMLParser.Parse(_html).Body;
+ }
+
+ private void with_a_document_that_has_a_child_BODY_tag()
+ {
+ _html = "<html><body></body></html>";
+ }
+
+ private void with_only_a_BODY_tag()
+ {
+ _html = "<body></body>";
+ }
+ }
+
+ [TestFixture]
+ public class When_asked_for_the_HEAD_tag
+ {
+ private string _html;
+ private HTMLTag _result;
+
+ [Test]
+ public void Given_an_html_document_that_has_a_child_HEAD_tag()
+ {
+ Test.Verify(
+ with_a_document_that_has_a_child_HEAD_tag,
+ when_asked_for_the_HEAD_tag,
+ should_not_return_null,
+ should_return_the_HEAD_tag
+ );
+ }
+
+ [Test]
+ public void Given_only_a_HEAD_tag()
+ {
+ Test.Verify(
+ with_only_a_HEAD_tag,
+ when_asked_for_the_HEAD_tag,
+ should_not_return_null,
+ should_return_the_HEAD_tag
+ );
+ }
+
+ private void should_not_return_null()
+ {
+ _result.ShouldNotBeNull();
+ }
+
+ private void should_return_the_HEAD_tag()
+ {
+ _result.TypeEqualsIgnoreCase("HEAD").ShouldBeTrue();
+ }
+
+ private void when_asked_for_the_HEAD_tag()
+ {
+ _result = HTMLParser.Parse(_html).Head;
+ }
+
+ private void with_a_document_that_has_a_child_HEAD_tag()
+ {
+ _html = "<html><head></head></html>";
+ }
+
+ private void with_only_a_HEAD_tag()
+ {
+ _html = "<head></head>";
+ }
+ }
+
+ [TestFixture]
+ public class When_asked_to_parse_XML
+ {
+ [Test]
+ public void Should_parse_the_content_correctly()
+ {
+ const string html = @"<?xml version='1.0' encoding='utf-8' ?>
<People>
<Person>
<FirstName>Plácido</FirstName>
@@ -223,24 +226,25 @@ public void Should_parse_the_content_correctly()
</Person>
</People>
";
- var doc = HTMLParser.Parse(html);
- var persons = doc
- .OfType("Person")
- .Select(x => new Person
- {
- Given = (string)x["FirstName"],
- Surname = (string)x["LastName"],
- Age = (int)x["Age"],
- Gender = (char)x["Gender"],
- });
-
- persons.Count().ShouldBeEqualTo(3, "found incorrect number of persons");
- var kάλλας = persons.Last();
- kάλλας.Age.ShouldBeEqualTo(53);
- kάλλας.Gender.ShouldBeEqualTo('F');
- kάλλας.Given.ShouldBeEqualTo("Μαρία");
- kάλλας.Surname.ShouldBeEqualTo("Κάλλας");
- }
- }
- }
+ var doc = HTMLParser.Parse(html);
+ var persons = doc
+ .OfType("Person")
+ .Select(x => new Person
+ {
+ Given = (string)x["FirstName"],
+ Surname = (string)x["LastName"],
+ Age = (int)x["Age"],
+ Gender = (char)x["Gender"],
+ })
+ .ToList();
+
+ persons.Count.ShouldBeEqualTo(3, "found incorrect number of persons");
+ var kάλλας = persons.Last();
+ kάλλας.Age.ShouldBeEqualTo(53);
+ kάλλας.Gender.ShouldBeEqualTo('F');
+ kάλλας.Given.ShouldBeEqualTo("Μαρία");
+ kάλλας.Surname.ShouldBeEqualTo("Κάλλας");
+ }
+ }
+ }
}
View
2 src/LinqToHtml.Tests/HTMLTagAttributeTests.cs
@@ -45,6 +45,7 @@ private void with_an_attribute_that_has_a_name()
{
var xmlDocument = new XmlDocument();
xmlDocument.LoadXml("<node datetime='now' />");
+// ReSharper disable once PossibleNullReferenceException
_attribute = xmlDocument.FirstChild.Attributes[0];
_expectedName = "datetime";
}
@@ -87,6 +88,7 @@ private void with_an_attribute_that_has_a_value()
{
var xmlDocument = new XmlDocument();
xmlDocument.LoadXml("<node datetime='now' />");
+// ReSharper disable once PossibleNullReferenceException
_attribute = xmlDocument.FirstChild.Attributes[0];
_expectedValue = "now";
}
View
8 src/LinqToHtml.Tests/HTMLTagTests.cs
@@ -53,6 +53,7 @@ private void should_not_return_null()
private void should_return_the_city_attribute()
{
+// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
_result.Single(x => x.NameEqualsIgnoreCase("city"));
}
@@ -63,11 +64,13 @@ private void should_return_the_correct_number_of_attributes()
private void should_return_the_state_attribute()
{
+// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
_result.Single(x => x.NameEqualsIgnoreCase("state"));
}
private void should_return_the_street_attribute()
{
+// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
_result.Single(x => x.NameEqualsIgnoreCase("street"));
}
@@ -126,6 +129,7 @@ private void should_not_return_null()
private void should_return_the_body_tag()
{
+// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
_result.Single(x => x.Type == "body");
}
@@ -136,6 +140,7 @@ private void should_return_the_correct_number_of_tags()
private void should_return_the_head_tag()
{
+// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
_result.Single(x => x.Type == "head");
}
@@ -230,6 +235,7 @@ private void should_not_return_null()
private void should_return_the_body_tag()
{
+// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
_result.Single(x => x.Type == "body");
}
@@ -240,11 +246,13 @@ private void should_return_the_correct_number_of_tags()
private void should_return_the_head_tag()
{
+// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
_result.Single(x => x.Type == "head");
}
private void should_return_the_title_tag()
{
+// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
_result.Single(x => x.Type == "title");
}
View
12 src/LinqToHtml.Tests/HTMLTagTypeFilterTests.cs
@@ -53,9 +53,9 @@ private void should_return_an_empty_list()
private void should_return_only_the_matching_tags()
{
- var enumerable = _result.Select(x => x.Type).Distinct();
- enumerable.Count().ShouldBeEqualTo(1);
- enumerable.First().ShouldBeEqualTo(_type);
+ var list = _result.Select(x => x.Type).Distinct().ToList();
+ list.Count.ShouldBeEqualTo(1);
+ list.First().ShouldBeEqualTo(_type);
}
private void when_asked_to_get_the_tags_for_the_requested_type()
@@ -117,9 +117,9 @@ private void should_not_return_null()
private void should_return_only_the_matching_tags_ignoring_case()
{
- var enumerable = _result.Select(x => x.Type).Distinct();
- enumerable.Count().ShouldBeEqualTo(1);
- string type = enumerable.First();
+ var list = _result.Select(x => x.Type).Distinct().ToList();
+ list.Count.ShouldBeEqualTo(1);
+ var type = list.First();
String.Equals(type, _type, StringComparison.InvariantCultureIgnoreCase).ShouldBeTrue();
}
View
6 src/LinqToHtml.Tests/IEnumerableHTMLTagExtensionsTests.cs
@@ -35,9 +35,9 @@ private void should_not_return_null()
private void should_return_only_the_matching_tags()
{
- var enumerable = _result.Select(x => x.Type).Distinct();
- enumerable.Count().ShouldBeEqualTo(1);
- enumerable.First().ShouldBeEqualTo(_type);
+ var list = _result.Select(x => x.Type).Distinct().ToList();
+ list.Count.ShouldBeEqualTo(1);
+ list.First().ShouldBeEqualTo(_type);
}
private void when_asked_to_get_the_tags_for_the_requested_type()
View
5 src/LinqToHtml.Tests/LinqToHtml.Tests.csproj
@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LinqToHtml.Tests</RootNamespace>
<AssemblyName>LinqToHtml.Tests</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
@@ -31,6 +31,7 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
+ <TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -40,6 +41,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -48,6 +50,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="FluentAssert, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
View
5 src/LinqToHtml/LinqToHtml.csproj
@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LinqToHtml</RootNamespace>
<AssemblyName>LinqToHtml</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
@@ -31,6 +31,7 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
+ <TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -40,6 +41,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -48,6 +50,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
View
106 src/LinqToHtml/PropertySetter.cs
@@ -8,72 +8,72 @@ namespace LinqToHtml
public class PropertySetter
{
public static readonly PropertySetter Boolean = new PropertySetter(typeof(bool), (d, p, v) =>
+ {
+ try
+ {
+ var value = Convert.ToBoolean(v);
+ p.SetValue(d, value, null);
+ }
+ catch
{
- try
- {
- bool value = Convert.ToBoolean(v);
- p.SetValue(d, value, null);
- }
- catch
- {
- }
- });
+ }
+ });
public static readonly PropertySetter DateTime = new PropertySetter(typeof(DateTime), (d, p, v) =>
+ {
+ try
{
- try
- {
- var value = Convert.ToDateTime(v);
- p.SetValue(d, value, null);
- }
- catch
- {
- }
- });
+ var value = Convert.ToDateTime(v);
+ p.SetValue(d, value, null);
+ }
+ catch
+ {
+ }
+ });
public static readonly PropertySetter Decimal = new PropertySetter(typeof(decimal), (d, p, v) =>
+ {
+ try
+ {
+ var value = Convert.ToDecimal(v);
+ p.SetValue(d, value, null);
+ }
+ catch
{
- try
- {
- decimal value = Convert.ToDecimal(v);
- p.SetValue(d, value, null);
- }
- catch
- {
- }
- });
+ }
+ });
public static readonly PropertySetter Default = new PropertySetter(typeof(object), (d, p, v) => { });
public static readonly PropertySetter Double = new PropertySetter(typeof(double), (d, p, v) =>
+ {
+ try
+ {
+ var value = Convert.ToDouble(v);
+ p.SetValue(d, value, null);
+ }
+ catch
{
- try
- {
- double value = Convert.ToDouble(v);
- p.SetValue(d, value, null);
- }
- catch
- {
- }
- });
+ }
+ });
public static readonly PropertySetter Int = new PropertySetter(typeof(int), (d, p, v) =>
+ {
+ try
{
- try
- {
- int value = Convert.ToInt32(v);
- p.SetValue(d, value, null);
- }
- catch
- {
- }
- });
+ var value = Convert.ToInt32(v);
+ p.SetValue(d, value, null);
+ }
+ catch
+ {
+ }
+ });
private static readonly IList<PropertySetter> PropertySetters = new List<PropertySetter>();
public static readonly PropertySetter String = new PropertySetter(typeof(string), (d, p, v) =>
+ {
+ try
+ {
+ p.SetValue(d, v, null);
+ }
+ catch
{
- try
- {
- p.SetValue(d, v, null);
- }
- catch
- {
- }
- });
+ }
+ });
private readonly Type _type;

0 comments on commit d21ce0d

Please sign in to comment.