From 676f2ab9b8d6caedeff931ad3c5d2c7b27be105f Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Sat, 21 Nov 2020 19:31:03 -0500 Subject: [PATCH 1/3] feat(stream_extensions): Add support for CancellationToken on extension stream.ReadBytesAsync() --- .editorconfig | 213 +++++++++++++++ .../Extensions/StreamExtensionsFixture.cs | 255 ++++++++++++++++++ .../Extensions/StringExtensionsFixture.cs | 166 +++++++----- src/Uno.Core.Tests/Uno.Core.Tests.csproj | 5 +- src/Uno.Core/Extensions/StreamExtensions.cs | 195 +++++++++----- .../Extensions/StringExtensions.Format.cs | 13 +- 6 files changed, 705 insertions(+), 142 deletions(-) create mode 100644 .editorconfig create mode 100644 src/Uno.Core.Tests/Extensions/StreamExtensionsFixture.cs diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..856f53f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,213 @@ +root = true + +[*] +tab_width = 4 +trim_trailing_whitespace = true +insert_final_newline = true + +[{*.xml, *.targets, *.props}] +indent_style = tab + +[{*.cs}] +indent_style = tab + +[*.csproj] +indent_style = tab +tab_width = 2 +indent_size = 2 + +[{*.yml, *.yaml}] +indent_style = space + +[*.md] +indent_style = space + +[*.cs] +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_indent_block_contents +csharp_indent_block_contents = true + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_indent_braces +csharp_indent_braces = false + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_indent_case_contents +csharp_indent_case_contents = true + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_indent_labels +csharp_indent_labels = one_less_than_current + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_indent_switch_labels +csharp_indent_switch_labels = true + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_new_line_before_catch +csharp_new_line_before_catch = true + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_new_line_before_else +csharp_new_line_before_else = true + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_new_line_before_finally +csharp_new_line_before_finally = true + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_new_line_before_members_in_anonymous_types +csharp_new_line_before_members_in_anonymous_types = true + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_new_line_before_members_in_object_initializers +csharp_new_line_before_members_in_object_initializers = true + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_new_line_before_open_brace +csharp_new_line_before_open_brace = all + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_new_line_between_query_expression_clauses +csharp_new_line_between_query_expression_clauses = true + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_prefer_braces +csharp_prefer_braces = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_prefer_simple_default_expression +csharp_prefer_simple_default_expression = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_preserve_single_line_blocks +csharp_preserve_single_line_blocks = true + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_after_cast +csharp_space_after_cast = false + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_after_colon_in_inheritance_clause +csharp_space_after_colon_in_inheritance_clause = true + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_after_comma +csharp_space_after_comma = true + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_after_dot +csharp_space_after_dot = false + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_after_keywords_in_control_flow_statements +csharp_space_after_keywords_in_control_flow_statements = true + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_after_semicolon_in_for_statement +csharp_space_after_semicolon_in_for_statement = true + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_around_binary_operators +csharp_space_around_binary_operators = before_and_after + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_around_declaration_statements +csharp_space_around_declaration_statements = do_not_ignore + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_before_colon_in_inheritance_clause +csharp_space_before_colon_in_inheritance_clause = true + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_before_comma +csharp_space_before_comma = false + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_before_dot +csharp_space_before_dot = false + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_before_open_square_brackets +csharp_space_before_open_square_brackets = false + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_before_semicolon_in_for_statement +csharp_space_before_semicolon_in_for_statement = false + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_between_empty_square_brackets +csharp_space_between_empty_square_brackets = false + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_between_method_call_empty_parameter_list_parentheses +csharp_space_between_method_call_empty_parameter_list_parentheses = false + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_between_method_call_name_and_opening_parenthesis +csharp_space_between_method_call_name_and_opening_parenthesis = false + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_between_method_call_parameter_list_parentheses +csharp_space_between_method_call_parameter_list_parentheses = false + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_between_method_declaration_empty_parameter_list_parentheses +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_between_method_declaration_name_and_open_parenthesis +csharp_space_between_method_declaration_name_and_open_parenthesis = false + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_between_method_declaration_parameter_list_parentheses +csharp_space_between_method_declaration_parameter_list_parentheses = false + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_between_parentheses +csharp_space_between_parentheses = none + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_between_square_brackets +csharp_space_between_square_brackets = false + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_conditional_delegate_call +csharp_style_conditional_delegate_call = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_expression_bodied_accessors +csharp_style_expression_bodied_accessors = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_expression_bodied_constructors +csharp_style_expression_bodied_constructors = false:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_expression_bodied_indexers +csharp_style_expression_bodied_indexers = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_expression_bodied_methods +csharp_style_expression_bodied_methods = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_expression_bodied_operators +csharp_style_expression_bodied_operators = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_expression_bodied_properties +csharp_style_expression_bodied_properties = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_inlined_variable_declaration +csharp_style_inlined_variable_declaration = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_pattern_matching_over_as_with_null_check +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_pattern_matching_over_is_with_cast_check +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_throw_expression +csharp_style_throw_expression = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_var_elsewhere +csharp_style_var_elsewhere = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_var_for_built_in_types +csharp_style_var_for_built_in_types = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_var_when_type_is_apparent +csharp_style_var_when_type_is_apparent = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_sort_system_directives_first +dotnet_sort_system_directives_first = true + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_coalesce_expression +dotnet_style_coalesce_expression = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_collection_initializer +dotnet_style_collection_initializer = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_explicit_tuple_names +dotnet_style_explicit_tuple_names = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_null_propagation +dotnet_style_null_propagation = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_object_initializer +dotnet_style_object_initializer = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_predefined_type_for_locals_parameters_members +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_predefined_type_for_member_access +dotnet_style_predefined_type_for_member_access = true:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_qualification_for_event +dotnet_style_qualification_for_event = false:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_qualification_for_field +dotnet_style_qualification_for_field = false:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_qualification_for_method +dotnet_style_qualification_for_method = false:suggestion + +# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_qualification_for_property +dotnet_style_qualification_for_property = false:suggestion diff --git a/src/Uno.Core.Tests/Extensions/StreamExtensionsFixture.cs b/src/Uno.Core.Tests/Extensions/StreamExtensionsFixture.cs new file mode 100644 index 0000000..8f57800 --- /dev/null +++ b/src/Uno.Core.Tests/Extensions/StreamExtensionsFixture.cs @@ -0,0 +1,255 @@ +using System; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using FluentAssertions; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Uno.Extensions; + +namespace Uno.Core.Tests.Extensions +{ + [TestClass] + public class StreamExtensionsFixture + { + [TestMethod] + public void ReadBytes_MemoryStream() + { + var (sut, originalBytes) = CreateStream(2000); + + var readBytes1 = sut.ReadBytes(); + + readBytes1.Should().Equal(originalBytes); + } + + [TestMethod] + public async Task ReadBytesAsync_MemoryStream() + { + var (sut, originalBytes) = CreateStream(2000); + + var readBytes1 = await sut.ReadBytesAsync(); + + readBytes1.Should().Equal(originalBytes); + } + + [TestMethod] + public void ReadBytes_UnseekableSyncStream() + { + var (stream, originalBytes) = CreateStream(50000); + var sut = new UnseekableSyncStream(stream); + + var readBytes1 = sut.ReadBytes(); + + readBytes1.Should().Equal(originalBytes); + } + + [TestMethod] + public void ReadBytes_UnseekableSyncStream2() + { + var (stream, originalBytes) = CreateStream(50000); + var sut = new UnseekableSyncStream(stream, true); + + var readBytes1 = sut.ReadBytes(); + + readBytes1.Should().Equal(originalBytes); + } + + [TestMethod] + public async Task ReadBytesAsync_UnseekableSyncStream() + { + var (stream, originalBytes) = CreateStream(50000); + var sut = new UnseekableSyncStream(stream); + + var readBytes1 = await sut.ReadBytesAsync(); + + readBytes1.Should().Equal(originalBytes); + } + + [TestMethod] + public async Task ReadBytesAsync_UnseekableSyncStream2() + { + var (stream, originalBytes) = CreateStream(50000); + var sut = new UnseekableSyncStream(stream, true); + + var readBytes1 = await sut.ReadBytesAsync(); + + readBytes1.Should().Equal(originalBytes); + } + + [TestMethod] + public void ReadBytes_NoLengthStream() + { + var (sut, _) = CreateStream(0); + sut.Length.Should().Be(0); + + var read = sut.ReadBytes(); + read.Should().BeEmpty(); + } + + [TestMethod] + public async Task ReadBytesAsync_NoLengthStream() + { + var (sut, _) = CreateStream(0); + sut.Length.Should().Be(0); + + var read = await sut.ReadBytesAsync(); + read.Should().BeEmpty(); + } + + [TestMethod] + public void ReadBytes_NoLengthStream_UnseekableSyncStream() + { + var (stream, _) = CreateStream(0); + var sut = new UnseekableSyncStream(stream); + + var read = sut.ReadBytes(); + read.Should().BeEmpty(); + } + + [TestMethod] + public async Task ReadBytesAsync_NoLengthStream_UnseekableSyncStream() + { + var (stream, _) = CreateStream(0); + var sut = new UnseekableSyncStream(stream); + + var read = await sut.ReadBytesAsync(); + read.Should().BeEmpty(); + } + + [TestMethod] + public async Task StartWith() + { + var (sut, _) = CreateStream(100); + + sut.StartsWith(1, 2, 3, 4, 5).Should().BeTrue(); + } + + [TestMethod] + public void StartWith_Empty() + { + var (sut, _) = CreateStream(0); + + sut.StartsWith(42, 42, 42, 42, 42).Should().BeFalse(); + } + + [TestMethod] + public void StartWith_Empty2() + { + var (sut, _) = CreateStream(10); + + sut.StartsWith().Should().BeTrue(); + } + + [TestMethod] + public async Task StartWithAsync_Empty() + { + var (sut, _) = CreateStream(0); + + (await sut.StartsWithAsync(42, 42, 42, 42, 42)).Should().BeFalse(); + } + + [TestMethod] + public async Task StartWithasync_Empty2() + { + var (sut, _) = CreateStream(10); + + (await sut.StartsWithAsync()).Should().BeTrue(); + } + + [TestMethod] + public async Task StartWithAsync() + { + var (sut, _) = CreateStream(100); + + sut.StartsWith(1, 2, 3, 4, 5).Should().BeTrue(); + } + + [TestMethod] + public async Task ReadBytesAsync_NoLengthStream_UnseekableSyncStream2() + { + var (stream, _) = CreateStream(0); + var sut = new UnseekableSyncStream(stream); + + var read = await sut.ReadBytesAsync(); + read.Should().BeEmpty(); + } + + [TestMethod] + public async Task ToSeekable() + { + var (stream, expected) = CreateStream(int.MaxValue/50); + var unseekable = new UnseekableSyncStream(stream); + unseekable.CanSeek.Should().BeFalse(); + + var sut = unseekable.ToSeekable(); + + sut.CanSeek.Should().BeTrue(); + (await sut.ReadBytesAsync()).Should().Equal(expected); + } + + private static (MemoryStream Stream, byte[] bytes) CreateStream(int length = 2000) + { + var bytes = Enumerable + .Range(1, length) + .Select(i => + { + unchecked + { + return (byte) i; + } + }) + .ToArray(); + + var stream = new MemoryStream(bytes); + return (stream, bytes); + } + + private class UnseekableSyncStream : Stream + { + private readonly Stream _stream; + + public UnseekableSyncStream(Stream stream, bool canSeek = false) + { + _stream = stream; + CanSeek = canSeek; + } + + public override void Flush() + { + } + + public override long Seek(long offset, SeekOrigin origin) + { + throw new NotSupportedException(); + } + + public override void SetLength(long value) + { + throw new NotSupportedException(); + } + + public override int Read(byte[] buffer, int offset, int count) + { + var newCount = count > 2 ? count / 2 : count; + return _stream.Read(buffer, offset, newCount); + } + + public override void Write(byte[] buffer, int offset, int count) + { + throw new NotSupportedException(); + } + + public override bool CanRead => true; + public override bool CanSeek { get; } + + public override bool CanWrite => false; + + public override long Length => throw new NotSupportedException(); + + public override long Position + { + get => throw new NotSupportedException(); + set => throw new NotSupportedException(); + } + } + } +} diff --git a/src/Uno.Core.Tests/Extensions/StringExtensionsFixture.cs b/src/Uno.Core.Tests/Extensions/StringExtensionsFixture.cs index 9b42bac..c28e545 100644 --- a/src/Uno.Core.Tests/Extensions/StringExtensionsFixture.cs +++ b/src/Uno.Core.Tests/Extensions/StringExtensionsFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,9 +14,12 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Globalization; using System.Linq; +using FluentAssertions; +using FluentAssertions.Execution; using Microsoft.VisualStudio.TestTools.UnitTesting; using Uno.Extensions; @@ -28,71 +31,81 @@ public class StringExtensionsFixture [TestMethod] public void IsNullOrEmpty() { - Assert.IsTrue(((string)null).IsNullOrEmpty()); - Assert.IsTrue("".IsNullOrEmpty()); - Assert.IsFalse("A".IsNullOrEmpty()); + using var _ = new AssertionScope(); + + ((string)null).IsNullOrEmpty().Should().BeTrue(); + "".IsNullOrEmpty().Should().BeTrue(); + string.Empty.IsNullOrEmpty().Should().BeTrue(); + "A".IsNullOrEmpty().Should().BeFalse(); } [TestMethod] public void HasValue() { - Assert.IsFalse(((string)null).HasValue()); - Assert.IsFalse("".HasValue()); - Assert.IsTrue("A".HasValue()); + using var _ = new AssertionScope(); + + ((string)null).HasValue().Should().BeFalse(); + "".HasValue().Should().BeFalse(); + string.Empty.HasValue().Should().BeFalse(); + "A".HasValue().Should().BeTrue(); } [TestMethod] public void IsNumber() { - Assert.IsTrue("123".IsNumber()); - Assert.IsTrue("123 ".IsNumber()); - Assert.IsTrue(" 123".IsNumber()); - Assert.IsTrue("\t\t123".IsNumber()); + using var _ = new AssertionScope(); + + "123".IsNumber().Should().BeTrue(); + "123 ".IsNumber().Should().BeTrue(); + " 123".IsNumber().Should().BeTrue(); + "\t\t123".IsNumber().Should().BeTrue(); - Assert.IsTrue("₀₁₂₃₄₅₆₇₈₉".IsNumber(), "subscripts"); - Assert.IsTrue("⁰¹²³⁴⁵⁶⁷⁸⁹".IsNumber(), "superscripts"); + "₀₁₂₃₄₅₆₇₈₉".IsNumber().Should().BeTrue("subscripts"); + "⁰¹²³⁴⁵⁶⁷⁸⁹".IsNumber().Should().BeTrue("superscripts"); - Assert.IsTrue("¼½¾".IsNumber(), "fractions 1"); - Assert.IsTrue("⅓⅔⅕⅖⅗⅘⅙⅚⅛⅜⅝⅞".IsNumber(), "fractions 2"); + "¼½¾".IsNumber().Should().BeTrue("fractions 1"); + "⅓⅔⅕⅖⅗⅘⅙⅚⅛⅜⅝⅞".IsNumber().Should().BeTrue("fractions 2"); //Assert.IsTrue("⅐⅑⅒".IsNumber()); THOSE ARE NOT SUPPORTED BY .NET! // Roman numerals http://www.unicode.org/charts/PDF/U2150.pdf - Assert.IsTrue("ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯ".IsNumber(), "romans upper"); // watch-out, those are not letters! ;-) - Assert.IsTrue("ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿ".IsNumber(), "romans lower"); // watch-out, those are not letters! ;-) + "ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯ".IsNumber().Should().BeTrue("romans upper"); // watch-out, those are not letters! ;-) + "ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿ".IsNumber().Should().BeTrue("romans lower"); // watch-out, those are not letters! ;-) // Umbrella are not supporting Aegean numbers, as they are 32bits unicode characters - Assert.IsTrue("٠١٢٣٤٥٦٧٨٩".IsNumber(), "Eastern Arabic numerals"); - Assert.IsTrue("۰۱۲۳۴۵۶۷۸۹".IsNumber(), "Persian numerals"); + "٠١٢٣٤٥٦٧٨٩".IsNumber().Should().BeTrue("Eastern Arabic numerals"); + "۰۱۲۳۴۵۶۷۸۹".IsNumber().Should().BeTrue("Persian numerals"); - Assert.IsFalse("1A2".IsNumber()); - Assert.IsFalse("1A2".IsNumber()); + "1A2".IsNumber().Should().BeFalse(); + "1A2".IsNumber().Should().BeFalse(); } [TestMethod] public void IsDigit() { - Assert.IsTrue("0123456789".IsDigit(), "Normal digits"); - Assert.IsTrue("٠١٢٣٤٥٦٧٨٩".IsDigit(), "Eastern Arabic numerals"); - Assert.IsTrue("۰۱۲۳۴۵۶۷۸۹".IsDigit(), "Persian numerals"); - - Assert.IsTrue(" 123".IsDigit(), "space before"); - Assert.IsTrue("123 ".IsDigit(), "space after"); - Assert.IsTrue("\t\t123".IsDigit(), "tab before"); - - Assert.IsFalse("₀₁₂₃₄₅₆₇₈₉".IsDigit()); - Assert.IsFalse("⁰¹²³⁴⁵⁶⁷⁸⁹".IsDigit()); - Assert.IsFalse("¼½¾".IsDigit()); - Assert.IsFalse("⅓⅔⅕⅖⅗⅘⅙⅚⅛⅜⅝⅞".IsDigit()); - Assert.IsFalse("⅐⅑⅒".IsDigit()); - Assert.IsFalse("ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯ".IsDigit()); // watch-out, those are not letters! ;-) - Assert.IsFalse("ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿ".IsDigit()); // watch-out, those are not letters! ;-) + using var _ = new AssertionScope(); + + "0123456789".IsDigit().Should().BeTrue("Normal digits"); + "٠١٢٣٤٥٦٧٨٩".IsDigit().Should().BeTrue("Eastern Arabic numerals"); + "۰۱۲۳۴۵۶۷۸۹".IsDigit().Should().BeTrue("Persian numerals"); + + " 123".IsDigit().Should().BeTrue("space before"); + "123 ".IsDigit().Should().BeTrue("space after"); + "\t\t123".IsDigit().Should().BeTrue("tab before"); + + "₀₁₂₃₄₅₆₇₈₉".IsDigit().Should().BeFalse(); + "⁰¹²³⁴⁵⁶⁷⁸⁹".IsDigit().Should().BeFalse(); + "¼½¾".IsDigit().Should().BeFalse(); + "⅓⅔⅕⅖⅗⅘⅙⅚⅛⅜⅝⅞".IsDigit().Should().BeFalse(); + "⅐⅑⅒".IsDigit().Should().BeFalse(); + "ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯ".IsDigit().Should().BeFalse(); // watch-out, those are not letters! ;-) + "ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿ".IsDigit().Should().BeFalse(); // watch-out, those are not letters! ;-) // Full Width digits http://www.unicode.org/charts/PDF/UFF00.pdf var fullWidthDigits = "\uFF10\uFF11\uFF12\uFF13\uFF14\uFF15\uFF16\uFF17\uFF18\uFF19"; - Assert.IsTrue(fullWidthDigits.IsNumber(), "Full Width Digits"); + fullWidthDigits.IsNumber().Should().BeTrue("Full Width Digits"); - Assert.IsFalse("1A2".IsDigit()); + "1A2".IsDigit().Should().BeFalse(); } [TestMethod] @@ -126,6 +139,8 @@ public void CustomStringFormatAcceptsOneAndMinusOne() [TestMethod] public void StringFormatsAreCompatible() { + using var _ = new AssertionScope(); + var formats = new[] { "{0:+#.#;-#.#;ZERO}", @@ -139,6 +154,7 @@ public void StringFormatsAreCompatible() CultureInfo.InvariantCulture, new CultureInfo("fr-CA"), new CultureInfo("en-US"), + new CultureInfo("ja-JP"), new CultureInfo("ru") }; @@ -146,15 +162,13 @@ public void StringFormatsAreCompatible() { foreach (var value in values) { - Assert.AreEqual( - string.Format(format, value), - StringExtensions.Format(format, value)); + var noCultureFormat = StringExtensions.Format(format, value); + noCultureFormat.Should().Be(string.Format(format, value)); foreach (var culture in cultures) { - Assert.AreEqual( - string.Format(culture, format, value), - StringExtensions.Format(culture, format, value)); + var cultureFormat = StringExtensions.Format(culture, format, value); + cultureFormat.Should().Be(string.Format(culture, format, value)); } } } @@ -163,6 +177,8 @@ public void StringFormatsAreCompatible() [TestMethod] public void StringFormatsAreComplementary() { + using var _ = new AssertionScope(); + var formats = new[] { "{0:+#.##;-#.##;ZERO;ONE;MINUS ONE}", @@ -184,29 +200,26 @@ public void StringFormatsAreComplementary() { foreach (var value in identicalValues) { - Assert.AreEqual( - string.Format(format, value), - StringExtensions.Format(format, value)); + var identicalValueFormat = StringExtensions.Format(format, value); + identicalValueFormat.Should().Be(string.Format(format, value), "using current culture"); foreach (var culture in cultures) { - Assert.AreEqual( - string.Format(culture, format, value), - StringExtensions.Format(culture, format, value)); + var identicalValueFormatWithCulture = StringExtensions.Format(culture, format, value); + identicalValueFormatWithCulture.Should().Be(string.Format(culture, format, value), "using culture " + culture); } } foreach (var value in differentValues) { - Assert.AreNotEqual( - string.Format(format, value), - StringExtensions.Format(format, value)); + var differentValueFormat = StringExtensions.Format(format, value); + differentValueFormat.Should().NotBe(string.Format(format, value), "using current culture"); foreach (var culture in cultures) { - Assert.AreNotEqual( - string.Format(culture, format, value), - StringExtensions.Format(culture, format, value)); + var differenceValueFOrmatWithCulture = StringExtensions.Format(culture, format, value); + differenceValueFOrmatWithCulture + .Should().NotBe(string.Format(culture, format, value), "using culture " + culture); } } } @@ -215,6 +228,8 @@ public void StringFormatsAreComplementary() [TestMethod] public void CustomStringFormatIsTolerant() { + using var _ = new AssertionScope(); + var formats = new[] { "This has no value", @@ -241,13 +256,15 @@ public void CustomStringFormatIsTolerant() foreach (var pair in formats.Zip(expectedResults, (format, expected) => new { format, expected })) { - Assert.AreEqual(StringExtensions.Format(pair.format, 42), pair.expected); + StringExtensions.Format(pair.format, 42).Should().Be(pair.expected); } } [TestMethod] public void StringFormatHasEscapedChars() { + using var _ = new AssertionScope(); + var formats = new[] { @"{0:\;#.##\;;(#.##);\;\-\-\;;\'XXX\'}", @@ -264,7 +281,7 @@ public void StringFormatHasEscapedChars() var original = string.Format(format, value); var custom = StringExtensions.Format(format, value); - Assert.AreEqual(original, custom); + custom.Should().Be(original); } } } @@ -272,6 +289,8 @@ public void StringFormatHasEscapedChars() [TestMethod] public void StringFormatsErrorHandlingAreIdentical() { + using var _ = new AssertionScope(); + var formats = new[] { @"{0:#.##;(#.##);ZERO", @@ -290,23 +309,24 @@ public void StringFormatsErrorHandlingAreIdentical() { var custom = StringExtensions.Format(format, 42); - Assert.AreEqual(original, custom); + custom.Should().Be(original); } catch { - Assert.Fail($"string.Format did not fail for {format}. StringExtensions.Format shouldn't have failed either."); + AssertionScope.Current.FailWith("string.Format did not fail for {0}. StringExtensions.Format shouldn't have failed either.", format); } } - catch + catch(Exception originalEx) { try { StringExtensions.Format(format, 42); - Assert.Fail($"string.Format failed for {format}. StringExtensions.Format should have failed too."); + AssertionScope.Current.FailWith("string.Format failed for {0}. StringExtensions.Format should have failed too.", format); } - catch + catch(Exception exceptionEx) { + exceptionEx.Should().BeOfType(originalEx.GetType()); } } } @@ -315,15 +335,17 @@ public void StringFormatsErrorHandlingAreIdentical() [TestMethod] public void CustomStringFormatsWithMultipleValues() { - Assert.AreEqual( - StringExtensions.Format("For {0} and {1}?", 42, 3.1416), - "For 42 and 3.1416?"); - Assert.AreEqual( - StringExtensions.Format("For {0:#.##;(#.##);ZERO} and {1:#.##;(#.##);ZERO}?", 42, 3.1416), - "For 42 and 3.14?"); - Assert.AreEqual( - StringExtensions.Format("For {0:#.##;(#.##);ZERO;ONE}, {1:#.##;(#.##);ZERO;ONE} and {2:#.##;(#.##);ZERO;ONE}?", 42, 3.1416, 1.004), - "For 42, 3.14 and ONE?"); + using var _ = new AssertionScope(); + + StringExtensions + .Format("For {0} and {1}?", 42, 3.1416) + .Should().Be("For 42 and 3.1416?"); + StringExtensions + .Format("For {0:#.##;(#.##);ZERO} and {1:#.##;(#.##);ZERO}?", 42, 3.1416) + .Should().Be("For 42 and 3.14?"); + StringExtensions + .Format("For {0:#.##;(#.##);ZERO;ONE}, {1:#.##;(#.##);ZERO;ONE} and {2:#.##;(#.##);ZERO;ONE}?", 42, 3.1416, 1.004) + .Should().Be("For 42, 3.14 and ONE?"); } } } diff --git a/src/Uno.Core.Tests/Uno.Core.Tests.csproj b/src/Uno.Core.Tests/Uno.Core.Tests.csproj index 04a77a5..1fc57cd 100644 --- a/src/Uno.Core.Tests/Uno.Core.Tests.csproj +++ b/src/Uno.Core.Tests/Uno.Core.Tests.csproj @@ -3,7 +3,7 @@ net46 1701;1702;1705;1998 - 7.3 + latest @@ -11,10 +11,11 @@ - + + all diff --git a/src/Uno.Core/Extensions/StreamExtensions.cs b/src/Uno.Core/Extensions/StreamExtensions.cs index f5898b6..bc55d6d 100644 --- a/src/Uno.Core/Extensions/StreamExtensions.cs +++ b/src/Uno.Core/Extensions/StreamExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,67 +15,125 @@ // // ****************************************************************** using System; -using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; +using System.Threading; using System.Threading.Tasks; namespace Uno.Extensions { public static class StreamExtensions { - public static async Task ReadBytesAsync(this Stream stream) + private const int BUFFER_SIZE = 4096; + + public static Task ReadBytesAsync(this Stream stream) => stream.ReadBytesAsync(default); + + /// + /// Read all bytes of a stream. + /// + /// + /// The stream won't be closed by this method. + /// + public static async Task ReadBytesAsync(this Stream stream, CancellationToken ct) { - byte[] readBuffer = new byte[stream.CanSeek ? (stream.Length - stream.Position) : 4096]; + long? length; + long? startingPosition; + + try + { + length = stream.CanSeek ? stream.Length : (long?)null; + startingPosition = stream.CanSeek ? stream.Position : (long?)null; + } + catch (NotSupportedException) + { + length = null; + startingPosition = null; + } + + if (length == 0 || (startingPosition.HasValue && startingPosition == length)) // empty stream + { + return new byte[] { }; + } + + if (stream is MemoryStream {Position: 0} memStream) + { + // MemoryStream.ToArray() is already optimized, so use it when possible + return memStream.ToArray(); + } - int totalBytesRead = 0; + var readBuffer = new byte[length ?? BUFFER_SIZE]; + + var totalBytesRead = 0; int bytesRead; - while ((bytesRead = await stream.ReadAsync(readBuffer, totalBytesRead, readBuffer.Length - totalBytesRead)) > 0) + while ((bytesRead = await stream.ReadAsync(readBuffer, totalBytesRead, readBuffer.Length - totalBytesRead, ct)) > 0) { totalBytesRead += bytesRead; if (totalBytesRead == readBuffer.Length) { var nextBytes = new byte[1]; - var read = await stream.ReadAsync(nextBytes, 0, 1); + var read = await stream.ReadAsync(nextBytes, 0, 1, ct); - if (read == 1) + if (read != 1) { - byte[] temp = new byte[readBuffer.Length * 2]; - System.Buffer.BlockCopy(readBuffer, 0, temp, 0, readBuffer.Length); - System.Buffer.SetByte(temp, totalBytesRead, (byte)nextBytes[0]); - readBuffer = temp; - totalBytesRead++; + continue; } + + var temp = new byte[readBuffer.Length * 2]; + Buffer.BlockCopy(readBuffer, 0, temp, 0, readBuffer.Length); + Buffer.SetByte(temp, totalBytesRead, (byte)nextBytes[0]); + readBuffer = temp; + totalBytesRead++; } } - byte[] buffer = readBuffer; + var buffer = readBuffer; if (readBuffer.Length != totalBytesRead) { buffer = new byte[totalBytesRead]; - System.Buffer.BlockCopy(readBuffer, 0, buffer, 0, totalBytesRead); + Buffer.BlockCopy(readBuffer, 0, buffer, 0, totalBytesRead); } return buffer; } + /// + /// Read all bytes of a stream. + /// + /// + /// The stream won't be closed by this method. + /// public static byte[] ReadBytes(this Stream stream) { - if (stream.CanSeek && (stream.Position == 0)) + long? length; + long? startingPosition; + + try { - var sourceMemoryStream = stream as MemoryStream; - if (sourceMemoryStream != null) - { - // MemoryStream.ToArray() is already optimized, so use it when possible - return sourceMemoryStream.ToArray(); - } + length = stream.CanSeek ? stream.Length : (long?)null; + startingPosition = stream.CanSeek ? stream.Position : (long?)null; + } + catch (NotSupportedException) + { + length = null; + startingPosition = null; + } + + if (length == 0 || (startingPosition.HasValue && startingPosition == length)) // empty stream + { + return new byte[] { }; + } + + if (stream is MemoryStream {Position: 0} memStream) + { + // MemoryStream.ToArray() is already optimized, so use it when possible + return memStream.ToArray(); } - byte[] readBuffer = new byte[stream.CanSeek ? (stream.Length - stream.Position) : 4096]; + var readBuffer = new byte[length ?? BUFFER_SIZE]; - int totalBytesRead = 0; + var totalBytesRead = 0; int bytesRead; while ((bytesRead = stream.Read(readBuffer, totalBytesRead, readBuffer.Length - totalBytesRead)) > 0) @@ -84,23 +142,25 @@ public static byte[] ReadBytes(this Stream stream) if (totalBytesRead == readBuffer.Length) { - int nextByte = stream.ReadByte(); - if (nextByte != -1) + var nextByte = stream.ReadByte(); + if (nextByte == -1) { - byte[] temp = new byte[readBuffer.Length * 2]; - System.Buffer.BlockCopy(readBuffer, 0, temp, 0, readBuffer.Length); - System.Buffer.SetByte(temp, totalBytesRead, (byte)nextByte); - readBuffer = temp; - totalBytesRead++; + continue; } + + var temp = new byte[readBuffer.Length * 2]; + Buffer.BlockCopy(readBuffer, 0, temp, 0, readBuffer.Length); + Buffer.SetByte(temp, totalBytesRead, (byte)nextByte); + readBuffer = temp; + totalBytesRead++; } } - byte[] buffer = readBuffer; + var buffer = readBuffer; if (readBuffer.Length != totalBytesRead) { buffer = new byte[totalBytesRead]; - System.Buffer.BlockCopy(readBuffer, 0, buffer, 0, totalBytesRead); + Buffer.BlockCopy(readBuffer, 0, buffer, 0, totalBytesRead); } return buffer; } @@ -108,44 +168,54 @@ public static byte[] ReadBytes(this Stream stream) /// /// Reads the text container into the specified stream. /// - /// - /// The string using the default encoding. + /// The read string using the default encoding. /// The stream will be disposed when calling this method. public static string ReadToEnd(this Stream stream) { - string value; - using (var reader = new StreamReader(stream)) - { - value = reader.ReadToEnd(); - } - return value; + using var reader = new StreamReader(stream); + return reader.ReadToEnd(); } /// /// Reads the text container into the specified stream. /// - /// - /// The string using the default encoding. + /// The read string using the specified encoding. /// The stream will be disposed when calling this method. public static string ReadToEnd(this Stream stream, Encoding encoding) { - string value; - using (var reader = new StreamReader(stream, encoding)) + using var reader = new StreamReader(stream, encoding); + return reader.ReadToEnd(); + } + + /// + /// Warning, if stream cannot be seek, will read from current position! + /// Warning, stream position will not been restored! + /// + public static bool StartsWith(this Stream stream, params byte[] start) + { + if (start.Length == 0) { - value = reader.ReadToEnd(); + return true; } - return value; + + if (stream.CanSeek) + { + stream.Position = 0; + } + + var buffer = new byte[start.Length]; + + stream.Read(buffer, 0, buffer.Length); + + return start.SequenceEqual(buffer); } /// /// Warning, if stream cannot be seek, will read from current position! /// Warning, stream position will not been restored! /// - /// - /// - /// - public static bool StartsWith(this Stream stream, byte[] start) + public static async Task StartsWithAsync(this Stream stream, params byte[] start) { if (stream.CanSeek) { @@ -154,7 +224,7 @@ public static bool StartsWith(this Stream stream, byte[] start) var buffer = new byte[start.Length]; - stream.Read(buffer, 0, buffer.Length); + await stream.ReadAsync(buffer, 0, buffer.Length); return start.SequenceEqual(buffer); } @@ -166,11 +236,19 @@ public static bool StartsWith(this Stream stream, byte[] start) /// Newly created memory stream, position set to 0 public static MemoryStream ToMemoryStream(this Stream source) { - var stream = new MemoryStream(); - source.CopyTo(stream); - stream.Position = 0; + if (source is MemoryStream memStream) + { + return memStream; + } + + memStream = source.CanSeek + ? new MemoryStream((int)source.Length) + : new MemoryStream(); - return stream; + source.CopyTo(memStream); + memStream.Position = 0; + + return memStream; } /// @@ -179,9 +257,6 @@ public static MemoryStream ToMemoryStream(this Stream source) /// /// A stream /// A seekable stream (orginal if seekable, a MemoryStream copy of else) - public static Stream ToSeekable(this Stream stream) - { - return stream.CanSeek ? stream : stream.ToMemoryStream(); - } + public static Stream ToSeekable(this Stream stream) => stream.CanSeek ? stream : stream.ToMemoryStream(); } } diff --git a/src/Uno.Core/Extensions/StringExtensions.Format.cs b/src/Uno.Core/Extensions/StringExtensions.Format.cs index 74512f2..212598d 100644 --- a/src/Uno.Core/Extensions/StringExtensions.Format.cs +++ b/src/Uno.Core/Extensions/StringExtensions.Format.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -32,10 +32,7 @@ public static partial class StringExtensions /// /// /// - public static string Format(string format, params object[] args) - { - return Format(CultureInfo.CurrentUICulture, format, args); - } + public static string Format(string format, params object[] args) => Format(CultureInfo.CurrentUICulture, format, args); /// /// Improves upon to allow a 4th and 5th @@ -61,7 +58,7 @@ public static string Format(IFormatProvider provider, string format, params obje var currentGroupBuilder = default(StringBuilder); var originalGroupBuilder = new StringBuilder(); - for (int position = 0; position < format.Length; position++) + for (var position = 0; position < format.Length; position++) { var builder = (currentGroupBuilder == null) ? finalBuilder : originalGroupBuilder; @@ -94,7 +91,7 @@ public static string Format(IFormatProvider provider, string format, params obje { if (currentGroupBuilder != null) { - throw new ArgumentException("Invalid group format. Nested opening accolades."); + throw new FormatException("Invalid group format. Nested opening accolades."); } // No { in deconstructed groups. @@ -116,7 +113,7 @@ public static string Format(IFormatProvider provider, string format, params obje if (currentGroupBuilder == null) { // string.Format does not tolerate this. - throw new ArgumentException("Format string contains an orphan closing accolade."); + throw new FormatException("Format string contains an orphan closing accolade."); } else { From 8a5a1624c50f81a0045cdd301b9ffe45f3d09cc9 Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Sat, 21 Nov 2020 19:40:16 -0500 Subject: [PATCH 2/3] ci: update headers --- build/header.txt | 4 +- .../Uno - Backup.Core.Build.csproj | 85 ++++ src/Uno.Core.Build/Uno.Core.Build.csproj | 2 +- .../Collections/ImmutableListFixture.cs | 3 +- .../Collections/ListExtensionsFixture.cs | 3 +- .../ObservableCollectionExtensionsFixture.cs | 3 +- .../Collections/SpanExtensionsFixture.cs | 5 +- .../ConversionExtensionsFixture.cs | 3 +- .../CustomConversionStrategyFixture.cs | 3 +- .../DefaultConversionsExtensionsFixture.cs | 3 +- .../EnumConversionStrategyFixture.cs | 3 +- src/Uno.Core.Tests/Conversions/FunqAdapter.cs | 3 +- .../TypeConverterConversionStrategyFixture.cs | 3 +- .../DelegateConditionalWeakTableFixture.cs | 3 +- .../DisposableConditionalWeakTableFixture.cs | 3 +- .../EqualityComparerExtensionsFixture.cs | 3 +- .../Equality/KeyEqualityComparerFixture.cs | 3 +- ...llectionExtensionsFixture.DisposableAdd.cs | 3 +- ...CollectionExtensions_RangeArray_Fixture.cs | 3 +- .../CollectionExtensions_RangeList_Fixture.cs | 3 +- .../Extensions/DateTimeExtensionsFixture.cs | 3 +- .../EnumerableExtensions.FullOuterJoin.cs | 3 +- .../EnumerableExtensions.SkipLast.cs | 3 +- .../Extensions/ExceptionExtensionsFixture.cs | 3 +- .../FormattableExtensionsFixture.cs | 3 +- .../Extensions/FuncExtensions.ApplyMemoize.cs | 3 +- .../Extensions/ObjectExtensionsFixture.cs | 3 +- .../Extensions/StreamExtensionsFixture.cs | 19 +- .../Transactional.ImmutableDictionary.cs | 3 +- .../Transactional.ImmutableQueue.cs | 3 +- .../Extensions/Transactional.Update.cs | 3 +- .../ValueType/ValueSupportFixture.cs | 3 +- src/Uno.Core.Tests/FuncsFixture.cs | 5 +- src/Uno.Core.Tests/Given_Predicates.cs | 3 +- src/Uno.Core.Tests/LoggerFixture.cs | 5 +- .../Options/OptionEqualityComparerFixture.cs | 3 +- src/Uno.Core.Tests/Properties/AssemblyInfo.cs | 3 +- .../Reflection/TypeExtensionsFixture.cs | 3 +- .../Threading/AsyncLockFixture.cs | 7 +- .../FastTaskCompletionSourceFixture.cs | 3 +- ...ransactionalFixture.ImmutableDictionary.cs | 3 +- .../TransactionalFixture.ImmutableList.cs | 3 +- src/Uno.Core.Tests/TransactionalFixture.cs | 3 +- .../_TestUtils/AsyncTestContext.cs | 5 +- .../_TestUtils/AsyncTestRunner.cs | 5 +- .../_TestUtils/SchedulerExtensions.cs | 3 +- src/Uno.Core.sln | 14 +- src/Uno.Core/ActionAsync.cs | 5 +- src/Uno.Core/Actions.Generic.cs | 5 +- src/Uno.Core/Actions.cs | 101 ++-- src/Uno.Core/Async/ActionService.cs | 3 +- src/Uno.Core/Async/AsyncResult.cs | 3 +- src/Uno.Core/Async/AsyncResultDecorator.cs | 3 +- src/Uno.Core/Async/IActionService.cs | 3 +- src/Uno.Core/Async/IAsyncService.cs | 3 +- src/Uno.Core/Async/SyncService.cs | 3 +- src/Uno.Core/Async/TaskExtensions.cs | 3 +- src/Uno.Core/Async/TaskUtilities.cs | 3 +- src/Uno.Core/Builder/BuilderContext.cs | 3 +- src/Uno.Core/Builder/IBuilder.cs | 3 +- src/Uno.Core/CachedTuple.cs | 7 +- src/Uno.Core/Cancellable.cs | 5 +- src/Uno.Core/Collections/CollectionAdapter.cs | 5 +- .../Collections/CollectionDecorator.cs | 5 +- .../Collections/CollectionExtensions.cs | 5 +- .../Collections/ConcatenatingDictionary.cs | 3 +- .../Collections/ConditionalWeakTableSlow.cs | 3 +- .../Collections/DictionaryExtensions.cs | 27 +- .../DictionnaryCompositeDisposabe.cs | 3 +- .../EnumerableExtensions.GroupBy.cs | 5 +- .../EnumerableExtensions.Specialized.cs | 3 +- .../Collections/EnumerableExtensions.cs | 3 +- .../Collections/GroupingExtensions.cs | 5 +- src/Uno.Core/Collections/ImmutableList.cs | 3 +- src/Uno.Core/Collections/LazyList.cs | 5 +- src/Uno.Core/Collections/ListAdapter.cs | 5 +- src/Uno.Core/Collections/ListDecorator.cs | 5 +- src/Uno.Core/Collections/ListExtensions.cs | 5 +- src/Uno.Core/Collections/MemoryExtensions.cs | 3 +- .../ObservableCollectionExtensions.Update.cs | 3 +- .../ObservableCollectionUpdateResults.cs | 3 +- src/Uno.Core/Collections/QueueExtensions.cs | 5 +- src/Uno.Core/Collections/StackExtensions.cs | 5 +- .../Collections/SynchronizedDictionary.cs | 5 +- .../UnsafeWeakAttachedDictionary.cs | 3 +- .../Collections/WeakAttachedDictionary.cs | 3 +- src/Uno.Core/Comparison/FastTypeComparer.cs | 3 +- src/Uno.Core/Comparison/FuncComparer.cs | 5 +- src/Uno.Core/CompositionType.cs | 21 +- .../Conversion/ConversionExtensionPoint.cs | 5 +- .../Conversion/ConversionExtensions.cs | 5 +- .../Conversion/CustomConversionStrategy.cs | 5 +- .../CustomCulturelessConversionStrategy.cs | 5 +- .../Conversion/DefaultConversionExtensions.cs | 5 +- .../Conversion/EnumConversionStrategy.cs | 5 +- .../Conversion/IConversionExtensions.cs | 5 +- .../Conversion/IConversionStrategy.cs | 5 +- .../Conversion/PrimitiveConversionStrategy.cs | 3 +- .../TypeConverterConversionStrategy.cs | 3 +- src/Uno.Core/DataStatus.cs | 41 +- src/Uno.Core/DateTimeUnit.cs | 39 +- src/Uno.Core/Decorator/Decorator.cs | 5 +- src/Uno.Core/Decorator/IDecorator.cs | 5 +- src/Uno.Core/DelegateConditionalWeakTable.cs | 3 +- src/Uno.Core/DisposableAction.cs | 31 +- .../DisposableConditionalWeakTable.cs | 3 +- .../Disposables/AnonymousDisposable.cs | 5 +- .../Disposables/CancellationDisposable.cs | 5 +- .../Disposables/CompositeDisposable.cs | 5 +- .../CompositeDisposableExtensions.cs | 3 +- .../Disposables/ConditionalDisposable.cs | 3 +- src/Uno.Core/Disposables/DefaultDisposable.cs | 3 +- src/Uno.Core/Disposables/Disposable.cs | 3 +- .../Disposables/DisposableExtensions.cs | 3 +- src/Uno.Core/Disposables/ICancelable.cs | 3 +- .../Disposables/IExtensibleDisposable.cs | 3 +- src/Uno.Core/Disposables/SerialDisposable.cs | 5 +- src/Uno.Core/EnumUtilities.cs | 7 +- .../Equality/CollectionEqualityComparer.cs | 3 +- .../Equality/EqualityComparerExtensions.cs | 3 +- .../Equality/EqualityExtensionPoint.cs | 5 +- src/Uno.Core/Equality/EqualityExtensions.cs | 3 +- src/Uno.Core/Equality/FuncEqualityComparer.cs | 5 +- src/Uno.Core/Equality/IKeyEquatable.cs | 3 +- src/Uno.Core/Equality/KeyEqualityComparer.cs | 3 +- .../Equality/WeakReferenceEqualityComparer.cs | 5 +- src/Uno.Core/Events/EventHandlerConverter.cs | 3 +- .../Expressions/Builder/IPredicateBuilder.cs | 15 +- .../Expressions/EditableBinaryExpression.cs | 51 +- .../EditableConditionalExpression.cs | 57 ++- .../Expressions/EditableConstantExpression.cs | 31 +- .../Expressions/EditableElementInit.cs | 41 +- .../Expressions/EditableExpression.cs | 199 ++++---- .../EditableExpressionCollection.cs | 49 +- .../EditableExpressionExtensions.cs | 247 ++++----- .../EditableInvocationExpression.cs | 51 +- .../EditableLambdaExpression.Generic.cs | 65 +-- .../Expressions/EditableLambdaExpression.cs | 65 +-- .../Expressions/EditableListInitExpression.cs | 67 +-- .../Expressions/EditableMemberExpression.cs | 43 +- .../EditableMemberInitExpression.cs | 51 +- .../EditableMethodCallExpression.cs | 81 +-- .../Expressions/EditableNewArrayExpression.cs | 103 ++-- .../Expressions/EditableNewExpression.cs | 51 +- .../EditableParameterExpression.cs | 47 +- .../EditableParameterExpressionCollection.cs | 83 +-- .../EditableTypeBinaryExpression.cs | 43 +- .../Expressions/EditableUnaryExpression.cs | 43 +- .../Expressions/ExpressionExtensions.cs | 273 +++++----- src/Uno.Core/Expressions/ExpressionFactory.cs | 27 +- src/Uno.Core/Expressions/Expressions.cs | 15 +- .../Expressions/IEditableExpression.cs | 23 +- .../PredicateExpression.Generic.cs | 119 ++--- .../Expressions/PredicateExpression.cs | 119 ++--- .../Extensibility/ExtensibilityModel.cs | 3 +- .../Extensions/ActionAsyncExtensions.cs | 7 +- src/Uno.Core/Extensions/ActionExtensions.cs | 14 +- .../Extensions/ComparableExtensions.cs | 169 ++++--- src/Uno.Core/Extensions/CurryExtensions.cs | 3 +- src/Uno.Core/Extensions/DateTimeExtensions.cs | 125 ++--- src/Uno.Core/Extensions/DoubleExtensions.cs | 3 +- src/Uno.Core/Extensions/EnumExtensions.cs | 7 +- .../Extensions/ExceptionExtensions.cs | 3 +- src/Uno.Core/Extensions/ExtensionPoint.cs | 75 +-- src/Uno.Core/Extensions/ExtensionsProvider.cs | 31 +- .../Extensions/FormattableExtensions.cs | 3 +- .../Extensions/FuncAsyncExtensions.cs | 5 +- .../FuncExtensions.ApplyMemoized.cs | 5 +- .../Extensions/FuncExtensions.AsyncRetry.cs | 5 +- src/Uno.Core/Extensions/FuncExtensions.cs | 125 ++--- .../Extensions/FuncMemoizeExtensions.cs | 3 +- .../Extensions/IExtensionPoint.Generic.cs | 13 +- src/Uno.Core/Extensions/IExtensionPoint.cs | 15 +- .../Extensions/IIndentedStringBuilder.cs | 5 +- .../Extensions/IndentedStringBuilder.cs | 3 +- .../IndentedStringBuilderExtensions.cs | 7 +- .../Extensions/InvocationLockingMode.cs | 5 +- src/Uno.Core/Extensions/NullableExtensions.cs | 3 +- src/Uno.Core/Extensions/ObjectExtensions.cs | 281 ++++++----- .../Extensions/StorageFolderExtensions.cs | 5 +- src/Uno.Core/Extensions/StreamExtensions.cs | 1 + .../Extensions/StringBuilderExtensions.cs | 5 +- .../Extensions/StringExtensions.Format.cs | 1 + src/Uno.Core/Extensions/StringExtensions.cs | 8 +- .../Extensions/TextWriterExtensions.cs | 23 +- src/Uno.Core/Extensions/UriExtensions.cs | 3 +- .../Extensions/ValueType/ByteSupport.cs | 65 +-- .../Extensions/ValueType/EnumSupport.cs | 69 +-- .../ValueType/IValueSupport.Generic.cs | 29 +- .../Extensions/ValueType/IValueSupport.cs | 29 +- .../Extensions/ValueType/Int32Support.cs | 52 +- .../ValueType/ValueSupport.Generic.cs | 206 +++----- .../Extensions/ValueType/ValueSupport.cs | 75 +-- .../ValueType/ValueSupportExtensions.cs | 88 +--- .../Extensions/WeakReferenceExtensions.cs | 5 +- src/Uno.Core/FallbackValueAttribute.cs | 3 +- src/Uno.Core/Fields.cs | 23 +- src/Uno.Core/FuncAsync.cs | 3 +- src/Uno.Core/Funcs.cs | 5 +- src/Uno.Core/Grouping.cs | 3 +- src/Uno.Core/I.cs | 11 +- src/Uno.Core/IIdentifiable.cs | 14 +- src/Uno.Core/IInitializable.cs | 6 +- src/Uno.Core/IInvalidatable.cs | 14 +- src/Uno.Core/ILoadable.cs | 15 +- src/Uno.Core/IServiceLocatorProvider.cs | 11 +- src/Uno.Core/IUpdatable.cs | 9 +- src/Uno.Core/Instance.cs | 27 +- .../InternalsWriteableFromAttribute.cs | 3 +- src/Uno.Core/Key.cs | 81 +-- src/Uno.Core/Lazy.cs | 25 +- src/Uno.Core/LazyBehavior.cs | 17 +- src/Uno.Core/Legacy.cs | 3 +- src/Uno.Core/Localisation/CultureContext.cs | 5 +- src/Uno.Core/Logging/LogExtensionPoint.cs | 17 +- .../Logging/LogExtensions.Conditional.cs | 149 +++--- src/Uno.Core/Logging/LogExtensions.cs | 3 +- src/Uno.Core/NotFoundException.cs | 81 +-- src/Uno.Core/Null.cs | 29 +- src/Uno.Core/NullDisposable.cs | 53 +- .../ObjectReferenceEqualityComparer.cs | 3 +- src/Uno.Core/Options/None.cs | 5 +- src/Uno.Core/Options/Option.cs | 3 +- .../Options/OptionEqualityComparer.cs | 3 +- src/Uno.Core/Options/OptionExtensions.cs | 5 +- src/Uno.Core/Options/OptionType.cs | 5 +- src/Uno.Core/Options/Some.cs | 5 +- src/Uno.Core/Pair.cs | 171 +++---- src/Uno.Core/Params.cs | 19 +- src/Uno.Core/Predicates.Generic.cs | 7 +- src/Uno.Core/Predicates.cs | 5 +- src/Uno.Core/ReadOnlyException.cs | 83 +-- src/Uno.Core/Reflection/AssemblyExtensions.cs | 19 +- src/Uno.Core/Reflection/BindingBehavior.cs | 19 +- .../Reflection/BindingContract.Metro.cs | 77 +-- src/Uno.Core/Reflection/BindingContract.cs | 93 ++-- .../Reflection/DefaultReflectionExtensions.cs | 359 ++++++------- src/Uno.Core/Reflection/EventDescriptor.cs | 71 +-- src/Uno.Core/Reflection/FieldDescriptor.cs | 123 ++--- src/Uno.Core/Reflection/IContract.cs | 11 +- src/Uno.Core/Reflection/IEventDescriptor.cs | 15 +- src/Uno.Core/Reflection/IMemberDescriptor.cs | 29 +- src/Uno.Core/Reflection/IMethodDescriptor.cs | 47 +- .../Reflection/IReflectionExtensionPoint.cs | 17 +- .../Reflection/IReflectionExtensions.cs | 69 +-- .../Reflection/IValueMemberDescriptor.cs | 79 +-- src/Uno.Core/Reflection/MemberDescriptor.cs | 103 ++-- .../Reflection/MemberDescriptorExtensions.cs | 25 +- .../Reflection/NestedTypeDescriptor.cs | 115 ++--- src/Uno.Core/Reflection/PropertyDescriptor.cs | 83 +-- .../Reflection/ReflectionExtensionPoint.cs | 27 +- .../Reflection/ReflectionExtensions.cs | 339 ++++++------- src/Uno.Core/Reflection/TypeDescriptor.cs | 81 +-- src/Uno.Core/Reflection/TypeExtensions.cs | 477 +++++++++--------- .../Reflection/TypeInfoExtensions.Metro.cs | 135 ++--- .../Reflection/ValueMemberDescriptor.cs | 73 +-- .../RegularExpressions/MatchExtensions.cs | 41 +- .../Resources/EmbeddedResourceFactory.cs | 3 +- src/Uno.Core/Runtime.cs | 3 +- .../SerializationExtensionPoint.cs | 27 +- .../Serialization/SerializationExtensions.cs | 185 +++---- .../ServiceLocatorProviderExtensions.cs | 19 +- src/Uno.Core/Threading/AsyncEvent.cs | 3 +- src/Uno.Core/Threading/AsyncLock.cs | 37 +- src/Uno.Core/Threading/FastAsyncLock.cs | 5 +- .../Threading/FastTaskCompletionSource.cs | 5 +- .../Threading/ISynchronizable.Generic.cs | 13 +- src/Uno.Core/Threading/ISynchronizableLock.cs | 21 +- src/Uno.Core/Threading/Synchronizable.cs | 29 +- .../Threading/SynchronizableExtensions.cs | 81 +-- .../Threading/SynchronizableLock.Phone.cs | 99 ++-- src/Uno.Core/Threading/SynchronizableLock.cs | 262 +++++----- .../Threading/ThreadLocalSource.Phone.cs | 3 +- src/Uno.Core/Transactional.Immutables.cs | 3 +- src/Uno.Core/Transactional.cs | 3 +- src/Uno.Core/Tuple.CompileTimeValidation.cs | 9 +- src/Uno.Core/UnavailableResourceException.cs | 3 +- .../Validation/StringValidationExtensions.cs | 3 +- .../Validation/ValidationExtensionPoint.cs | 19 +- .../Validation/ValidationExtensions.cs | 59 +-- src/Uno.Core/Validation/ValidationHelper.cs | 3 +- src/Uno.Core/WeakReference.cs | 56 +- src/Uno.Core/WebRequestCreate.cs | 5 +- 283 files changed, 4522 insertions(+), 4348 deletions(-) create mode 100644 src/Uno.Core.Build/Uno - Backup.Core.Build.csproj diff --git a/build/header.txt b/build/header.txt index cceb789..c07642d 100644 --- a/build/header.txt +++ b/build/header.txt @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright 2015-2018 nventive inc. All rights reserved. +// Copyright 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,4 +13,4 @@ // See the License for the specific language governing permissions and // limitations under the License. // -// ****************************************************************** \ No newline at end of file +// ****************************************************************** diff --git a/src/Uno.Core.Build/Uno - Backup.Core.Build.csproj b/src/Uno.Core.Build/Uno - Backup.Core.Build.csproj new file mode 100644 index 0000000..4f25ba7 --- /dev/null +++ b/src/Uno.Core.Build/Uno - Backup.Core.Build.csproj @@ -0,0 +1,85 @@ + + + net46 + $(AssemblyName) ($(TargetFramework)) + $(NoWarn);1998;1591;1573;1572;1574;1712;1711;1570;NU5128;NU5105 + + false + true + True + + full + True + false + + + + nventive + https://github.com/nventive/Uno.Core + https://nv-assets.azurewebsites.net/logos/uno.png + https://github.com/nventive/Uno.Core + A package that includes Uno.Core as a dependency for build tasks and Uno.SourceGeneration binaries. + Copyright (C) 2015-2020 nventive inc. - all rights reserved + + + + + + + + + true + build + + + true + build + + + true + build + + + true + build + + + + + + 15.1.1012 + runtime + all + + + 15.1.1012 + runtime + all + + + 15.1.1012 + runtime + all + + + 15.1.1012 + runtime + all + + + all + runtime; build; native; contentfiles; analyzers + + + + + + + + + + + \ No newline at end of file diff --git a/src/Uno.Core.Build/Uno.Core.Build.csproj b/src/Uno.Core.Build/Uno.Core.Build.csproj index b24c4bf..4f25ba7 100644 --- a/src/Uno.Core.Build/Uno.Core.Build.csproj +++ b/src/Uno.Core.Build/Uno.Core.Build.csproj @@ -19,7 +19,7 @@ https://nv-assets.azurewebsites.net/logos/uno.png https://github.com/nventive/Uno.Core A package that includes Uno.Core as a dependency for build tasks and Uno.SourceGeneration binaries. - Copyright (C) 2015-2018 nventive inc. - all rights reserved + Copyright (C) 2015-2020 nventive inc. - all rights reserved diff --git a/src/Uno.Core.Tests/Collections/ImmutableListFixture.cs b/src/Uno.Core.Tests/Collections/ImmutableListFixture.cs index 738b9c7..e191e32 100644 --- a/src/Uno.Core.Tests/Collections/ImmutableListFixture.cs +++ b/src/Uno.Core.Tests/Collections/ImmutableListFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Linq; using FluentAssertions; diff --git a/src/Uno.Core.Tests/Collections/ListExtensionsFixture.cs b/src/Uno.Core.Tests/Collections/ListExtensionsFixture.cs index e87d233..5153307 100644 --- a/src/Uno.Core.Tests/Collections/ListExtensionsFixture.cs +++ b/src/Uno.Core.Tests/Collections/ListExtensionsFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections; using System.Collections.Generic; diff --git a/src/Uno.Core.Tests/Collections/ObservableCollectionExtensionsFixture.cs b/src/Uno.Core.Tests/Collections/ObservableCollectionExtensionsFixture.cs index 21eb80b..5bde984 100644 --- a/src/Uno.Core.Tests/Collections/ObservableCollectionExtensionsFixture.cs +++ b/src/Uno.Core.Tests/Collections/ObservableCollectionExtensionsFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/src/Uno.Core.Tests/Collections/SpanExtensionsFixture.cs b/src/Uno.Core.Tests/Collections/SpanExtensionsFixture.cs index 862f0fb..d59a662 100644 --- a/src/Uno.Core.Tests/Collections/SpanExtensionsFixture.cs +++ b/src/Uno.Core.Tests/Collections/SpanExtensionsFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; @@ -25,7 +26,7 @@ namespace Uno.Core.Tests.Collections { [TestClass] - public class SpanExtensionsFixture + public class SpanExtensionsFixture { [TestMethod] public void When_SelectToSpan() diff --git a/src/Uno.Core.Tests/Conversions/ConversionExtensionsFixture.cs b/src/Uno.Core.Tests/Conversions/ConversionExtensionsFixture.cs index 4e62513..f246fce 100644 --- a/src/Uno.Core.Tests/Conversions/ConversionExtensionsFixture.cs +++ b/src/Uno.Core.Tests/Conversions/ConversionExtensionsFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using CommonServiceLocator; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/src/Uno.Core.Tests/Conversions/CustomConversionStrategyFixture.cs b/src/Uno.Core.Tests/Conversions/CustomConversionStrategyFixture.cs index d933104..920187a 100644 --- a/src/Uno.Core.Tests/Conversions/CustomConversionStrategyFixture.cs +++ b/src/Uno.Core.Tests/Conversions/CustomConversionStrategyFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using CommonServiceLocator; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/src/Uno.Core.Tests/Conversions/DefaultConversionsExtensionsFixture.cs b/src/Uno.Core.Tests/Conversions/DefaultConversionsExtensionsFixture.cs index 5b1691a..f6edd52 100644 --- a/src/Uno.Core.Tests/Conversions/DefaultConversionsExtensionsFixture.cs +++ b/src/Uno.Core.Tests/Conversions/DefaultConversionsExtensionsFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Globalization; using CommonServiceLocator; diff --git a/src/Uno.Core.Tests/Conversions/EnumConversionStrategyFixture.cs b/src/Uno.Core.Tests/Conversions/EnumConversionStrategyFixture.cs index 1eb311f..4a02e34 100644 --- a/src/Uno.Core.Tests/Conversions/EnumConversionStrategyFixture.cs +++ b/src/Uno.Core.Tests/Conversions/EnumConversionStrategyFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using CommonServiceLocator; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/src/Uno.Core.Tests/Conversions/FunqAdapter.cs b/src/Uno.Core.Tests/Conversions/FunqAdapter.cs index f8b6f6b..1716e5d 100644 --- a/src/Uno.Core.Tests/Conversions/FunqAdapter.cs +++ b/src/Uno.Core.Tests/Conversions/FunqAdapter.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using Funq; diff --git a/src/Uno.Core.Tests/Conversions/TypeConverterConversionStrategyFixture.cs b/src/Uno.Core.Tests/Conversions/TypeConverterConversionStrategyFixture.cs index 41451d6..cb572ea 100644 --- a/src/Uno.Core.Tests/Conversions/TypeConverterConversionStrategyFixture.cs +++ b/src/Uno.Core.Tests/Conversions/TypeConverterConversionStrategyFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using CommonServiceLocator; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/src/Uno.Core.Tests/DelegateConditionalWeakTableFixture.cs b/src/Uno.Core.Tests/DelegateConditionalWeakTableFixture.cs index 1d2474e..6c0f513 100644 --- a/src/Uno.Core.Tests/DelegateConditionalWeakTableFixture.cs +++ b/src/Uno.Core.Tests/DelegateConditionalWeakTableFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Collections.Immutable; diff --git a/src/Uno.Core.Tests/DisposableConditionalWeakTableFixture.cs b/src/Uno.Core.Tests/DisposableConditionalWeakTableFixture.cs index d5f0294..f7f3662 100644 --- a/src/Uno.Core.Tests/DisposableConditionalWeakTableFixture.cs +++ b/src/Uno.Core.Tests/DisposableConditionalWeakTableFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core.Tests/Equality/EqualityComparerExtensionsFixture.cs b/src/Uno.Core.Tests/Equality/EqualityComparerExtensionsFixture.cs index 37f46e6..a2fa718 100644 --- a/src/Uno.Core.Tests/Equality/EqualityComparerExtensionsFixture.cs +++ b/src/Uno.Core.Tests/Equality/EqualityComparerExtensionsFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections; using System.Collections.Generic; diff --git a/src/Uno.Core.Tests/Equality/KeyEqualityComparerFixture.cs b/src/Uno.Core.Tests/Equality/KeyEqualityComparerFixture.cs index f9ddcc2..9ef9c25 100644 --- a/src/Uno.Core.Tests/Equality/KeyEqualityComparerFixture.cs +++ b/src/Uno.Core.Tests/Equality/KeyEqualityComparerFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; using Uno.Equality; diff --git a/src/Uno.Core.Tests/Extensions/CollectionExtensionsFixture.DisposableAdd.cs b/src/Uno.Core.Tests/Extensions/CollectionExtensionsFixture.DisposableAdd.cs index 84fc266..9378545 100644 --- a/src/Uno.Core.Tests/Extensions/CollectionExtensionsFixture.DisposableAdd.cs +++ b/src/Uno.Core.Tests/Extensions/CollectionExtensionsFixture.DisposableAdd.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core.Tests/Extensions/CollectionExtensions_RangeArray_Fixture.cs b/src/Uno.Core.Tests/Extensions/CollectionExtensions_RangeArray_Fixture.cs index f34111b..b95a1e6 100644 --- a/src/Uno.Core.Tests/Extensions/CollectionExtensions_RangeArray_Fixture.cs +++ b/src/Uno.Core.Tests/Extensions/CollectionExtensions_RangeArray_Fixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; diff --git a/src/Uno.Core.Tests/Extensions/CollectionExtensions_RangeList_Fixture.cs b/src/Uno.Core.Tests/Extensions/CollectionExtensions_RangeList_Fixture.cs index 83e9a37..5318b01 100644 --- a/src/Uno.Core.Tests/Extensions/CollectionExtensions_RangeList_Fixture.cs +++ b/src/Uno.Core.Tests/Extensions/CollectionExtensions_RangeList_Fixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; diff --git a/src/Uno.Core.Tests/Extensions/DateTimeExtensionsFixture.cs b/src/Uno.Core.Tests/Extensions/DateTimeExtensionsFixture.cs index 40678af..0f830f2 100644 --- a/src/Uno.Core.Tests/Extensions/DateTimeExtensionsFixture.cs +++ b/src/Uno.Core.Tests/Extensions/DateTimeExtensionsFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using Uno.Extensions; diff --git a/src/Uno.Core.Tests/Extensions/EnumerableExtensions.FullOuterJoin.cs b/src/Uno.Core.Tests/Extensions/EnumerableExtensions.FullOuterJoin.cs index 2128563..47ab380 100644 --- a/src/Uno.Core.Tests/Extensions/EnumerableExtensions.FullOuterJoin.cs +++ b/src/Uno.Core.Tests/Extensions/EnumerableExtensions.FullOuterJoin.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core.Tests/Extensions/EnumerableExtensions.SkipLast.cs b/src/Uno.Core.Tests/Extensions/EnumerableExtensions.SkipLast.cs index f381d01..5e469e1 100644 --- a/src/Uno.Core.Tests/Extensions/EnumerableExtensions.SkipLast.cs +++ b/src/Uno.Core.Tests/Extensions/EnumerableExtensions.SkipLast.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core.Tests/Extensions/ExceptionExtensionsFixture.cs b/src/Uno.Core.Tests/Extensions/ExceptionExtensionsFixture.cs index 2ba0f82..9783cb0 100644 --- a/src/Uno.Core.Tests/Extensions/ExceptionExtensionsFixture.cs +++ b/src/Uno.Core.Tests/Extensions/ExceptionExtensionsFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using Uno.Extensions; diff --git a/src/Uno.Core.Tests/Extensions/FormattableExtensionsFixture.cs b/src/Uno.Core.Tests/Extensions/FormattableExtensionsFixture.cs index 211ff1e..02a0e12 100644 --- a/src/Uno.Core.Tests/Extensions/FormattableExtensionsFixture.cs +++ b/src/Uno.Core.Tests/Extensions/FormattableExtensionsFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using Microsoft.VisualStudio.TestTools.UnitTesting; using Uno.Extensions; diff --git a/src/Uno.Core.Tests/Extensions/FuncExtensions.ApplyMemoize.cs b/src/Uno.Core.Tests/Extensions/FuncExtensions.ApplyMemoize.cs index dec4d16..3b53a10 100644 --- a/src/Uno.Core.Tests/Extensions/FuncExtensions.ApplyMemoize.cs +++ b/src/Uno.Core.Tests/Extensions/FuncExtensions.ApplyMemoize.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using Uno.Extensions; diff --git a/src/Uno.Core.Tests/Extensions/ObjectExtensionsFixture.cs b/src/Uno.Core.Tests/Extensions/ObjectExtensionsFixture.cs index 040a881..779cac5 100644 --- a/src/Uno.Core.Tests/Extensions/ObjectExtensionsFixture.cs +++ b/src/Uno.Core.Tests/Extensions/ObjectExtensionsFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using Microsoft.VisualStudio.TestTools.UnitTesting; using Uno.Extensions; diff --git a/src/Uno.Core.Tests/Extensions/StreamExtensionsFixture.cs b/src/Uno.Core.Tests/Extensions/StreamExtensionsFixture.cs index 8f57800..e2d4885 100644 --- a/src/Uno.Core.Tests/Extensions/StreamExtensionsFixture.cs +++ b/src/Uno.Core.Tests/Extensions/StreamExtensionsFixture.cs @@ -1,4 +1,21 @@ -using System; +// ****************************************************************** +// Copyright � 2015-2020 nventive inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ****************************************************************** + +using System; using System.IO; using System.Linq; using System.Threading.Tasks; diff --git a/src/Uno.Core.Tests/Extensions/Transactional.ImmutableDictionary.cs b/src/Uno.Core.Tests/Extensions/Transactional.ImmutableDictionary.cs index a33b146..4790dc5 100644 --- a/src/Uno.Core.Tests/Extensions/Transactional.ImmutableDictionary.cs +++ b/src/Uno.Core.Tests/Extensions/Transactional.ImmutableDictionary.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Immutable; using FluentAssertions; diff --git a/src/Uno.Core.Tests/Extensions/Transactional.ImmutableQueue.cs b/src/Uno.Core.Tests/Extensions/Transactional.ImmutableQueue.cs index 050c3df..d04e021 100644 --- a/src/Uno.Core.Tests/Extensions/Transactional.ImmutableQueue.cs +++ b/src/Uno.Core.Tests/Extensions/Transactional.ImmutableQueue.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Immutable; using System.Linq; diff --git a/src/Uno.Core.Tests/Extensions/Transactional.Update.cs b/src/Uno.Core.Tests/Extensions/Transactional.Update.cs index 85142a0..7b99d0a 100644 --- a/src/Uno.Core.Tests/Extensions/Transactional.Update.cs +++ b/src/Uno.Core.Tests/Extensions/Transactional.Update.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Immutable; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/src/Uno.Core.Tests/Extensions/ValueType/ValueSupportFixture.cs b/src/Uno.Core.Tests/Extensions/ValueType/ValueSupportFixture.cs index 209fceb..bc8498d 100644 --- a/src/Uno.Core.Tests/Extensions/ValueType/ValueSupportFixture.cs +++ b/src/Uno.Core.Tests/Extensions/ValueType/ValueSupportFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System.Reflection; using Microsoft.VisualStudio.TestTools.UnitTesting; using Uno.Extensions.ValueType; diff --git a/src/Uno.Core.Tests/FuncsFixture.cs b/src/Uno.Core.Tests/FuncsFixture.cs index d1e447b..6d35367 100644 --- a/src/Uno.Core.Tests/FuncsFixture.cs +++ b/src/Uno.Core.Tests/FuncsFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Threading; using System.Threading.Tasks; @@ -50,4 +51,4 @@ public async Task When_AsLockedMemoized_ThenSameInstance() Assert.IsTrue(object.ReferenceEquals(a.Result, b.Result)); } } -} \ No newline at end of file +} diff --git a/src/Uno.Core.Tests/Given_Predicates.cs b/src/Uno.Core.Tests/Given_Predicates.cs index 8ab15b9..cf87651 100644 --- a/src/Uno.Core.Tests/Given_Predicates.cs +++ b/src/Uno.Core.Tests/Given_Predicates.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core.Tests/LoggerFixture.cs b/src/Uno.Core.Tests/LoggerFixture.cs index e8c305e..ad70bcd 100644 --- a/src/Uno.Core.Tests/LoggerFixture.cs +++ b/src/Uno.Core.Tests/LoggerFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -49,4 +50,4 @@ public void TestDebug() this.Log().Debug("Test logging"); } } -} \ No newline at end of file +} diff --git a/src/Uno.Core.Tests/Options/OptionEqualityComparerFixture.cs b/src/Uno.Core.Tests/Options/OptionEqualityComparerFixture.cs index 300944c..d40a2c4 100644 --- a/src/Uno.Core.Tests/Options/OptionEqualityComparerFixture.cs +++ b/src/Uno.Core.Tests/Options/OptionEqualityComparerFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/src/Uno.Core.Tests/Properties/AssemblyInfo.cs b/src/Uno.Core.Tests/Properties/AssemblyInfo.cs index 66f14ae..71938a9 100644 --- a/src/Uno.Core.Tests/Properties/AssemblyInfo.cs +++ b/src/Uno.Core.Tests/Properties/AssemblyInfo.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/Uno.Core.Tests/Reflection/TypeExtensionsFixture.cs b/src/Uno.Core.Tests/Reflection/TypeExtensionsFixture.cs index c00db03..d8de2a0 100644 --- a/src/Uno.Core.Tests/Reflection/TypeExtensionsFixture.cs +++ b/src/Uno.Core.Tests/Reflection/TypeExtensionsFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; diff --git a/src/Uno.Core.Tests/Threading/AsyncLockFixture.cs b/src/Uno.Core.Tests/Threading/AsyncLockFixture.cs index 27368ee..2ea22a1 100644 --- a/src/Uno.Core.Tests/Threading/AsyncLockFixture.cs +++ b/src/Uno.Core.Tests/Threading/AsyncLockFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -39,8 +40,8 @@ public class AsyncLockFixture [TestMethod] [Timeout(_timeout)] - [Ignore] // https://github.com/nventive/Uno.Core/issues/48 - public async Task TestUnlockReleaseNextSynchronously() + [Ignore] // https://github.com/nventive/Uno.Core/issues/48 + public async Task TestUnlockReleaseNextSynchronously() { Console.WriteLine($"Running on thread {Thread.CurrentThread.ManagedThreadId}"); diff --git a/src/Uno.Core.Tests/Threading/FastTaskCompletionSourceFixture.cs b/src/Uno.Core.Tests/Threading/FastTaskCompletionSourceFixture.cs index 0e0fc7c..87571b6 100644 --- a/src/Uno.Core.Tests/Threading/FastTaskCompletionSourceFixture.cs +++ b/src/Uno.Core.Tests/Threading/FastTaskCompletionSourceFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Runtime.ExceptionServices; using System.Threading; diff --git a/src/Uno.Core.Tests/TransactionalFixture.ImmutableDictionary.cs b/src/Uno.Core.Tests/TransactionalFixture.ImmutableDictionary.cs index a32e598..37865e0 100644 --- a/src/Uno.Core.Tests/TransactionalFixture.ImmutableDictionary.cs +++ b/src/Uno.Core.Tests/TransactionalFixture.ImmutableDictionary.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Collections.Immutable; diff --git a/src/Uno.Core.Tests/TransactionalFixture.ImmutableList.cs b/src/Uno.Core.Tests/TransactionalFixture.ImmutableList.cs index 73ff19e..986a064 100644 --- a/src/Uno.Core.Tests/TransactionalFixture.ImmutableList.cs +++ b/src/Uno.Core.Tests/TransactionalFixture.ImmutableList.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Collections.Immutable; diff --git a/src/Uno.Core.Tests/TransactionalFixture.cs b/src/Uno.Core.Tests/TransactionalFixture.cs index 44a42ca..ea9389b 100644 --- a/src/Uno.Core.Tests/TransactionalFixture.cs +++ b/src/Uno.Core.Tests/TransactionalFixture.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core.Tests/_TestUtils/AsyncTestContext.cs b/src/Uno.Core.Tests/_TestUtils/AsyncTestContext.cs index 34ee27d..c9c056d 100644 --- a/src/Uno.Core.Tests/_TestUtils/AsyncTestContext.cs +++ b/src/Uno.Core.Tests/_TestUtils/AsyncTestContext.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Linq; using System.Threading; @@ -51,4 +52,4 @@ public void Validate() Assert.AreEqual(this, _context.Value); } } -} \ No newline at end of file +} diff --git a/src/Uno.Core.Tests/_TestUtils/AsyncTestRunner.cs b/src/Uno.Core.Tests/_TestUtils/AsyncTestRunner.cs index 767a907..f4eb436 100644 --- a/src/Uno.Core.Tests/_TestUtils/AsyncTestRunner.cs +++ b/src/Uno.Core.Tests/_TestUtils/AsyncTestRunner.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -352,4 +353,4 @@ public SyncFlag(int position) public void Canceled() => _task.TrySetCanceled(); } } -} \ No newline at end of file +} diff --git a/src/Uno.Core.Tests/_TestUtils/SchedulerExtensions.cs b/src/Uno.Core.Tests/_TestUtils/SchedulerExtensions.cs index 88a8356..2227bd4 100644 --- a/src/Uno.Core.Tests/_TestUtils/SchedulerExtensions.cs +++ b/src/Uno.Core.Tests/_TestUtils/SchedulerExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Linq; using System.Reactive; diff --git a/src/Uno.Core.sln b/src/Uno.Core.sln index 9be4532..e4a6c18 100644 --- a/src/Uno.Core.sln +++ b/src/Uno.Core.sln @@ -1,14 +1,22 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27009.1 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30709.64 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Uno.Core.Tests", "Uno.Core.Tests\Uno.Core.Tests.csproj", "{B554D7E4-17FC-4909-BA06-80B5B2FB0BD1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Uno.Core.Tests", "Uno.Core.Tests\Uno.Core.Tests.csproj", "{B554D7E4-17FC-4909-BA06-80B5B2FB0BD1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Uno.Core", "Uno.Core\Uno.Core.csproj", "{ABB4F177-6966-4C24-A465-A5E941A70680}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Uno.Core.Build", "Uno.Core.Build\Uno.Core.Build.csproj", "{E414AC61-1BED-458E-A78C-868514DDA1A2}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{1D12D059-9984-473D-9A9A-2D4FCDC0355E}" + ProjectSection(SolutionItems) = preProject + ..\.azure-pipelines.yml = ..\.azure-pipelines.yml + ..\build\build.ps1 = ..\build\build.ps1 + ..\build\header.txt = ..\build\header.txt + ..\Readme.md = ..\Readme.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/src/Uno.Core/ActionAsync.cs b/src/Uno.Core/ActionAsync.cs index 89c56c0..de74048 100644 --- a/src/Uno.Core/ActionAsync.cs +++ b/src/Uno.Core/ActionAsync.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Text; @@ -22,7 +23,7 @@ namespace Uno { - public delegate Task ActionAsync(CancellationToken ct); + public delegate Task ActionAsync(CancellationToken ct); public delegate Task ActionAsync(CancellationToken ct, T1 value); public delegate Task ActionAsync(CancellationToken ct, T1 t1, T2 t2); public delegate Task ActionAsync(CancellationToken ct, T1 t1, T2 t2, T3 t3); diff --git a/src/Uno.Core/Actions.Generic.cs b/src/Uno.Core/Actions.Generic.cs index 623d5db..7a5d015 100644 --- a/src/Uno.Core/Actions.Generic.cs +++ b/src/Uno.Core/Actions.Generic.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno @@ -47,4 +48,4 @@ public static class Actions /// public static readonly ActionAsync NullAsync = (_, __, ___) => Actions.NullTask; } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Actions.cs b/src/Uno.Core/Actions.cs index fd31d5f..667ad8c 100644 --- a/src/Uno.Core/Actions.cs +++ b/src/Uno.Core/Actions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Threading; using System.Threading.Tasks; @@ -23,60 +24,60 @@ namespace Uno { - public static class Actions - { - /// - /// An action which does nothing. - /// - public static readonly Action Null = () => { }; + public static class Actions + { + /// + /// An action which does nothing. + /// + public static readonly Action Null = () => { }; - /// - /// An ActionAsync which does nothing. - /// - public static readonly ActionAsync NullAsync = _ => NullTask; - internal static readonly Task NullTask = _Task.FromResult(true); + /// + /// An ActionAsync which does nothing. + /// + public static readonly ActionAsync NullAsync = _ => NullTask; + internal static readonly Task NullTask = _Task.FromResult(true); - public static Action Create(Action action) - { - return action; - } + public static Action Create(Action action) + { + return action; + } - public static ActionAsync CreateAsync(ActionAsync action) - { - return action; - } + public static ActionAsync CreateAsync(ActionAsync action) + { + return action; + } - public static Action Create(Action action) - { - return action; - } + public static Action Create(Action action) + { + return action; + } - public static ActionAsync CreateAsync(ActionAsync action) - { - return action; - } + public static ActionAsync CreateAsync(ActionAsync action) + { + return action; + } - /// - /// Creates an action that will only execute once the provided action, even if called multiple times. This is Thread Safe. - /// - /// The action to be executed once - /// An action. - public static Action CreateOnce(Action action) - { - var once = 0; + /// + /// Creates an action that will only execute once the provided action, even if called multiple times. This is Thread Safe. + /// + /// The action to be executed once + /// An action. + public static Action CreateOnce(Action action) + { + var once = 0; - return () => - { - if (Interlocked.Exchange(ref once, 1) == 0) - { - action(); - } - }; - } + return () => + { + if (Interlocked.Exchange(ref once, 1) == 0) + { + action(); + } + }; + } - public static IDisposable ToDisposable(Action action) - { - return action.ToDisposable(); - } - } -} \ No newline at end of file + public static IDisposable ToDisposable(Action action) + { + return action.ToDisposable(); + } + } +} diff --git a/src/Uno.Core/Async/ActionService.cs b/src/Uno.Core/Async/ActionService.cs index 14e636e..ab33abc 100644 --- a/src/Uno.Core/Async/ActionService.cs +++ b/src/Uno.Core/Async/ActionService.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Async/AsyncResult.cs b/src/Uno.Core/Async/AsyncResult.cs index 8fc5024..9577241 100644 --- a/src/Uno.Core/Async/AsyncResult.cs +++ b/src/Uno.Core/Async/AsyncResult.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Net; diff --git a/src/Uno.Core/Async/AsyncResultDecorator.cs b/src/Uno.Core/Async/AsyncResultDecorator.cs index 715647e..b9fff08 100644 --- a/src/Uno.Core/Async/AsyncResultDecorator.cs +++ b/src/Uno.Core/Async/AsyncResultDecorator.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Async/IActionService.cs b/src/Uno.Core/Async/IActionService.cs index 4536ed1..b3fc013 100644 --- a/src/Uno.Core/Async/IActionService.cs +++ b/src/Uno.Core/Async/IActionService.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Security.Principal; diff --git a/src/Uno.Core/Async/IAsyncService.cs b/src/Uno.Core/Async/IAsyncService.cs index ea68289..2fb77a2 100644 --- a/src/Uno.Core/Async/IAsyncService.cs +++ b/src/Uno.Core/Async/IAsyncService.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Async/SyncService.cs b/src/Uno.Core/Async/SyncService.cs index 402ae3d..1a04d2e 100644 --- a/src/Uno.Core/Async/SyncService.cs +++ b/src/Uno.Core/Async/SyncService.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Async/TaskExtensions.cs b/src/Uno.Core/Async/TaskExtensions.cs index 9963c5a..1215538 100644 --- a/src/Uno.Core/Async/TaskExtensions.cs +++ b/src/Uno.Core/Async/TaskExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Async/TaskUtilities.cs b/src/Uno.Core/Async/TaskUtilities.cs index ba2116b..d797dab 100644 --- a/src/Uno.Core/Async/TaskUtilities.cs +++ b/src/Uno.Core/Async/TaskUtilities.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Builder/BuilderContext.cs b/src/Uno.Core/Builder/BuilderContext.cs index be8c023..2573611 100644 --- a/src/Uno.Core/Builder/BuilderContext.cs +++ b/src/Uno.Core/Builder/BuilderContext.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using Uno.Collections; using System; using System.Collections.Generic; diff --git a/src/Uno.Core/Builder/IBuilder.cs b/src/Uno.Core/Builder/IBuilder.cs index f35ab25..6ee45c2 100644 --- a/src/Uno.Core/Builder/IBuilder.cs +++ b/src/Uno.Core/Builder/IBuilder.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/CachedTuple.cs b/src/Uno.Core/CachedTuple.cs index bc3c32b..586e00f 100644 --- a/src/Uno.Core/CachedTuple.cs +++ b/src/Uno.Core/CachedTuple.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Text; @@ -23,8 +24,8 @@ namespace Uno /// /// A tuple implementation that caches the GetHashCode value for faster lookup performance. /// - public class CachedTuple - { + public class CachedTuple + { /// /// Creates a tuple with two values. /// diff --git a/src/Uno.Core/Cancellable.cs b/src/Uno.Core/Cancellable.cs index 6747dc7..a3cb752 100644 --- a/src/Uno.Core/Cancellable.cs +++ b/src/Uno.Core/Cancellable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Threading; using Uno.Extensions; @@ -30,7 +31,7 @@ public Cancellable(Action onCancel) _onCancel = onCancel.Validation().NotNull("onCancel"); } - public bool IsCancelled { get { return _isCancelled != 0; } } + public bool IsCancelled => _isCancelled != 0; public void Cancel() { diff --git a/src/Uno.Core/Collections/CollectionAdapter.cs b/src/Uno.Core/Collections/CollectionAdapter.cs index 2c7d45c..d86f5d2 100644 --- a/src/Uno.Core/Collections/CollectionAdapter.cs +++ b/src/Uno.Core/Collections/CollectionAdapter.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections; using System.Collections.Generic; @@ -140,4 +141,4 @@ IEnumerator IEnumerable.GetEnumerator() #endregion } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Collections/CollectionDecorator.cs b/src/Uno.Core/Collections/CollectionDecorator.cs index 1976071..f202994 100644 --- a/src/Uno.Core/Collections/CollectionDecorator.cs +++ b/src/Uno.Core/Collections/CollectionDecorator.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System.Collections; using System.Collections.Generic; using Uno.Decorator; @@ -81,4 +82,4 @@ IEnumerator IEnumerable.GetEnumerator() #endregion } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Collections/CollectionExtensions.cs b/src/Uno.Core/Collections/CollectionExtensions.cs index b64b2d5..595b204 100644 --- a/src/Uno.Core/Collections/CollectionExtensions.cs +++ b/src/Uno.Core/Collections/CollectionExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -400,4 +401,4 @@ public static List ToRangeList(this List source, int return output; } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Collections/ConcatenatingDictionary.cs b/src/Uno.Core/Collections/ConcatenatingDictionary.cs index bbe9492..7d7715b 100644 --- a/src/Uno.Core/Collections/ConcatenatingDictionary.cs +++ b/src/Uno.Core/Collections/ConcatenatingDictionary.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Collections/ConditionalWeakTableSlow.cs b/src/Uno.Core/Collections/ConditionalWeakTableSlow.cs index deb2464..ff5e2e4 100644 --- a/src/Uno.Core/Collections/ConditionalWeakTableSlow.cs +++ b/src/Uno.Core/Collections/ConditionalWeakTableSlow.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Collections/DictionaryExtensions.cs b/src/Uno.Core/Collections/DictionaryExtensions.cs index 5e4b4f6..6baf816 100644 --- a/src/Uno.Core/Collections/DictionaryExtensions.cs +++ b/src/Uno.Core/Collections/DictionaryExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -38,8 +39,8 @@ public static TValue FindOrCreate(this IDictionary i } public static TValue FindOrCreate(this SynchronizedDictionary items, TKey key, Func factory) - { - TValue value = default(TValue); + { + TValue value = default(TValue); using (items.Lock.CreateWriterScope()) { @@ -50,21 +51,21 @@ public static TValue FindOrCreate(this SynchronizedDictionary(this ISynchronizable> items, TKey key, Func factory) - { - TValue value = default(TValue); + { + TValue value = default(TValue); - items.Lock.Write(d => d.TryGetValue(key, out value), d => d.Add(key, value = factory())); + items.Lock.Write(d => d.TryGetValue(key, out value), d => d.Add(key, value = factory())); - return value; - } + return value; + } public static KeyValuePair[] ToArrayLocked(this ISynchronizable> items) - { - return items.Lock.Read(d => d.ToArray()); - } + { + return items.Lock.Read(d => d.ToArray()); + } /// /// Gets the value associated with the specified key, or a default value. @@ -129,4 +130,4 @@ public static TValue GetValueOrDefaultAndRemove(this IDictionary> item => item); } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Collections/ImmutableList.cs b/src/Uno.Core/Collections/ImmutableList.cs index 623f5a2..17a62c1 100644 --- a/src/Uno.Core/Collections/ImmutableList.cs +++ b/src/Uno.Core/Collections/ImmutableList.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections; using System.Collections.Generic; diff --git a/src/Uno.Core/Collections/LazyList.cs b/src/Uno.Core/Collections/LazyList.cs index 377f753..abcaf66 100644 --- a/src/Uno.Core/Collections/LazyList.cs +++ b/src/Uno.Core/Collections/LazyList.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; @@ -45,4 +46,4 @@ public override ICollection Target set { base.Target = value; } } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Collections/ListAdapter.cs b/src/Uno.Core/Collections/ListAdapter.cs index 9376815..7cdd635 100644 --- a/src/Uno.Core/Collections/ListAdapter.cs +++ b/src/Uno.Core/Collections/ListAdapter.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; @@ -75,4 +76,4 @@ public U this[int index] #endregion } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Collections/ListDecorator.cs b/src/Uno.Core/Collections/ListDecorator.cs index 2899a73..dc8a6e5 100644 --- a/src/Uno.Core/Collections/ListDecorator.cs +++ b/src/Uno.Core/Collections/ListDecorator.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System.Collections; using System.Collections.Generic; using Uno.Decorator; @@ -61,4 +62,4 @@ public virtual T this[int index] #endregion } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Collections/ListExtensions.cs b/src/Uno.Core/Collections/ListExtensions.cs index 34892c6..9a11062 100644 --- a/src/Uno.Core/Collections/ListExtensions.cs +++ b/src/Uno.Core/Collections/ListExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -324,4 +325,4 @@ public static bool SequenceKeyEqual(this IList first, IList second) return true; } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Collections/MemoryExtensions.cs b/src/Uno.Core/Collections/MemoryExtensions.cs index 550a794..1fc95b3 100644 --- a/src/Uno.Core/Collections/MemoryExtensions.cs +++ b/src/Uno.Core/Collections/MemoryExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Collections/ObservableCollectionExtensions.Update.cs b/src/Uno.Core/Collections/ObservableCollectionExtensions.Update.cs index 72dc45c..aa64ec8 100644 --- a/src/Uno.Core/Collections/ObservableCollectionExtensions.Update.cs +++ b/src/Uno.Core/Collections/ObservableCollectionExtensions.Update.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/src/Uno.Core/Collections/ObservableCollectionUpdateResults.cs b/src/Uno.Core/Collections/ObservableCollectionUpdateResults.cs index 3406890..c730da1 100644 --- a/src/Uno.Core/Collections/ObservableCollectionUpdateResults.cs +++ b/src/Uno.Core/Collections/ObservableCollectionUpdateResults.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System.Collections.Generic; namespace Uno.Extensions diff --git a/src/Uno.Core/Collections/QueueExtensions.cs b/src/Uno.Core/Collections/QueueExtensions.cs index 5d527c7..a3353ad 100644 --- a/src/Uno.Core/Collections/QueueExtensions.cs +++ b/src/Uno.Core/Collections/QueueExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; @@ -46,4 +47,4 @@ public static T DequeueOrDefault(this Queue queue) : default(T); } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Collections/StackExtensions.cs b/src/Uno.Core/Collections/StackExtensions.cs index 6cfc31c..c813673 100644 --- a/src/Uno.Core/Collections/StackExtensions.cs +++ b/src/Uno.Core/Collections/StackExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; @@ -33,4 +34,4 @@ public static IDisposable Subscribe(this Stack stack, T value) return Actions.Create(() => stack.Pop()).ToDisposable(); } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Collections/SynchronizedDictionary.cs b/src/Uno.Core/Collections/SynchronizedDictionary.cs index b1c2b34..0000053 100644 --- a/src/Uno.Core/Collections/SynchronizedDictionary.cs +++ b/src/Uno.Core/Collections/SynchronizedDictionary.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System.Collections; using System.Collections.Generic; using System.Linq; @@ -267,4 +268,4 @@ public bool TryRemove(TKey key, out TValue value) } } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Collections/UnsafeWeakAttachedDictionary.cs b/src/Uno.Core/Collections/UnsafeWeakAttachedDictionary.cs index 145377f..ead9651 100644 --- a/src/Uno.Core/Collections/UnsafeWeakAttachedDictionary.cs +++ b/src/Uno.Core/Collections/UnsafeWeakAttachedDictionary.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Collections/WeakAttachedDictionary.cs b/src/Uno.Core/Collections/WeakAttachedDictionary.cs index a57ad1b..3c48f28 100644 --- a/src/Uno.Core/Collections/WeakAttachedDictionary.cs +++ b/src/Uno.Core/Collections/WeakAttachedDictionary.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Comparison/FastTypeComparer.cs b/src/Uno.Core/Comparison/FastTypeComparer.cs index 96f1b0b..d7af5d9 100644 --- a/src/Uno.Core/Comparison/FastTypeComparer.cs +++ b/src/Uno.Core/Comparison/FastTypeComparer.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Comparison/FuncComparer.cs b/src/Uno.Core/Comparison/FuncComparer.cs index a648853..3dc26e2 100644 --- a/src/Uno.Core/Comparison/FuncComparer.cs +++ b/src/Uno.Core/Comparison/FuncComparer.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; @@ -50,4 +51,4 @@ public int Compare(T x, T y) return _compare(x, y); } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/CompositionType.cs b/src/Uno.Core/CompositionType.cs index 359110c..5d53212 100644 --- a/src/Uno.Core/CompositionType.cs +++ b/src/Uno.Core/CompositionType.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,14 +14,15 @@ // limitations under the License. // // ****************************************************************** + namespace Uno { - /// - /// Represets the type of composition. - /// - public enum CompositionType - { - And, - Or - } -} \ No newline at end of file + /// + /// Represents the type of composition. + /// + public enum CompositionType + { + And, + Or + } +} diff --git a/src/Uno.Core/Conversion/ConversionExtensionPoint.cs b/src/Uno.Core/Conversion/ConversionExtensionPoint.cs index b8dd70c..3ee4325 100644 --- a/src/Uno.Core/Conversion/ConversionExtensionPoint.cs +++ b/src/Uno.Core/Conversion/ConversionExtensionPoint.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using Uno.Extensions; namespace Uno.Conversion @@ -25,4 +26,4 @@ public ConversionExtensionPoint(object value) { } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Conversion/ConversionExtensions.cs b/src/Uno.Core/Conversion/ConversionExtensions.cs index 833cea5..bf2e712 100644 --- a/src/Uno.Core/Conversion/ConversionExtensions.cs +++ b/src/Uno.Core/Conversion/ConversionExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using Uno.Conversion; using System.Globalization; @@ -47,4 +48,4 @@ public static object To(this ConversionExtensionPoint extensionPoint, Type toTyp return Extensions.To(extensionPoint, toType, culture); } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Conversion/CustomConversionStrategy.cs b/src/Uno.Core/Conversion/CustomConversionStrategy.cs index 0361145..b328bc6 100644 --- a/src/Uno.Core/Conversion/CustomConversionStrategy.cs +++ b/src/Uno.Core/Conversion/CustomConversionStrategy.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Globalization; using Uno.Extensions; @@ -40,4 +41,4 @@ public object Convert(object value, Type toType, CultureInfo culture = null) return _conversion((TFrom)value, culture); } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Conversion/CustomCulturelessConversionStrategy.cs b/src/Uno.Core/Conversion/CustomCulturelessConversionStrategy.cs index 832c0ce..5f717e1 100644 --- a/src/Uno.Core/Conversion/CustomCulturelessConversionStrategy.cs +++ b/src/Uno.Core/Conversion/CustomCulturelessConversionStrategy.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Globalization; using Uno.Extensions; @@ -40,4 +41,4 @@ public object Convert(object value, Type toType, CultureInfo culture = null) return _conversion((TFrom)value); } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Conversion/DefaultConversionExtensions.cs b/src/Uno.Core/Conversion/DefaultConversionExtensions.cs index 0e6636a..dc3c9cd 100644 --- a/src/Uno.Core/Conversion/DefaultConversionExtensions.cs +++ b/src/Uno.Core/Conversion/DefaultConversionExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -95,4 +96,4 @@ private IConversionStrategy GetConversionStrategy(object value, Type toType, Cul .FirstOrDefault(item => item.CanConvert(value, toType, culture)); } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Conversion/EnumConversionStrategy.cs b/src/Uno.Core/Conversion/EnumConversionStrategy.cs index 52cca87..2c42758 100644 --- a/src/Uno.Core/Conversion/EnumConversionStrategy.cs +++ b/src/Uno.Core/Conversion/EnumConversionStrategy.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.ComponentModel; using System.Globalization; @@ -156,4 +157,4 @@ private static string SourceFindValue(Type enumType, string text, CultureInfo cu return unkownFieldInfo == null ? null : unkownFieldInfo.Name; } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Conversion/IConversionExtensions.cs b/src/Uno.Core/Conversion/IConversionExtensions.cs index 37474e7..cfcdb83 100644 --- a/src/Uno.Core/Conversion/IConversionExtensions.cs +++ b/src/Uno.Core/Conversion/IConversionExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.ComponentModel; using System.Globalization; @@ -106,4 +107,4 @@ public static T To(this IConversionExtensions conversionExtensions, Conversio //public static IConversionExtensions RegisterStrategy } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Conversion/IConversionStrategy.cs b/src/Uno.Core/Conversion/IConversionStrategy.cs index 40b33ca..d9c678f 100644 --- a/src/Uno.Core/Conversion/IConversionStrategy.cs +++ b/src/Uno.Core/Conversion/IConversionStrategy.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Globalization; @@ -33,4 +34,4 @@ public interface IConversionStrategy /// result object Convert(object value, Type toType, CultureInfo culture = null); } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Conversion/PrimitiveConversionStrategy.cs b/src/Uno.Core/Conversion/PrimitiveConversionStrategy.cs index 1bbb3a0..4a8738d 100644 --- a/src/Uno.Core/Conversion/PrimitiveConversionStrategy.cs +++ b/src/Uno.Core/Conversion/PrimitiveConversionStrategy.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Globalization; diff --git a/src/Uno.Core/Conversion/TypeConverterConversionStrategy.cs b/src/Uno.Core/Conversion/TypeConverterConversionStrategy.cs index f79a96f..0d4df1a 100644 --- a/src/Uno.Core/Conversion/TypeConverterConversionStrategy.cs +++ b/src/Uno.Core/Conversion/TypeConverterConversionStrategy.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.ComponentModel; using System.Globalization; diff --git a/src/Uno.Core/DataStatus.cs b/src/Uno.Core/DataStatus.cs index 799ebba..f98456e 100644 --- a/src/Uno.Core/DataStatus.cs +++ b/src/Uno.Core/DataStatus.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -22,23 +23,23 @@ namespace Uno { - [DataContract(Namespace = "Uno.Contract")] - [Flags] - public enum DataStatus - { - [EnumMember] - NotInitialized = 0, - [EnumMember] - Unchanged = 1, - [EnumMember] - Created = 2, - [EnumMember] - Updated = 4, - [EnumMember] - Deleted = 8, - [EnumMember] - Added = 16, - [EnumMember] - Removed = 32 - } + [DataContract(Namespace = "Uno.Contract")] + [Flags] + public enum DataStatus + { + [EnumMember] + NotInitialized = 0, + [EnumMember] + Unchanged = 1, + [EnumMember] + Created = 2, + [EnumMember] + Updated = 4, + [EnumMember] + Deleted = 8, + [EnumMember] + Added = 16, + [EnumMember] + Removed = 32 + } } diff --git a/src/Uno.Core/DateTimeUnit.cs b/src/Uno.Core/DateTimeUnit.cs index 7f6951a..6a876fb 100644 --- a/src/Uno.Core/DateTimeUnit.cs +++ b/src/Uno.Core/DateTimeUnit.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,25 +14,26 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno { - [Flags] - public enum DateTimeUnit - { - Year = 1, - Month = 2, - Day = 4, - Hour = 8, - Minute = 16, - Second = 32, - Millisecond = 64, - ToMonth = Year | Month, - ToDay = ToMonth | Day, - ToHour = ToDay | Hour, - ToMinute = ToHour | Minute, - ToSecond = ToMinute | Second, - ToMillisecond = ToSecond | Millisecond - } -} \ No newline at end of file + [Flags] + public enum DateTimeUnit + { + Year = 1, + Month = 2, + Day = 4, + Hour = 8, + Minute = 16, + Second = 32, + Millisecond = 64, + ToMonth = Year | Month, + ToDay = ToMonth | Day, + ToHour = ToDay | Hour, + ToMinute = ToHour | Minute, + ToSecond = ToMinute | Second, + ToMillisecond = ToSecond | Millisecond + } +} diff --git a/src/Uno.Core/Decorator/Decorator.cs b/src/Uno.Core/Decorator/Decorator.cs index 6af6553..ead9f7f 100644 --- a/src/Uno.Core/Decorator/Decorator.cs +++ b/src/Uno.Core/Decorator/Decorator.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,7 +14,6 @@ // limitations under the License. // // ****************************************************************** -using System; namespace Uno.Decorator { @@ -52,4 +51,4 @@ public Decorator(T target) #endregion } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Decorator/IDecorator.cs b/src/Uno.Core/Decorator/IDecorator.cs index 99a2f5b..a168198 100644 --- a/src/Uno.Core/Decorator/IDecorator.cs +++ b/src/Uno.Core/Decorator/IDecorator.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + namespace Uno.Decorator { /// @@ -27,4 +28,4 @@ public interface IDecorator /// T Target { get; set; } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/DelegateConditionalWeakTable.cs b/src/Uno.Core/DelegateConditionalWeakTable.cs index 4fd3952..50b75bd 100644 --- a/src/Uno.Core/DelegateConditionalWeakTable.cs +++ b/src/Uno.Core/DelegateConditionalWeakTable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Collections.Immutable; diff --git a/src/Uno.Core/DisposableAction.cs b/src/Uno.Core/DisposableAction.cs index 848bf02..332d693 100644 --- a/src/Uno.Core/DisposableAction.cs +++ b/src/Uno.Core/DisposableAction.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -21,22 +22,22 @@ namespace Uno { - public class DisposableAction : IDisposable - { - public DisposableAction(Action action) - { - Action = action; - } + public class DisposableAction : IDisposable + { + public DisposableAction(Action action) + { + Action = action; + } - public Action Action { get; private set; } + public Action Action { get; private set; } - #region IDisposable Members + #region IDisposable Members - public void Dispose() - { - Action(); - } + public void Dispose() + { + Action(); + } - #endregion - } + #endregion + } } diff --git a/src/Uno.Core/DisposableConditionalWeakTable.cs b/src/Uno.Core/DisposableConditionalWeakTable.cs index e01ced8..632cde4 100644 --- a/src/Uno.Core/DisposableConditionalWeakTable.cs +++ b/src/Uno.Core/DisposableConditionalWeakTable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Runtime.CompilerServices; diff --git a/src/Uno.Core/Disposables/AnonymousDisposable.cs b/src/Uno.Core/Disposables/AnonymousDisposable.cs index df47963..6e90da7 100644 --- a/src/Uno.Core/Disposables/AnonymousDisposable.cs +++ b/src/Uno.Core/Disposables/AnonymousDisposable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Threading; @@ -56,4 +57,4 @@ public void Dispose() } } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Disposables/CancellationDisposable.cs b/src/Uno.Core/Disposables/CancellationDisposable.cs index 23a08ca..e3ea848 100644 --- a/src/Uno.Core/Disposables/CancellationDisposable.cs +++ b/src/Uno.Core/Disposables/CancellationDisposable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Threading; @@ -71,4 +72,4 @@ public bool IsDisposed get { return _cts.IsCancellationRequested; } } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Disposables/CompositeDisposable.cs b/src/Uno.Core/Disposables/CompositeDisposable.cs index 93aa102..4fd2586 100644 --- a/src/Uno.Core/Disposables/CompositeDisposable.cs +++ b/src/Uno.Core/Disposables/CompositeDisposable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -288,4 +289,4 @@ public bool IsDisposed get { return _disposed; } } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Disposables/CompositeDisposableExtensions.cs b/src/Uno.Core/Disposables/CompositeDisposableExtensions.cs index 3c39f8a..debe133 100644 --- a/src/Uno.Core/Disposables/CompositeDisposableExtensions.cs +++ b/src/Uno.Core/Disposables/CompositeDisposableExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Disposables/ConditionalDisposable.cs b/src/Uno.Core/Disposables/ConditionalDisposable.cs index e61b597..6bb0a3a 100644 --- a/src/Uno.Core/Disposables/ConditionalDisposable.cs +++ b/src/Uno.Core/Disposables/ConditionalDisposable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Runtime.CompilerServices; diff --git a/src/Uno.Core/Disposables/DefaultDisposable.cs b/src/Uno.Core/Disposables/DefaultDisposable.cs index 7ef3ecd..2e1c480 100644 --- a/src/Uno.Core/Disposables/DefaultDisposable.cs +++ b/src/Uno.Core/Disposables/DefaultDisposable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno.Disposables diff --git a/src/Uno.Core/Disposables/Disposable.cs b/src/Uno.Core/Disposables/Disposable.cs index 05ccb37..00545bf 100644 --- a/src/Uno.Core/Disposables/Disposable.cs +++ b/src/Uno.Core/Disposables/Disposable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno.Disposables diff --git a/src/Uno.Core/Disposables/DisposableExtensions.cs b/src/Uno.Core/Disposables/DisposableExtensions.cs index 557ad48..2e245f0 100644 --- a/src/Uno.Core/Disposables/DisposableExtensions.cs +++ b/src/Uno.Core/Disposables/DisposableExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Disposables/ICancelable.cs b/src/Uno.Core/Disposables/ICancelable.cs index 13f75ca..4ef93b8 100644 --- a/src/Uno.Core/Disposables/ICancelable.cs +++ b/src/Uno.Core/Disposables/ICancelable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno.Disposables diff --git a/src/Uno.Core/Disposables/IExtensibleDisposable.cs b/src/Uno.Core/Disposables/IExtensibleDisposable.cs index f073458..8d19c9f 100644 --- a/src/Uno.Core/Disposables/IExtensibleDisposable.cs +++ b/src/Uno.Core/Disposables/IExtensibleDisposable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Disposables/SerialDisposable.cs b/src/Uno.Core/Disposables/SerialDisposable.cs index 2097be1..ddd2204 100644 --- a/src/Uno.Core/Disposables/SerialDisposable.cs +++ b/src/Uno.Core/Disposables/SerialDisposable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno.Disposables @@ -100,4 +101,4 @@ public void Dispose() old.Dispose(); } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/EnumUtilities.cs b/src/Uno.Core/EnumUtilities.cs index 41beb91..b04df3a 100644 --- a/src/Uno.Core/EnumUtilities.cs +++ b/src/Uno.Core/EnumUtilities.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Globalization; @@ -103,7 +104,7 @@ public static bool TryParse(Type enumType, string value, bool ignoreCase, out ob } result = null; - return false; + return false; } public static System.Tuple[] GetValues(Type enumType, bool ignoreCase) @@ -117,7 +118,7 @@ public static System.Tuple[] GetValues(Type enumType, bo var enumParsedValue = Enum.Parse(enumType, info.Name, ignoreCase); var enumUnderlyingValue = Convert.ChangeType(enumValue, Enum.GetUnderlyingType(enumValue.GetType()), CultureInfo.InvariantCulture); return System.Tuple.Create(info.Name, enumParsedValue, enumUnderlyingValue); - }) + }) .ToArray(); } diff --git a/src/Uno.Core/Equality/CollectionEqualityComparer.cs b/src/Uno.Core/Equality/CollectionEqualityComparer.cs index 772a93e..575e65c 100644 --- a/src/Uno.Core/Equality/CollectionEqualityComparer.cs +++ b/src/Uno.Core/Equality/CollectionEqualityComparer.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Equality/EqualityComparerExtensions.cs b/src/Uno.Core/Equality/EqualityComparerExtensions.cs index 72bfe0e..1eb3019 100644 --- a/src/Uno.Core/Equality/EqualityComparerExtensions.cs +++ b/src/Uno.Core/Equality/EqualityComparerExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections; using System.Collections.Generic; diff --git a/src/Uno.Core/Equality/EqualityExtensionPoint.cs b/src/Uno.Core/Equality/EqualityExtensionPoint.cs index 3aa7c0e..76a554e 100644 --- a/src/Uno.Core/Equality/EqualityExtensionPoint.cs +++ b/src/Uno.Core/Equality/EqualityExtensionPoint.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using Uno.Extensions; namespace Uno.Equality @@ -42,4 +43,4 @@ public override bool Equals(object obj) } } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Equality/EqualityExtensions.cs b/src/Uno.Core/Equality/EqualityExtensions.cs index 402e973..63ab833 100644 --- a/src/Uno.Core/Equality/EqualityExtensions.cs +++ b/src/Uno.Core/Equality/EqualityExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections; using System.Collections.Generic; diff --git a/src/Uno.Core/Equality/FuncEqualityComparer.cs b/src/Uno.Core/Equality/FuncEqualityComparer.cs index f018538..519f675 100644 --- a/src/Uno.Core/Equality/FuncEqualityComparer.cs +++ b/src/Uno.Core/Equality/FuncEqualityComparer.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.ComponentModel; @@ -182,4 +183,4 @@ public int GetHashCode(T obj) return _valueEqualityComparer.GetHashCode(value); } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Equality/IKeyEquatable.cs b/src/Uno.Core/Equality/IKeyEquatable.cs index 5c2ffbe..5ccea51 100644 --- a/src/Uno.Core/Equality/IKeyEquatable.cs +++ b/src/Uno.Core/Equality/IKeyEquatable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Text; diff --git a/src/Uno.Core/Equality/KeyEqualityComparer.cs b/src/Uno.Core/Equality/KeyEqualityComparer.cs index 1a6efa1..7e5761f 100644 --- a/src/Uno.Core/Equality/KeyEqualityComparer.cs +++ b/src/Uno.Core/Equality/KeyEqualityComparer.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections; using System.Collections.Generic; diff --git a/src/Uno.Core/Equality/WeakReferenceEqualityComparer.cs b/src/Uno.Core/Equality/WeakReferenceEqualityComparer.cs index 8dbd6be..5623364 100644 --- a/src/Uno.Core/Equality/WeakReferenceEqualityComparer.cs +++ b/src/Uno.Core/Equality/WeakReferenceEqualityComparer.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System.Linq; using System; using System.Collections.Generic; @@ -56,4 +57,4 @@ public int GetHashCode(System.WeakReference w) : -1; } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Events/EventHandlerConverter.cs b/src/Uno.Core/Events/EventHandlerConverter.cs index cacebdf..9911d29 100644 --- a/src/Uno.Core/Events/EventHandlerConverter.cs +++ b/src/Uno.Core/Events/EventHandlerConverter.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Collections.Immutable; diff --git a/src/Uno.Core/Expressions/Builder/IPredicateBuilder.cs b/src/Uno.Core/Expressions/Builder/IPredicateBuilder.cs index 56090b9..da5b0dd 100644 --- a/src/Uno.Core/Expressions/Builder/IPredicateBuilder.cs +++ b/src/Uno.Core/Expressions/Builder/IPredicateBuilder.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,14 +14,15 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Linq.Expressions; namespace Uno.Expressions.Builder { - //TODO - public interface IPredicateBuilder - { - Expression> ToExpression(); - } -} \ No newline at end of file + //TODO + public interface IPredicateBuilder + { + Expression> ToExpression(); + } +} diff --git a/src/Uno.Core/Expressions/EditableBinaryExpression.cs b/src/Uno.Core/Expressions/EditableBinaryExpression.cs index fcfe1b7..cdd1859 100644 --- a/src/Uno.Core/Expressions/EditableBinaryExpression.cs +++ b/src/Uno.Core/Expressions/EditableBinaryExpression.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,37 +14,38 @@ // limitations under the License. // // ****************************************************************** + using System.Collections.Generic; using System.Linq.Expressions; using Uno.Extensions; namespace Uno.Expressions { - public class EditableBinaryExpression : EditableExpression - { - public EditableBinaryExpression(BinaryExpression expression) - : base(expression) - { - Left = expression.Left.Edit(); - Right = expression.Right.Edit(); - } + public class EditableBinaryExpression : EditableExpression + { + public EditableBinaryExpression(BinaryExpression expression) + : base(expression) + { + Left = expression.Left.Edit(); + Right = expression.Right.Edit(); + } - public IEditableExpression Left { get; set; } + public IEditableExpression Left { get; set; } - public IEditableExpression Right { get; set; } + public IEditableExpression Right { get; set; } - public override IEnumerable Nodes - { - get - { - yield return Left; - yield return Right; - } - } + public override IEnumerable Nodes + { + get + { + yield return Left; + yield return Right; + } + } - public override BinaryExpression DoToExpression() - { - return Expression.MakeBinary(NodeType, Left.ToExpression(), Right.ToExpression()); - } - } -} \ No newline at end of file + public override BinaryExpression DoToExpression() + { + return Expression.MakeBinary(NodeType, Left.ToExpression(), Right.ToExpression()); + } + } +} diff --git a/src/Uno.Core/Expressions/EditableConditionalExpression.cs b/src/Uno.Core/Expressions/EditableConditionalExpression.cs index f3b2b63..382d9a6 100644 --- a/src/Uno.Core/Expressions/EditableConditionalExpression.cs +++ b/src/Uno.Core/Expressions/EditableConditionalExpression.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,41 +14,42 @@ // limitations under the License. // // ****************************************************************** + using System.Collections.Generic; using System.Linq.Expressions; using Uno.Extensions; namespace Uno.Expressions { - public class EditableConditionalExpression : EditableExpression - { - public EditableConditionalExpression(ConditionalExpression expression) - : base(expression) - { - Test = expression.Test.Edit(); - IfTrue = expression.IfTrue.Edit(); - IfFalse = expression.IfFalse.Edit(); - } + public class EditableConditionalExpression : EditableExpression + { + public EditableConditionalExpression(ConditionalExpression expression) + : base(expression) + { + Test = expression.Test.Edit(); + IfTrue = expression.IfTrue.Edit(); + IfFalse = expression.IfFalse.Edit(); + } - public IEditableExpression Test { get; set; } + public IEditableExpression Test { get; set; } - public IEditableExpression IfTrue { get; set; } + public IEditableExpression IfTrue { get; set; } - public IEditableExpression IfFalse { get; set; } + public IEditableExpression IfFalse { get; set; } - public override IEnumerable Nodes - { - get - { - yield return Test; - yield return IfTrue; - yield return IfFalse; - } - } + public override IEnumerable Nodes + { + get + { + yield return Test; + yield return IfTrue; + yield return IfFalse; + } + } - public override ConditionalExpression DoToExpression() - { - return Expression.Condition(Test.ToExpression(), IfTrue.ToExpression(), IfFalse.ToExpression()); - } - } -} \ No newline at end of file + public override ConditionalExpression DoToExpression() + { + return Expression.Condition(Test.ToExpression(), IfTrue.ToExpression(), IfFalse.ToExpression()); + } + } +} diff --git a/src/Uno.Core/Expressions/EditableConstantExpression.cs b/src/Uno.Core/Expressions/EditableConstantExpression.cs index f8c8eb1..7f6649d 100644 --- a/src/Uno.Core/Expressions/EditableConstantExpression.cs +++ b/src/Uno.Core/Expressions/EditableConstantExpression.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,23 +14,24 @@ // limitations under the License. // // ****************************************************************** + using System.Linq.Expressions; namespace Uno.Expressions { - public class EditableConstantExpression : EditableExpression - { - public EditableConstantExpression(ConstantExpression expression) - : base(expression, false) - { - Value = expression.Value; - } + public class EditableConstantExpression : EditableExpression + { + public EditableConstantExpression(ConstantExpression expression) + : base(expression, false) + { + Value = expression.Value; + } - public object Value { get; set; } + public object Value { get; set; } - public override ConstantExpression DoToExpression() - { - return Expression.Constant(Value); - } - } -} \ No newline at end of file + public override ConstantExpression DoToExpression() + { + return Expression.Constant(Value); + } + } +} diff --git a/src/Uno.Core/Expressions/EditableElementInit.cs b/src/Uno.Core/Expressions/EditableElementInit.cs index 31681df..8a45921 100644 --- a/src/Uno.Core/Expressions/EditableElementInit.cs +++ b/src/Uno.Core/Expressions/EditableElementInit.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,31 +14,32 @@ // limitations under the License. // // ****************************************************************** + using System.Linq.Expressions; using System.Reflection; namespace Uno.Expressions { - public class EditableElementInit - { - private readonly EditableExpressionCollection arguments; + public class EditableElementInit + { + private readonly EditableExpressionCollection arguments; - public EditableElementInit(ElementInit elementInit) - { - AddMethod = elementInit.AddMethod; - arguments = new EditableExpressionCollection(elementInit.Arguments); - } + public EditableElementInit(ElementInit elementInit) + { + AddMethod = elementInit.AddMethod; + arguments = new EditableExpressionCollection(elementInit.Arguments); + } - public MethodInfo AddMethod { get; set; } + public MethodInfo AddMethod { get; set; } - public EditableExpressionCollection Arguments - { - get { return arguments; } - } + public EditableExpressionCollection Arguments + { + get { return arguments; } + } - public ElementInit ToElementInit() - { - return Expression.ElementInit(AddMethod, Arguments.ToExpression()); - } - } -} \ No newline at end of file + public ElementInit ToElementInit() + { + return Expression.ElementInit(AddMethod, Arguments.ToExpression()); + } + } +} diff --git a/src/Uno.Core/Expressions/EditableExpression.cs b/src/Uno.Core/Expressions/EditableExpression.cs index 9b81bd9..17bfb11 100644 --- a/src/Uno.Core/Expressions/EditableExpression.cs +++ b/src/Uno.Core/Expressions/EditableExpression.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,107 +14,108 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq.Expressions; namespace Uno.Expressions { - public abstract class EditableExpression : IEditableExpression - where T : Expression - { - private readonly bool nodeTypeEditable; - private readonly T originalExpression; - private Expression expressionOverride; - private ExpressionType nodeType; - - // TODO: convert to protected - public EditableExpression(T expression) - : this(expression, true) - { - } - - // TODO: convert to protected - public EditableExpression(T expression, bool nodeTypeEditable) - { - //TODO Validate expression != null - originalExpression = expression; - nodeType = expression.NodeType; - this.nodeTypeEditable = nodeTypeEditable; - } - - #region IEditableExpression Members - - public Expression OriginalExpression - { - get { return originalExpression; } - } - - public virtual ExpressionType NodeType - { - get { return nodeType; } - set - { - if (!nodeTypeEditable) - { - throw new InvalidOperationException("Cannot change NodeType!"); - } - nodeType = value; - } - } - - public Type ExpressionType - { - get { return typeof (T); } - } - - Expression IEditableExpression.ToExpression() - { - return ToExpression(); - } - - public virtual IEnumerable Nodes - { - get { return new IEditableExpression[0]; } - } - - public virtual void Use(Expression expression) - { - if (ShouldUse(expression)) - { - expressionOverride = expression; - } - } - - #endregion - - public virtual T ToExpression() - { - if (expressionOverride == null) - { - return DoToExpression(); - } - return expressionOverride as T; - } - - public abstract T DoToExpression(); - - protected virtual bool ShouldUse(Expression expression) - { - if (expression.NodeType == NodeType && - expression is T) - { - var castedExpression = expression as T; - - return ShouldUse(castedExpression); - } - - return false; - } - - protected virtual bool ShouldUse(T expression) - { - return true; - } - } -} \ No newline at end of file + public abstract class EditableExpression : IEditableExpression + where T : Expression + { + private readonly bool nodeTypeEditable; + private readonly T originalExpression; + private Expression expressionOverride; + private ExpressionType nodeType; + + // TODO: convert to protected + public EditableExpression(T expression) + : this(expression, true) + { + } + + // TODO: convert to protected + public EditableExpression(T expression, bool nodeTypeEditable) + { + //TODO Validate expression != null + originalExpression = expression; + nodeType = expression.NodeType; + this.nodeTypeEditable = nodeTypeEditable; + } + + #region IEditableExpression Members + + public Expression OriginalExpression + { + get { return originalExpression; } + } + + public virtual ExpressionType NodeType + { + get { return nodeType; } + set + { + if (!nodeTypeEditable) + { + throw new InvalidOperationException("Cannot change NodeType!"); + } + nodeType = value; + } + } + + public Type ExpressionType + { + get { return typeof (T); } + } + + Expression IEditableExpression.ToExpression() + { + return ToExpression(); + } + + public virtual IEnumerable Nodes + { + get { return new IEditableExpression[0]; } + } + + public virtual void Use(Expression expression) + { + if (ShouldUse(expression)) + { + expressionOverride = expression; + } + } + + #endregion + + public virtual T ToExpression() + { + if (expressionOverride == null) + { + return DoToExpression(); + } + return expressionOverride as T; + } + + public abstract T DoToExpression(); + + protected virtual bool ShouldUse(Expression expression) + { + if (expression.NodeType == NodeType && + expression is T) + { + var castedExpression = expression as T; + + return ShouldUse(castedExpression); + } + + return false; + } + + protected virtual bool ShouldUse(T expression) + { + return true; + } + } +} diff --git a/src/Uno.Core/Expressions/EditableExpressionCollection.cs b/src/Uno.Core/Expressions/EditableExpressionCollection.cs index 7eefff0..05f9957 100644 --- a/src/Uno.Core/Expressions/EditableExpressionCollection.cs +++ b/src/Uno.Core/Expressions/EditableExpressionCollection.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; @@ -21,30 +22,30 @@ namespace Uno.Expressions { - public class EditableExpressionCollection - where T : Expression - { - private readonly IList> items; + public class EditableExpressionCollection + where T : Expression + { + private readonly IList> items; - public EditableExpressionCollection(IEnumerable items) - { - this.items = new List>(items.Edit().Cast>()); - } + public EditableExpressionCollection(IEnumerable items) + { + this.items = new List>(items.Edit().Cast>()); + } - // TODO parameter can be type IEnumerable - public EditableExpressionCollection(IEnumerable items) - : this(items.Cast()) - { - } + // TODO parameter can be type IEnumerable + public EditableExpressionCollection(IEnumerable items) + : this(items.Cast()) + { + } - public IList> Items - { - get { return items; } - } + public IList> Items + { + get { return items; } + } - public virtual T[] ToExpression() - { - return items.Select(item => item.DoToExpression()).ToArray(); - } - } -} \ No newline at end of file + public virtual T[] ToExpression() + { + return items.Select(item => item.DoToExpression()).ToArray(); + } + } +} diff --git a/src/Uno.Core/Expressions/EditableExpressionExtensions.cs b/src/Uno.Core/Expressions/EditableExpressionExtensions.cs index 73e2ca9..6592106 100644 --- a/src/Uno.Core/Expressions/EditableExpressionExtensions.cs +++ b/src/Uno.Core/Expressions/EditableExpressionExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; @@ -21,125 +22,125 @@ namespace Uno.Extensions { - public static class EditableExpressionExtensions - { - public static EditableLambdaExpression Edit(this Expression expression) - { - return new EditableLambdaExpression(expression); - } - - public static EditableConstantExpression Edit(this ConstantExpression expression) - { - return new EditableConstantExpression(expression); - } - - public static EditableBinaryExpression Edit(this BinaryExpression expression) - { - return new EditableBinaryExpression(expression); - } - - public static EditableConditionalExpression Edit(this ConditionalExpression expression) - { - return new EditableConditionalExpression(expression); - } - - public static EditableInvocationExpression Edit(this InvocationExpression expression) - { - return new EditableInvocationExpression(expression); - } - - public static EditableLambdaExpression Edit(this LambdaExpression expression) - { - return new EditableLambdaExpression(expression); - } - - public static EditableParameterExpression Edit(this ParameterExpression expression) - { - return new EditableParameterExpression(expression); - } - - public static EditableListInitExpression Edit(this ListInitExpression expression) - { - return new EditableListInitExpression(expression); - } - - public static EditableMemberExpression Edit(this MemberExpression expression) - { - return new EditableMemberExpression(expression); - } - - public static EditableMemberInitExpression Edit(this MemberInitExpression expression) - { - return new EditableMemberInitExpression(expression); - } - - public static EditableMethodCallExpression Edit(this MethodCallExpression expression) - { - return new EditableMethodCallExpression(expression); - } - - public static EditableNewArrayExpression Edit(this NewArrayExpression expression) - { - return new EditableNewArrayExpression(expression); - } - - public static EditableNewExpression Edit(this NewExpression expression) - { - return new EditableNewExpression(expression); - } - - public static EditableTypeBinaryExpression Edit(this TypeBinaryExpression expression) - { - return new EditableTypeBinaryExpression(expression); - } - - public static EditableUnaryExpression Edit(this UnaryExpression expression) - { - return new EditableUnaryExpression(expression); - } - - public static IEditableExpression Edit(this Expression expression) - { - if (expression is ConstantExpression) return Edit(expression as ConstantExpression); - if (expression is BinaryExpression) return Edit(expression as BinaryExpression); - if (expression is ConditionalExpression) return Edit(expression as ConditionalExpression); - if (expression is InvocationExpression) return Edit(expression as InvocationExpression); - if (expression is LambdaExpression) return Edit(expression as LambdaExpression); - if (expression is ParameterExpression) return Edit(expression as ParameterExpression); - if (expression is ListInitExpression) return Edit(expression as ListInitExpression); - if (expression is MemberExpression) return Edit(expression as MemberExpression); - if (expression is MemberInitExpression) return Edit(expression as MemberInitExpression); - if (expression is MethodCallExpression) return Edit(expression as MethodCallExpression); - if (expression is NewArrayExpression) return Edit(expression as NewArrayExpression); - if (expression is NewExpression) return Edit(expression as NewExpression); - if (expression is TypeBinaryExpression) return Edit(expression as TypeBinaryExpression); - if (expression is UnaryExpression) return Edit(expression as UnaryExpression); - return null; - } - - public static IEnumerable Edit(this IEnumerable expressions) - { - return expressions.Select(Edit); - } - - public static IEnumerable AllNodes(this IEditableExpression expression) - { - foreach (IEditableExpression node in expression.Nodes.SelectMany(item => item.AllNodes())) - { - yield return node; - } - - yield return expression; - } - - public static void Use(this IEditableExpression editableExpression, Expression expression) - { - editableExpression.AllNodes().ForEach(item => item.Use(expression)); - } - - public static void Use(this IEditableExpression editableExpression, IEnumerable expressions) - { - expressions.ForEach(item => Use(editableExpression, item)); - } - } -} \ No newline at end of file + public static class EditableExpressionExtensions + { + public static EditableLambdaExpression Edit(this Expression expression) + { + return new EditableLambdaExpression(expression); + } + + public static EditableConstantExpression Edit(this ConstantExpression expression) + { + return new EditableConstantExpression(expression); + } + + public static EditableBinaryExpression Edit(this BinaryExpression expression) + { + return new EditableBinaryExpression(expression); + } + + public static EditableConditionalExpression Edit(this ConditionalExpression expression) + { + return new EditableConditionalExpression(expression); + } + + public static EditableInvocationExpression Edit(this InvocationExpression expression) + { + return new EditableInvocationExpression(expression); + } + + public static EditableLambdaExpression Edit(this LambdaExpression expression) + { + return new EditableLambdaExpression(expression); + } + + public static EditableParameterExpression Edit(this ParameterExpression expression) + { + return new EditableParameterExpression(expression); + } + + public static EditableListInitExpression Edit(this ListInitExpression expression) + { + return new EditableListInitExpression(expression); + } + + public static EditableMemberExpression Edit(this MemberExpression expression) + { + return new EditableMemberExpression(expression); + } + + public static EditableMemberInitExpression Edit(this MemberInitExpression expression) + { + return new EditableMemberInitExpression(expression); + } + + public static EditableMethodCallExpression Edit(this MethodCallExpression expression) + { + return new EditableMethodCallExpression(expression); + } + + public static EditableNewArrayExpression Edit(this NewArrayExpression expression) + { + return new EditableNewArrayExpression(expression); + } + + public static EditableNewExpression Edit(this NewExpression expression) + { + return new EditableNewExpression(expression); + } + + public static EditableTypeBinaryExpression Edit(this TypeBinaryExpression expression) + { + return new EditableTypeBinaryExpression(expression); + } + + public static EditableUnaryExpression Edit(this UnaryExpression expression) + { + return new EditableUnaryExpression(expression); + } + + public static IEditableExpression Edit(this Expression expression) + { + if (expression is ConstantExpression) return Edit(expression as ConstantExpression); + if (expression is BinaryExpression) return Edit(expression as BinaryExpression); + if (expression is ConditionalExpression) return Edit(expression as ConditionalExpression); + if (expression is InvocationExpression) return Edit(expression as InvocationExpression); + if (expression is LambdaExpression) return Edit(expression as LambdaExpression); + if (expression is ParameterExpression) return Edit(expression as ParameterExpression); + if (expression is ListInitExpression) return Edit(expression as ListInitExpression); + if (expression is MemberExpression) return Edit(expression as MemberExpression); + if (expression is MemberInitExpression) return Edit(expression as MemberInitExpression); + if (expression is MethodCallExpression) return Edit(expression as MethodCallExpression); + if (expression is NewArrayExpression) return Edit(expression as NewArrayExpression); + if (expression is NewExpression) return Edit(expression as NewExpression); + if (expression is TypeBinaryExpression) return Edit(expression as TypeBinaryExpression); + if (expression is UnaryExpression) return Edit(expression as UnaryExpression); + return null; + } + + public static IEnumerable Edit(this IEnumerable expressions) + { + return expressions.Select(Edit); + } + + public static IEnumerable AllNodes(this IEditableExpression expression) + { + foreach (IEditableExpression node in expression.Nodes.SelectMany(item => item.AllNodes())) + { + yield return node; + } + + yield return expression; + } + + public static void Use(this IEditableExpression editableExpression, Expression expression) + { + editableExpression.AllNodes().ForEach(item => item.Use(expression)); + } + + public static void Use(this IEditableExpression editableExpression, IEnumerable expressions) + { + expressions.ForEach(item => Use(editableExpression, item)); + } + } +} diff --git a/src/Uno.Core/Expressions/EditableInvocationExpression.cs b/src/Uno.Core/Expressions/EditableInvocationExpression.cs index 08544f1..22bf965 100644 --- a/src/Uno.Core/Expressions/EditableInvocationExpression.cs +++ b/src/Uno.Core/Expressions/EditableInvocationExpression.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; @@ -21,32 +22,32 @@ namespace Uno.Expressions { - public class EditableInvocationExpression : EditableExpression - { - private readonly EditableExpressionCollection arguments; + public class EditableInvocationExpression : EditableExpression + { + private readonly EditableExpressionCollection arguments; - public EditableInvocationExpression(InvocationExpression expression) - : base(expression, false) - { - Expression = expression.Expression.Edit(); - arguments = new EditableExpressionCollection(expression.Arguments); - } + public EditableInvocationExpression(InvocationExpression expression) + : base(expression, false) + { + Expression = expression.Expression.Edit(); + arguments = new EditableExpressionCollection(expression.Arguments); + } - public EditableExpressionCollection Arguments - { - get { return arguments; } - } + public EditableExpressionCollection Arguments + { + get { return arguments; } + } - public IEditableExpression Expression { get; set; } + public IEditableExpression Expression { get; set; } - public override IEnumerable Nodes - { - get { return Arguments.Items.Cast(); } - } + public override IEnumerable Nodes + { + get { return Arguments.Items.Cast(); } + } - public override InvocationExpression DoToExpression() - { - return System.Linq.Expressions.Expression.Invoke(Expression.ToExpression(), Arguments.ToExpression()); - } - } -} \ No newline at end of file + public override InvocationExpression DoToExpression() + { + return System.Linq.Expressions.Expression.Invoke(Expression.ToExpression(), Arguments.ToExpression()); + } + } +} diff --git a/src/Uno.Core/Expressions/EditableLambdaExpression.Generic.cs b/src/Uno.Core/Expressions/EditableLambdaExpression.Generic.cs index 81513af..dad03cb 100644 --- a/src/Uno.Core/Expressions/EditableLambdaExpression.Generic.cs +++ b/src/Uno.Core/Expressions/EditableLambdaExpression.Generic.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,45 +14,46 @@ // limitations under the License. // // ****************************************************************** + using System.Collections.Generic; using System.Linq.Expressions; using Uno.Extensions; namespace Uno.Expressions { - public class EditableLambdaExpression : EditableExpression> - { - private readonly EditableParameterExpressionCollection parameters; + public class EditableLambdaExpression : EditableExpression> + { + private readonly EditableParameterExpressionCollection parameters; - public EditableLambdaExpression(Expression expression) - : base(expression, false) - { - Body = expression.Body.Edit(); - parameters = new EditableParameterExpressionCollection(Body, expression.Parameters); - } + public EditableLambdaExpression(Expression expression) + : base(expression, false) + { + Body = expression.Body.Edit(); + parameters = new EditableParameterExpressionCollection(Body, expression.Parameters); + } - public IEditableExpression Body { get; set; } + public IEditableExpression Body { get; set; } - public EditableParameterExpressionCollection Parameters - { - get { return parameters; } - } + public EditableParameterExpressionCollection Parameters + { + get { return parameters; } + } - public override IEnumerable Nodes - { - get - { - yield return Body; - foreach (var item in Parameters.Items) - { - yield return item; - } - } - } + public override IEnumerable Nodes + { + get + { + yield return Body; + foreach (var item in Parameters.Items) + { + yield return item; + } + } + } - public override Expression DoToExpression() - { - return Expression.Lambda(Body.ToExpression(), Parameters.ToExpression()); - } - } -} \ No newline at end of file + public override Expression DoToExpression() + { + return Expression.Lambda(Body.ToExpression(), Parameters.ToExpression()); + } + } +} diff --git a/src/Uno.Core/Expressions/EditableLambdaExpression.cs b/src/Uno.Core/Expressions/EditableLambdaExpression.cs index c243e15..6e7648f 100644 --- a/src/Uno.Core/Expressions/EditableLambdaExpression.cs +++ b/src/Uno.Core/Expressions/EditableLambdaExpression.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,45 +14,46 @@ // limitations under the License. // // ****************************************************************** + using System.Collections.Generic; using System.Linq.Expressions; using Uno.Extensions; namespace Uno.Expressions { - public class EditableLambdaExpression : EditableExpression - { - private readonly EditableParameterExpressionCollection parameters; + public class EditableLambdaExpression : EditableExpression + { + private readonly EditableParameterExpressionCollection parameters; - public EditableLambdaExpression(LambdaExpression expression) - : base(expression, false) - { - Body = expression.Body.Edit(); - parameters = new EditableParameterExpressionCollection(Body, expression.Parameters); - } + public EditableLambdaExpression(LambdaExpression expression) + : base(expression, false) + { + Body = expression.Body.Edit(); + parameters = new EditableParameterExpressionCollection(Body, expression.Parameters); + } - public IEditableExpression Body { get; set; } + public IEditableExpression Body { get; set; } - public EditableParameterExpressionCollection Parameters - { - get { return parameters; } - } + public EditableParameterExpressionCollection Parameters + { + get { return parameters; } + } - public override IEnumerable Nodes - { - get - { - yield return Body; - foreach (var item in Parameters.Items) - { - yield return item; - } - } - } + public override IEnumerable Nodes + { + get + { + yield return Body; + foreach (var item in Parameters.Items) + { + yield return item; + } + } + } - public override LambdaExpression DoToExpression() - { - return Expression.Lambda(OriginalExpression.Type, Body.ToExpression(), Parameters.ToExpression()); - } - } -} \ No newline at end of file + public override LambdaExpression DoToExpression() + { + return Expression.Lambda(OriginalExpression.Type, Body.ToExpression(), Parameters.ToExpression()); + } + } +} diff --git a/src/Uno.Core/Expressions/EditableListInitExpression.cs b/src/Uno.Core/Expressions/EditableListInitExpression.cs index 420e9d6..a483401 100644 --- a/src/Uno.Core/Expressions/EditableListInitExpression.cs +++ b/src/Uno.Core/Expressions/EditableListInitExpression.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; @@ -21,40 +22,40 @@ namespace Uno.Expressions { - public class EditableListInitExpression : EditableExpression - { - private readonly List initializers; + public class EditableListInitExpression : EditableExpression + { + private readonly List initializers; - public EditableListInitExpression(ListInitExpression expression) - : base(expression, false) - { - initializers = new List(expression.Initializers.Select(item => new EditableElementInit(item))); - NewExpression = expression.NewExpression.Edit(); - } + public EditableListInitExpression(ListInitExpression expression) + : base(expression, false) + { + initializers = new List(expression.Initializers.Select(item => new EditableElementInit(item))); + NewExpression = expression.NewExpression.Edit(); + } - public EditableNewExpression NewExpression { get; set; } + public EditableNewExpression NewExpression { get; set; } - public IList Initializers - { - get { return initializers; } - } + public IList Initializers + { + get { return initializers; } + } - public override IEnumerable Nodes - { - get - { - yield return NewExpression; - foreach (var init in Initializers.SelectMany(item => item.Arguments.Items).Cast()) - { - yield return init; - } - } - } + public override IEnumerable Nodes + { + get + { + yield return NewExpression; + foreach (var init in Initializers.SelectMany(item => item.Arguments.Items).Cast()) + { + yield return init; + } + } + } - public override ListInitExpression DoToExpression() - { - return Expression.ListInit(NewExpression.DoToExpression(), - initializers.Select(item => item.ToElementInit()).ToArray()); - } - } -} \ No newline at end of file + public override ListInitExpression DoToExpression() + { + return Expression.ListInit(NewExpression.DoToExpression(), + initializers.Select(item => item.ToElementInit()).ToArray()); + } + } +} diff --git a/src/Uno.Core/Expressions/EditableMemberExpression.cs b/src/Uno.Core/Expressions/EditableMemberExpression.cs index 38aae30..508c60f 100644 --- a/src/Uno.Core/Expressions/EditableMemberExpression.cs +++ b/src/Uno.Core/Expressions/EditableMemberExpression.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System.Collections.Generic; using System.Linq.Expressions; using System.Reflection; @@ -21,27 +22,27 @@ namespace Uno.Expressions { - public class EditableMemberExpression : EditableExpression - { - public EditableMemberExpression(MemberExpression expression) - : base(expression, false) - { - Member = expression.Member; - Expression = expression.Expression.Edit(); - } + public class EditableMemberExpression : EditableExpression + { + public EditableMemberExpression(MemberExpression expression) + : base(expression, false) + { + Member = expression.Member; + Expression = expression.Expression.Edit(); + } - public MemberInfo Member { get; set; } + public MemberInfo Member { get; set; } - public IEditableExpression Expression { get; set; } + public IEditableExpression Expression { get; set; } - public override IEnumerable Nodes - { - get { yield return Expression; } - } + public override IEnumerable Nodes + { + get { yield return Expression; } + } - public override MemberExpression DoToExpression() - { - return System.Linq.Expressions.Expression.MakeMemberAccess(Expression.ToExpression(), Member); - } - } -} \ No newline at end of file + public override MemberExpression DoToExpression() + { + return System.Linq.Expressions.Expression.MakeMemberAccess(Expression.ToExpression(), Member); + } + } +} diff --git a/src/Uno.Core/Expressions/EditableMemberInitExpression.cs b/src/Uno.Core/Expressions/EditableMemberInitExpression.cs index 7d94b82..5890ae0 100644 --- a/src/Uno.Core/Expressions/EditableMemberInitExpression.cs +++ b/src/Uno.Core/Expressions/EditableMemberInitExpression.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,38 +14,39 @@ // limitations under the License. // // ****************************************************************** + using System.Collections.Generic; using System.Linq.Expressions; using Uno.Extensions; namespace Uno.Expressions { - public class EditableMemberInitExpression : EditableExpression - { - private readonly List bindings; + public class EditableMemberInitExpression : EditableExpression + { + private readonly List bindings; - public EditableMemberInitExpression(MemberInitExpression expression) - : base(expression, false) - { - NewExpression = expression.NewExpression.Edit(); - bindings = new List(expression.Bindings); - } + public EditableMemberInitExpression(MemberInitExpression expression) + : base(expression, false) + { + NewExpression = expression.NewExpression.Edit(); + bindings = new List(expression.Bindings); + } - public EditableNewExpression NewExpression { get; set; } + public EditableNewExpression NewExpression { get; set; } - public IList Bindings - { - get { return bindings; } - } + public IList Bindings + { + get { return bindings; } + } - public override IEnumerable Nodes - { - get { yield return NewExpression; } - } + public override IEnumerable Nodes + { + get { yield return NewExpression; } + } - public override MemberInitExpression DoToExpression() - { - return Expression.MemberInit(NewExpression.DoToExpression(), Bindings); - } - } -} \ No newline at end of file + public override MemberInitExpression DoToExpression() + { + return Expression.MemberInit(NewExpression.DoToExpression(), Bindings); + } + } +} diff --git a/src/Uno.Core/Expressions/EditableMethodCallExpression.cs b/src/Uno.Core/Expressions/EditableMethodCallExpression.cs index 62f69f0..ee3c299 100644 --- a/src/Uno.Core/Expressions/EditableMethodCallExpression.cs +++ b/src/Uno.Core/Expressions/EditableMethodCallExpression.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System.Collections.Generic; using System.Linq.Expressions; using System.Reflection; @@ -21,42 +22,42 @@ namespace Uno.Expressions { - public class EditableMethodCallExpression : EditableExpression - { - private readonly EditableExpressionCollection arguments; - - public EditableMethodCallExpression(MethodCallExpression expression) - : base(expression, false) - { - Method = expression.Method; - Object = expression.Object.Edit(); - arguments = new EditableExpressionCollection(expression.Arguments); - } - - public MethodInfo Method { get; set; } - - public IEditableExpression Object { get; set; } - - public EditableExpressionCollection Arguments - { - get { return arguments; } - } - - public override IEnumerable Nodes - { - get - { - yield return Object; - foreach (var item in Arguments.Items) - { - yield return item; - } - } - } - - public override MethodCallExpression DoToExpression() - { - return Expression.Call(Object.ToExpression(), Method, arguments.ToExpression()); - } - } -} \ No newline at end of file + public class EditableMethodCallExpression : EditableExpression + { + private readonly EditableExpressionCollection arguments; + + public EditableMethodCallExpression(MethodCallExpression expression) + : base(expression, false) + { + Method = expression.Method; + Object = expression.Object.Edit(); + arguments = new EditableExpressionCollection(expression.Arguments); + } + + public MethodInfo Method { get; set; } + + public IEditableExpression Object { get; set; } + + public EditableExpressionCollection Arguments + { + get { return arguments; } + } + + public override IEnumerable Nodes + { + get + { + yield return Object; + foreach (var item in Arguments.Items) + { + yield return item; + } + } + } + + public override MethodCallExpression DoToExpression() + { + return Expression.Call(Object.ToExpression(), Method, arguments.ToExpression()); + } + } +} diff --git a/src/Uno.Core/Expressions/EditableNewArrayExpression.cs b/src/Uno.Core/Expressions/EditableNewArrayExpression.cs index 2a7dd57..2431cf3 100644 --- a/src/Uno.Core/Expressions/EditableNewArrayExpression.cs +++ b/src/Uno.Core/Expressions/EditableNewArrayExpression.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -21,62 +22,62 @@ namespace Uno.Expressions { - public class EditableNewArrayExpression : EditableExpression - { - private readonly EditableExpressionCollection expressions; + public class EditableNewArrayExpression : EditableExpression + { + private readonly EditableExpressionCollection expressions; - public EditableNewArrayExpression(NewArrayExpression expression) - : base(expression) - { - Type = expression.Type; - expressions = new EditableExpressionCollection(expression.Expressions); - } + public EditableNewArrayExpression(NewArrayExpression expression) + : base(expression) + { + Type = expression.Type; + expressions = new EditableExpressionCollection(expression.Expressions); + } - public override ExpressionType NodeType - { - get { return base.NodeType; } - set - { - switch (value) - { - case System.Linq.Expressions.ExpressionType.NewArrayInit: - case System.Linq.Expressions.ExpressionType.NewArrayBounds: - base.NodeType = value; - break; + public override ExpressionType NodeType + { + get { return base.NodeType; } + set + { + switch (value) + { + case System.Linq.Expressions.ExpressionType.NewArrayInit: + case System.Linq.Expressions.ExpressionType.NewArrayBounds: + base.NodeType = value; + break; - default: - throw new InvalidOperationException( - "NodeType for NewArrayExpression must be ExpressionType.NewArrayInit or ExpressionType.NewArrayBounds"); - } - } - } + default: + throw new InvalidOperationException( + "NodeType for NewArrayExpression must be ExpressionType.NewArrayInit or ExpressionType.NewArrayBounds"); + } + } + } - public Type Type { get; set; } + public Type Type { get; set; } - public EditableExpressionCollection Expressions - { - get { return expressions; } - } + public EditableExpressionCollection Expressions + { + get { return expressions; } + } - public override IEnumerable Nodes - { - get { return Expressions.Items.Cast(); } - } + public override IEnumerable Nodes + { + get { return Expressions.Items.Cast(); } + } - public override NewArrayExpression DoToExpression() - { - switch (NodeType) - { - case System.Linq.Expressions.ExpressionType.NewArrayInit: - return Expression.NewArrayInit(Type, expressions.ToExpression()); + public override NewArrayExpression DoToExpression() + { + switch (NodeType) + { + case System.Linq.Expressions.ExpressionType.NewArrayInit: + return Expression.NewArrayInit(Type, expressions.ToExpression()); - case System.Linq.Expressions.ExpressionType.NewArrayBounds: - return Expression.NewArrayBounds(Type, expressions.ToExpression()); + case System.Linq.Expressions.ExpressionType.NewArrayBounds: + return Expression.NewArrayBounds(Type, expressions.ToExpression()); - default: - throw new InvalidOperationException( - "NodeType for NewArrayExpression must be ExpressionType.NewArrayInit or ExpressionType.NewArrayBounds"); - } - } - } -} \ No newline at end of file + default: + throw new InvalidOperationException( + "NodeType for NewArrayExpression must be ExpressionType.NewArrayInit or ExpressionType.NewArrayBounds"); + } + } + } +} diff --git a/src/Uno.Core/Expressions/EditableNewExpression.cs b/src/Uno.Core/Expressions/EditableNewExpression.cs index e5bb799..58ae68c 100644 --- a/src/Uno.Core/Expressions/EditableNewExpression.cs +++ b/src/Uno.Core/Expressions/EditableNewExpression.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; @@ -21,32 +22,32 @@ namespace Uno.Expressions { - public class EditableNewExpression : EditableExpression - { - private readonly EditableExpressionCollection arguments; + public class EditableNewExpression : EditableExpression + { + private readonly EditableExpressionCollection arguments; - public EditableNewExpression(NewExpression expression) - : base(expression, false) - { - arguments = new EditableExpressionCollection(expression.Arguments); - Constructor = expression.Constructor; - } + public EditableNewExpression(NewExpression expression) + : base(expression, false) + { + arguments = new EditableExpressionCollection(expression.Arguments); + Constructor = expression.Constructor; + } - public ConstructorInfo Constructor { get; set; } + public ConstructorInfo Constructor { get; set; } - public EditableExpressionCollection Arguments - { - get { return arguments; } - } + public EditableExpressionCollection Arguments + { + get { return arguments; } + } - public override IEnumerable Nodes - { - get { return Arguments.Items.Cast(); } - } + public override IEnumerable Nodes + { + get { return Arguments.Items.Cast(); } + } - public override NewExpression DoToExpression() - { - return Expression.New(Constructor, arguments.ToExpression()); - } - } -} \ No newline at end of file + public override NewExpression DoToExpression() + { + return Expression.New(Constructor, arguments.ToExpression()); + } + } +} diff --git a/src/Uno.Core/Expressions/EditableParameterExpression.cs b/src/Uno.Core/Expressions/EditableParameterExpression.cs index 9ed6911..f59e55d 100644 --- a/src/Uno.Core/Expressions/EditableParameterExpression.cs +++ b/src/Uno.Core/Expressions/EditableParameterExpression.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,34 +14,35 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Linq.Expressions; namespace Uno.Expressions { - public class EditableParameterExpression : EditableExpression - { - public EditableParameterExpression(ParameterExpression expression) - : base(expression, false) - { - Type = expression.Type; - Name = expression.Name; - } + public class EditableParameterExpression : EditableExpression + { + public EditableParameterExpression(ParameterExpression expression) + : base(expression, false) + { + Type = expression.Type; + Name = expression.Name; + } - public Type Type { get; set; } + public Type Type { get; set; } - public string Name { get; set; } + public string Name { get; set; } - public override ParameterExpression DoToExpression() - { - return Expression.Parameter(Type, Name); - } + public override ParameterExpression DoToExpression() + { + return Expression.Parameter(Type, Name); + } - protected override bool ShouldUse(ParameterExpression expression) - { - return expression.Type == Type /* && - expression.Name == Name*/; - //TODO Support Name, Index strategies to compare parameters (Require Parent Collection for index?) - } - } -} \ No newline at end of file + protected override bool ShouldUse(ParameterExpression expression) + { + return expression.Type == Type /* && + expression.Name == Name*/; + //TODO Support Name, Index strategies to compare parameters (Require Parent Collection for index?) + } + } +} diff --git a/src/Uno.Core/Expressions/EditableParameterExpressionCollection.cs b/src/Uno.Core/Expressions/EditableParameterExpressionCollection.cs index 0039c5e..aceede3 100644 --- a/src/Uno.Core/Expressions/EditableParameterExpressionCollection.cs +++ b/src/Uno.Core/Expressions/EditableParameterExpressionCollection.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; @@ -21,51 +22,51 @@ namespace Uno.Expressions { - public class EditableParameterExpressionCollection : EditableExpressionCollection - { - private readonly IEditableExpression body; - private IEnumerable parametersOverride; + public class EditableParameterExpressionCollection : EditableExpressionCollection + { + private readonly IEditableExpression body; + private IEnumerable parametersOverride; - public EditableParameterExpressionCollection(IEditableExpression body, IEnumerable items) - : base(items) - { - this.body = body; - } + public EditableParameterExpressionCollection(IEditableExpression body, IEnumerable items) + : base(items) + { + this.body = body; + } - public IEnumerable Parameters - { - get { return Items.Cast(); } - } + public IEnumerable Parameters + { + get { return Items.Cast(); } + } - public void Use(IEnumerable parameters) - { - parametersOverride = parameters; - } + public void Use(IEnumerable parameters) + { + parametersOverride = parameters; + } - public override ParameterExpression[] ToExpression() - { - var expressions = new List(); + public override ParameterExpression[] ToExpression() + { + var expressions = new List(); - if (parametersOverride == null) - { - var bodyParams = body.AllNodes().OfType(); + if (parametersOverride == null) + { + var bodyParams = body.AllNodes().OfType(); - foreach (var param in Parameters) - { - // TODO: Closure problem - Do we want closure? - var param1 = param; - //TODO Check if more than one param matches? - var bodyParam = bodyParams.FirstOrDefault(item => item.Type == param1.Type && item.Name == param1.Name); + foreach (var param in Parameters) + { + // TODO: Closure problem - Do we want closure? + var param1 = param; + //TODO Check if more than one param matches? + var bodyParam = bodyParams.FirstOrDefault(item => item.Type == param1.Type && item.Name == param1.Name); - expressions.Add((bodyParam ?? param).DoToExpression()); - } - } - else - { - expressions.AddRange(parametersOverride); - } + expressions.Add((bodyParam ?? param).DoToExpression()); + } + } + else + { + expressions.AddRange(parametersOverride); + } - return expressions.ToArray(); - } - } -} \ No newline at end of file + return expressions.ToArray(); + } + } +} diff --git a/src/Uno.Core/Expressions/EditableTypeBinaryExpression.cs b/src/Uno.Core/Expressions/EditableTypeBinaryExpression.cs index a751dab..d14b897 100644 --- a/src/Uno.Core/Expressions/EditableTypeBinaryExpression.cs +++ b/src/Uno.Core/Expressions/EditableTypeBinaryExpression.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq.Expressions; @@ -21,27 +22,27 @@ namespace Uno.Expressions { - public class EditableTypeBinaryExpression : EditableExpression - { - public EditableTypeBinaryExpression(TypeBinaryExpression expression) - : base(expression, false) - { - TypeOperand = expression.TypeOperand; - Expression = expression.Expression.Edit(); - } + public class EditableTypeBinaryExpression : EditableExpression + { + public EditableTypeBinaryExpression(TypeBinaryExpression expression) + : base(expression, false) + { + TypeOperand = expression.TypeOperand; + Expression = expression.Expression.Edit(); + } - public Type TypeOperand { get; set; } + public Type TypeOperand { get; set; } - public IEditableExpression Expression { get; set; } + public IEditableExpression Expression { get; set; } - public override IEnumerable Nodes - { - get { yield return Expression; } - } + public override IEnumerable Nodes + { + get { yield return Expression; } + } - public override TypeBinaryExpression DoToExpression() - { - return System.Linq.Expressions.Expression.TypeIs(Expression.ToExpression(), TypeOperand); - } - } -} \ No newline at end of file + public override TypeBinaryExpression DoToExpression() + { + return System.Linq.Expressions.Expression.TypeIs(Expression.ToExpression(), TypeOperand); + } + } +} diff --git a/src/Uno.Core/Expressions/EditableUnaryExpression.cs b/src/Uno.Core/Expressions/EditableUnaryExpression.cs index 47c30e2..042d69e 100644 --- a/src/Uno.Core/Expressions/EditableUnaryExpression.cs +++ b/src/Uno.Core/Expressions/EditableUnaryExpression.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq.Expressions; @@ -21,27 +22,27 @@ namespace Uno.Expressions { - public class EditableUnaryExpression : EditableExpression - { - public EditableUnaryExpression(UnaryExpression expression) - : base(expression) - { - Type = expression.Type; - Operand = expression.Operand.Edit(); - } + public class EditableUnaryExpression : EditableExpression + { + public EditableUnaryExpression(UnaryExpression expression) + : base(expression) + { + Type = expression.Type; + Operand = expression.Operand.Edit(); + } - public Type Type { get; set; } + public Type Type { get; set; } - public IEditableExpression Operand { get; set; } + public IEditableExpression Operand { get; set; } - public override IEnumerable Nodes - { - get { yield return Operand; } - } + public override IEnumerable Nodes + { + get { yield return Operand; } + } - public override UnaryExpression DoToExpression() - { - return Expression.MakeUnary(NodeType, Operand.ToExpression(), Type); - } - } -} \ No newline at end of file + public override UnaryExpression DoToExpression() + { + return Expression.MakeUnary(NodeType, Operand.ToExpression(), Type); + } + } +} diff --git a/src/Uno.Core/Expressions/ExpressionExtensions.cs b/src/Uno.Core/Expressions/ExpressionExtensions.cs index 9e46073..09568c9 100644 --- a/src/Uno.Core/Expressions/ExpressionExtensions.cs +++ b/src/Uno.Core/Expressions/ExpressionExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Linq; using System.Linq.Expressions; @@ -21,138 +22,138 @@ namespace Uno.Extensions { - public static class ExpressionExtensions - { - public static string GetMemberName(this Expression> selector) - { - var member = selector.FindMember(); - - return member == null ? null : member.Name; - } - - public static MemberInfo FindMember(this Expression> selector) - { - var memberExpression = selector.Body as MemberExpression; - - if (memberExpression == null) - { - selector.Body.Maybe(u => memberExpression = u.Operand as MemberExpression); - } - - if (memberExpression == null) - { - return null; - } - else - { - return memberExpression.Member; - } - } - - public static string GetSelectedMemberName(this Expression> selector) - { - if (selector == null) - { - return null; - } - else - { - if (selector.Body is MemberExpression) - { - var memberExpression = selector.Body as MemberExpression; - return memberExpression.Member.Name; - } - else if (selector.Body is UnaryExpression) - { - var unaryExpression = selector.Body as UnaryExpression; - return (unaryExpression.Operand as MemberExpression).Member.Name; - } - return null; - - } - } - - public static Expression> And(this Expression> left, - params Expression>[] items) - { - var result = left; - - items.ForEach(item => result = Binary(CompositionType.And, result, item)); - - return result; - } - - public static Expression> Or(this Expression> left, - params Expression>[] items) - { - var result = left; - - items.ForEach(item => result = Binary(CompositionType.Or, result, item)); - - return result; - } - - public static Expression> Not(this Expression> expression) - { - return Expression.Lambda>(Expression.Not(expression.Body), expression.Parameters); - } - - public static Expression> And(this Expression> left, params Expression>[] items) - { - var result = left; - - items.ForEach(item => result = Binary(CompositionType.And, result, item)); - - return result; - } - - public static Expression> Or(this Expression> left, params Expression>[] items) - { - var result = left; - - items.ForEach(item => result = Binary(CompositionType.Or, result, item)); - - return result; - } - - public static Expression> Not(this Expression> expression) - { - return Expression.Lambda>(Expression.Not(expression.Body), expression.Parameters); - } - - private static Expression Binary(CompositionType type, Expression left, Expression right) - { - if (left == null) - { - return right; - } - - if (right == null) - { - return left; - } - - right = ReplaceParameters(left, right); - - var newBody = Binary(type, left.Body, right.Body); - - return Expression.Lambda(newBody, left.Parameters); - } - - private static Expression ReplaceParameters(Expression source, Expression target) - { - var editableTarget = target.Edit(); - - editableTarget.Use(source.Parameters.Cast()); - - target = editableTarget.ToExpression(); - - return target; - } - - private static Expression Binary(CompositionType type, Expression left, Expression right) - { - return type == CompositionType.And ? Expression.And(left, right) : Expression.Or(left, right); - } - } -} \ No newline at end of file + public static class ExpressionExtensions + { + public static string GetMemberName(this Expression> selector) + { + var member = selector.FindMember(); + + return member == null ? null : member.Name; + } + + public static MemberInfo FindMember(this Expression> selector) + { + var memberExpression = selector.Body as MemberExpression; + + if (memberExpression == null) + { + selector.Body.Maybe(u => memberExpression = u.Operand as MemberExpression); + } + + if (memberExpression == null) + { + return null; + } + else + { + return memberExpression.Member; + } + } + + public static string GetSelectedMemberName(this Expression> selector) + { + if (selector == null) + { + return null; + } + else + { + if (selector.Body is MemberExpression) + { + var memberExpression = selector.Body as MemberExpression; + return memberExpression.Member.Name; + } + else if (selector.Body is UnaryExpression) + { + var unaryExpression = selector.Body as UnaryExpression; + return (unaryExpression.Operand as MemberExpression).Member.Name; + } + return null; + + } + } + + public static Expression> And(this Expression> left, + params Expression>[] items) + { + var result = left; + + items.ForEach(item => result = Binary(CompositionType.And, result, item)); + + return result; + } + + public static Expression> Or(this Expression> left, + params Expression>[] items) + { + var result = left; + + items.ForEach(item => result = Binary(CompositionType.Or, result, item)); + + return result; + } + + public static Expression> Not(this Expression> expression) + { + return Expression.Lambda>(Expression.Not(expression.Body), expression.Parameters); + } + + public static Expression> And(this Expression> left, params Expression>[] items) + { + var result = left; + + items.ForEach(item => result = Binary(CompositionType.And, result, item)); + + return result; + } + + public static Expression> Or(this Expression> left, params Expression>[] items) + { + var result = left; + + items.ForEach(item => result = Binary(CompositionType.Or, result, item)); + + return result; + } + + public static Expression> Not(this Expression> expression) + { + return Expression.Lambda>(Expression.Not(expression.Body), expression.Parameters); + } + + private static Expression Binary(CompositionType type, Expression left, Expression right) + { + if (left == null) + { + return right; + } + + if (right == null) + { + return left; + } + + right = ReplaceParameters(left, right); + + var newBody = Binary(type, left.Body, right.Body); + + return Expression.Lambda(newBody, left.Parameters); + } + + private static Expression ReplaceParameters(Expression source, Expression target) + { + var editableTarget = target.Edit(); + + editableTarget.Use(source.Parameters.Cast()); + + target = editableTarget.ToExpression(); + + return target; + } + + private static Expression Binary(CompositionType type, Expression left, Expression right) + { + return type == CompositionType.And ? Expression.And(left, right) : Expression.Or(left, right); + } + } +} diff --git a/src/Uno.Core/Expressions/ExpressionFactory.cs b/src/Uno.Core/Expressions/ExpressionFactory.cs index 9428f21..e16a40a 100644 --- a/src/Uno.Core/Expressions/ExpressionFactory.cs +++ b/src/Uno.Core/Expressions/ExpressionFactory.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,23 +14,24 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Linq.Expressions; namespace Uno.Expressions { - public static class ExpressionFactory - { - public static Expression> PropertyEqualConstant(string propertyName, object value) - { - var parameter = Expression.Parameter(typeof (T), "item"); + public static class ExpressionFactory + { + public static Expression> PropertyEqualConstant(string propertyName, object value) + { + var parameter = Expression.Parameter(typeof (T), "item"); - var property = Expression.Property(parameter, propertyName); - var constant = Expression.Constant(value); + var property = Expression.Property(parameter, propertyName); + var constant = Expression.Constant(value); - var body = Expression.Equal(property, constant); + var body = Expression.Equal(property, constant); - return Expression.Lambda>(body, parameter); - } - } -} \ No newline at end of file + return Expression.Lambda>(body, parameter); + } + } +} diff --git a/src/Uno.Core/Expressions/Expressions.cs b/src/Uno.Core/Expressions/Expressions.cs index 53be7ca..dc4dcea 100644 --- a/src/Uno.Core/Expressions/Expressions.cs +++ b/src/Uno.Core/Expressions/Expressions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,14 +14,15 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Linq.Expressions; namespace Uno.Expressions { - public class Expressions - { - public static readonly Expression> False = item => false; - public static readonly Expression> True = item => true; - } -} \ No newline at end of file + public class Expressions + { + public static readonly Expression> False = item => false; + public static readonly Expression> True = item => true; + } +} diff --git a/src/Uno.Core/Expressions/IEditableExpression.cs b/src/Uno.Core/Expressions/IEditableExpression.cs index 3a6ee3f..1aaa85f 100644 --- a/src/Uno.Core/Expressions/IEditableExpression.cs +++ b/src/Uno.Core/Expressions/IEditableExpression.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,19 +14,20 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq.Expressions; namespace Uno.Expressions { - public interface IEditableExpression - { - Expression OriginalExpression { get; } - ExpressionType NodeType { get; set; } - Type ExpressionType { get; } - IEnumerable Nodes { get; } - Expression ToExpression(); - void Use(Expression expression); - } -} \ No newline at end of file + public interface IEditableExpression + { + Expression OriginalExpression { get; } + ExpressionType NodeType { get; set; } + Type ExpressionType { get; } + IEnumerable Nodes { get; } + Expression ToExpression(); + void Use(Expression expression); + } +} diff --git a/src/Uno.Core/Expressions/PredicateExpression.Generic.cs b/src/Uno.Core/Expressions/PredicateExpression.Generic.cs index a8a4b50..4136eca 100644 --- a/src/Uno.Core/Expressions/PredicateExpression.Generic.cs +++ b/src/Uno.Core/Expressions/PredicateExpression.Generic.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,82 +14,83 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Linq.Expressions; using Uno.Extensions; namespace Uno.Expressions { - public class PredicateExpression - { - private readonly Expression> expression; + public class PredicateExpression + { + private readonly Expression> expression; - public PredicateExpression(Expression> expression) - { - //TODO Could make sure the parameter is "item" - this.expression = expression; - } + public PredicateExpression(Expression> expression) + { + //TODO Could make sure the parameter is "item" + this.expression = expression; + } - public Expression> Expression - { - get { return expression; } - } + public Expression> Expression + { + get { return expression; } + } - public static implicit operator Expression>(PredicateExpression proxy) - { - return proxy.Expression; - } + public static implicit operator Expression>(PredicateExpression proxy) + { + return proxy.Expression; + } - public static implicit operator PredicateExpression(Expression> expression) - { - return new PredicateExpression(expression); - } + public static implicit operator PredicateExpression(Expression> expression) + { + return new PredicateExpression(expression); + } #if !WINDOWS_PHONE - public static implicit operator Func(PredicateExpression proxy) - { - return proxy.Expression.Compile(); - } + public static implicit operator Func(PredicateExpression proxy) + { + return proxy.Expression.Compile(); + } #endif - public static bool operator true(PredicateExpression expression) - { - return false; - } + public static bool operator true(PredicateExpression expression) + { + return false; + } - public static bool operator false(PredicateExpression expression) - { - return false; - } + public static bool operator false(PredicateExpression expression) + { + return false; + } - public static PredicateExpression operator &(PredicateExpression lhs, PredicateExpression rhs) - { - if (lhs == null) - { - return rhs; - } + public static PredicateExpression operator &(PredicateExpression lhs, PredicateExpression rhs) + { + if (lhs == null) + { + return rhs; + } - if (rhs == null) - { - return lhs; - } + if (rhs == null) + { + return lhs; + } - return lhs.Expression.And(rhs.Expression); - } + return lhs.Expression.And(rhs.Expression); + } - public static PredicateExpression operator |(PredicateExpression lhs, PredicateExpression rhs) - { - if (lhs == null) - { - return rhs; - } + public static PredicateExpression operator |(PredicateExpression lhs, PredicateExpression rhs) + { + if (lhs == null) + { + return rhs; + } - if (rhs == null) - { - return lhs; - } + if (rhs == null) + { + return lhs; + } - return lhs.Expression.Or(rhs.Expression); - } - } -} \ No newline at end of file + return lhs.Expression.Or(rhs.Expression); + } + } +} diff --git a/src/Uno.Core/Expressions/PredicateExpression.cs b/src/Uno.Core/Expressions/PredicateExpression.cs index 0247cbe..e981b23 100644 --- a/src/Uno.Core/Expressions/PredicateExpression.cs +++ b/src/Uno.Core/Expressions/PredicateExpression.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,82 +14,83 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Linq.Expressions; using Uno.Extensions; namespace Uno.Expressions { - public class PredicateExpression - { - private readonly Expression> expression; + public class PredicateExpression + { + private readonly Expression> expression; - public PredicateExpression(Expression> expression) - { - //TODO Could make sure the parameter is "item" - this.expression = expression; - } + public PredicateExpression(Expression> expression) + { + //TODO Could make sure the parameter is "item" + this.expression = expression; + } - public Expression> Expression - { - get { return expression; } - } + public Expression> Expression + { + get { return expression; } + } - public static implicit operator Expression>(PredicateExpression proxy) - { - return proxy.Expression; - } + public static implicit operator Expression>(PredicateExpression proxy) + { + return proxy.Expression; + } - public static implicit operator PredicateExpression(Expression> expression) - { - return new PredicateExpression(expression); - } + public static implicit operator PredicateExpression(Expression> expression) + { + return new PredicateExpression(expression); + } #if !WINDOWS_PHONE - public static implicit operator Func(PredicateExpression proxy) - { - return proxy.Expression.Compile(); - } + public static implicit operator Func(PredicateExpression proxy) + { + return proxy.Expression.Compile(); + } #endif - public static bool operator true(PredicateExpression expression) - { - return false; - } + public static bool operator true(PredicateExpression expression) + { + return false; + } - public static bool operator false(PredicateExpression expression) - { - return false; - } + public static bool operator false(PredicateExpression expression) + { + return false; + } - public static PredicateExpression operator &(PredicateExpression lhs, PredicateExpression rhs) - { - if (lhs == null) - { - return rhs; - } + public static PredicateExpression operator &(PredicateExpression lhs, PredicateExpression rhs) + { + if (lhs == null) + { + return rhs; + } - if (rhs == null) - { - return lhs; - } + if (rhs == null) + { + return lhs; + } - return lhs.Expression.And(rhs.Expression); - } + return lhs.Expression.And(rhs.Expression); + } - public static PredicateExpression operator |(PredicateExpression lhs, PredicateExpression rhs) - { - if (lhs == null) - { - return rhs; - } + public static PredicateExpression operator |(PredicateExpression lhs, PredicateExpression rhs) + { + if (lhs == null) + { + return rhs; + } - if (rhs == null) - { - return lhs; - } + if (rhs == null) + { + return lhs; + } - return lhs.Expression.Or(rhs.Expression); - } - } -} \ No newline at end of file + return lhs.Expression.Or(rhs.Expression); + } + } +} diff --git a/src/Uno.Core/Extensibility/ExtensibilityModel.cs b/src/Uno.Core/Extensibility/ExtensibilityModel.cs index f648fff..761b826 100644 --- a/src/Uno.Core/Extensibility/ExtensibilityModel.cs +++ b/src/Uno.Core/Extensibility/ExtensibilityModel.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Extensions/ActionAsyncExtensions.cs b/src/Uno.Core/Extensions/ActionAsyncExtensions.cs index 634fea5..5aba5b0 100644 --- a/src/Uno.Core/Extensions/ActionAsyncExtensions.cs +++ b/src/Uno.Core/Extensions/ActionAsyncExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Text; @@ -25,8 +26,8 @@ namespace Uno.Extensions /// /// Extensions of /// - public static class ActionAsyncExtensions - { + public static class ActionAsyncExtensions + { /// /// Invoke the if not null. /// diff --git a/src/Uno.Core/Extensions/ActionExtensions.cs b/src/Uno.Core/Extensions/ActionExtensions.cs index 2819438..eda53c6 100644 --- a/src/Uno.Core/Extensions/ActionExtensions.cs +++ b/src/Uno.Core/Extensions/ActionExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -21,11 +22,8 @@ namespace Uno.Extensions { - public static class ActionExtensions - { - public static IDisposable ToDisposable(this Action action) - { - return new DisposableAction(action); - } - } + public static class ActionExtensions + { + public static IDisposable ToDisposable(this Action action) => new DisposableAction(action); + } } diff --git a/src/Uno.Core/Extensions/ComparableExtensions.cs b/src/Uno.Core/Extensions/ComparableExtensions.cs index 84ac35c..4610aab 100644 --- a/src/Uno.Core/Extensions/ComparableExtensions.cs +++ b/src/Uno.Core/Extensions/ComparableExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -21,91 +22,91 @@ namespace Uno.Extensions { - public static class ComparableExtensions - { - public static T Min(this T left, T right) - where T : IComparable - { - if (left == null) - { - return right; - } - else if (right == null) - { - return left; - } - else - { - return left.CompareTo(right) < 0 ? left : right; - } - } + public static class ComparableExtensions + { + public static T Min(this T left, T right) + where T : IComparable + { + if (left == null) + { + return right; + } + else if (right == null) + { + return left; + } + else + { + return left.CompareTo(right) < 0 ? left : right; + } + } - public static T Max(this T left, T right) - where T : IComparable - { - if (left == null) - { - return right; - } - else if (right == null) - { - return left; - } - else - { - return left.CompareTo(right) > 0 ? left : right; - } - } + public static T Max(this T left, T right) + where T : IComparable + { + if (left == null) + { + return right; + } + else if (right == null) + { + return left; + } + else + { + return left.CompareTo(right) > 0 ? left : right; + } + } - public static T? Min(this T? left, T? right) - where T : struct, IComparable - { - if (left == null) - { - return right; - } - else if (right == null) - { - return left; - } - else - { - return left.Value.CompareTo(right.Value) < 0 ? left.Value : right.Value; - } - } + public static T? Min(this T? left, T? right) + where T : struct, IComparable + { + if (left == null) + { + return right; + } + else if (right == null) + { + return left; + } + else + { + return left.Value.CompareTo(right.Value) < 0 ? left.Value : right.Value; + } + } - public static T? Max(this T? left, T? right) - where T : struct, IComparable - { - if (left == null) - { - return right; - } - else if (right == null) - { - return left; - } - else - { - return left.Value.CompareTo(right.Value) > 0 ? left.Value : right.Value; - } - } + public static T? Max(this T? left, T? right) + where T : struct, IComparable + { + if (left == null) + { + return right; + } + else if (right == null) + { + return left; + } + else + { + return left.Value.CompareTo(right.Value) > 0 ? left.Value : right.Value; + } + } - public static int SafeCompareTo(this T left, T right) - where T : IComparable - { - if(left != null) - { - return left.CompareTo(right); - } - else if(right == null) - { - return 0; - } - else - { - return -1; - } - } - } + public static int SafeCompareTo(this T left, T right) + where T : IComparable + { + if(left != null) + { + return left.CompareTo(right); + } + else if(right == null) + { + return 0; + } + else + { + return -1; + } + } + } } diff --git a/src/Uno.Core/Extensions/CurryExtensions.cs b/src/Uno.Core/Extensions/CurryExtensions.cs index 3c46cab..3ea94e8 100644 --- a/src/Uno.Core/Extensions/CurryExtensions.cs +++ b/src/Uno.Core/Extensions/CurryExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Threading; diff --git a/src/Uno.Core/Extensions/DateTimeExtensions.cs b/src/Uno.Core/Extensions/DateTimeExtensions.cs index 1e824ce..e1491cb 100644 --- a/src/Uno.Core/Extensions/DateTimeExtensions.cs +++ b/src/Uno.Core/Extensions/DateTimeExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using Uno.Extensions.ValueType; @@ -52,66 +53,66 @@ public static DateTime AddWeekDays(this DateTime instance, TimeSpan timeSpan) return AddWeekDays(instance, Convert.ToInt32(timeSpan.TotalDays)); } - public static bool Equal(this DateTime lhs, DateTime rhs, DateTimeUnit unit) - { - if (unit.ContainsAll(DateTimeUnit.Year)) - { - if (lhs.Year != rhs.Year) - { - return false; - } - } - - if (unit.ContainsAll(DateTimeUnit.Month)) - { - if (lhs.Month != rhs.Month) - { - return false; - } - } - - if (unit.ContainsAll(DateTimeUnit.Day)) - { - if (lhs.Day != rhs.Day) - { - return false; - } - } - - if (unit.ContainsAll(DateTimeUnit.Hour)) - { - if (lhs.Hour != rhs.Hour) - { - return false; - } - } - - if (unit.ContainsAll(DateTimeUnit.Minute)) - { - if (lhs.Minute != rhs.Minute) - { - return false; - } - } - - if (unit.ContainsAll(DateTimeUnit.Second)) - { - if (lhs.Second != rhs.Second) - { - return false; - } - } - - if (unit.ContainsAll(DateTimeUnit.Millisecond)) - { - if (lhs.Millisecond != rhs.Millisecond) - { - return false; - } - } - - return true; - } + public static bool Equal(this DateTime lhs, DateTime rhs, DateTimeUnit unit) + { + if (unit.ContainsAll(DateTimeUnit.Year)) + { + if (lhs.Year != rhs.Year) + { + return false; + } + } + + if (unit.ContainsAll(DateTimeUnit.Month)) + { + if (lhs.Month != rhs.Month) + { + return false; + } + } + + if (unit.ContainsAll(DateTimeUnit.Day)) + { + if (lhs.Day != rhs.Day) + { + return false; + } + } + + if (unit.ContainsAll(DateTimeUnit.Hour)) + { + if (lhs.Hour != rhs.Hour) + { + return false; + } + } + + if (unit.ContainsAll(DateTimeUnit.Minute)) + { + if (lhs.Minute != rhs.Minute) + { + return false; + } + } + + if (unit.ContainsAll(DateTimeUnit.Second)) + { + if (lhs.Second != rhs.Second) + { + return false; + } + } + + if (unit.ContainsAll(DateTimeUnit.Millisecond)) + { + if (lhs.Millisecond != rhs.Millisecond) + { + return false; + } + } + + return true; + } public static DateTime Truncate(this DateTime instance, DateTimeUnit unit) { @@ -282,4 +283,4 @@ public static DateTimeOffset FromUnixTimeMilliseconds(long milliseconds, TimeSpa return new DateTimeOffset((milliseconds + UnixEpochMilliseconds + (long)offset.TotalMilliseconds) * TimeSpan.TicksPerMillisecond, offset); } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Extensions/DoubleExtensions.cs b/src/Uno.Core/Extensions/DoubleExtensions.cs index 5d9234f..7c95eac 100644 --- a/src/Uno.Core/Extensions/DoubleExtensions.cs +++ b/src/Uno.Core/Extensions/DoubleExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Text; diff --git a/src/Uno.Core/Extensions/EnumExtensions.cs b/src/Uno.Core/Extensions/EnumExtensions.cs index 3ed54dd..3630128 100644 --- a/src/Uno.Core/Extensions/EnumExtensions.cs +++ b/src/Uno.Core/Extensions/EnumExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Linq; using System.Reflection; @@ -31,9 +32,9 @@ public static class EnumHelper /// Note: Considerer using memoization if called often. /// public static string[] GetNames() - { + { #if WINDOWS_UWP || HAS_CRIPPLEDREFLECTION - return Enum.GetNames(typeof (T)); + return Enum.GetNames(typeof (T)); #else var flds = typeof(T).GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); diff --git a/src/Uno.Core/Extensions/ExceptionExtensions.cs b/src/Uno.Core/Extensions/ExceptionExtensions.cs index fcea3c8..a16c756 100644 --- a/src/Uno.Core/Extensions/ExceptionExtensions.cs +++ b/src/Uno.Core/Extensions/ExceptionExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Diagnostics; using System.Globalization; diff --git a/src/Uno.Core/Extensions/ExtensionPoint.cs b/src/Uno.Core/Extensions/ExtensionPoint.cs index e0aad45..8096992 100644 --- a/src/Uno.Core/Extensions/ExtensionPoint.cs +++ b/src/Uno.Core/Extensions/ExtensionPoint.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,43 +14,44 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno.Extensions { - public class ExtensionPoint : IExtensionPoint - { - private readonly Type type; - private readonly T value; - - public ExtensionPoint(T value) - { - this.value = value; - } - - public ExtensionPoint(Type type) - { - this.type = type; - } - - #region IExtensionPoint Members - - public T ExtendedValue - { - get { return value; } - } - - object IExtensionPoint.ExtendedValue - { - get { return value; } - } - - public Type ExtendedType - { - // TODO: value might not be null - get { return type ?? (value == null ? typeof (T) : value.GetType()); } - } - - #endregion - } -} \ No newline at end of file + public class ExtensionPoint : IExtensionPoint + { + private readonly Type type; + private readonly T value; + + public ExtensionPoint(T value) + { + this.value = value; + } + + public ExtensionPoint(Type type) + { + this.type = type; + } + + #region IExtensionPoint Members + + public T ExtendedValue + { + get { return value; } + } + + object IExtensionPoint.ExtendedValue + { + get { return value; } + } + + public Type ExtendedType + { + // TODO: value might not be null + get { return type ?? (value == null ? typeof (T) : value.GetType()); } + } + + #endregion + } +} diff --git a/src/Uno.Core/Extensions/ExtensionsProvider.cs b/src/Uno.Core/Extensions/ExtensionsProvider.cs index 804cd5c..d888c08 100644 --- a/src/Uno.Core/Extensions/ExtensionsProvider.cs +++ b/src/Uno.Core/Extensions/ExtensionsProvider.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,35 +14,36 @@ // limitations under the License. // // ****************************************************************** + using System; using CommonServiceLocator; namespace Uno.Extensions { - public static class ExtensionsProvider - { - public static TService Get() - where TConcrete : TService, new() + public static class ExtensionsProvider + { + public static TService Get() + where TConcrete : TService, new() where TService : class - { - var service = ServiceLocator.IsLocationProviderSet ? ServiceLocator.Current.GetInstance() : null; + { + var service = ServiceLocator.IsLocationProviderSet ? ServiceLocator.Current.GetInstance() : null; - if (service == null) - { - service = new TConcrete(); - } + if (service == null) + { + service = new TConcrete(); + } - return service; - } + return service; + } public static TService Get(Func defaultFactory) where TService : class { var service = - ServiceLocator.IsLocationProviderSet ? ServiceLocator.Current.GetInstance() : null + ServiceLocator.IsLocationProviderSet ? ServiceLocator.Current.GetInstance() : null ?? defaultFactory(); return service; } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Extensions/FormattableExtensions.cs b/src/Uno.Core/Extensions/FormattableExtensions.cs index fc9f314..232ad47 100644 --- a/src/Uno.Core/Extensions/FormattableExtensions.cs +++ b/src/Uno.Core/Extensions/FormattableExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Globalization; diff --git a/src/Uno.Core/Extensions/FuncAsyncExtensions.cs b/src/Uno.Core/Extensions/FuncAsyncExtensions.cs index 10e8f92..6bff305 100644 --- a/src/Uno.Core/Extensions/FuncAsyncExtensions.cs +++ b/src/Uno.Core/Extensions/FuncAsyncExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Runtime.CompilerServices; @@ -187,4 +188,4 @@ public static FuncAsync LockInvocation(this Fu } } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Extensions/FuncExtensions.ApplyMemoized.cs b/src/Uno.Core/Extensions/FuncExtensions.ApplyMemoized.cs index 4ac60a4..9dcdc0a 100644 --- a/src/Uno.Core/Extensions/FuncExtensions.ApplyMemoized.cs +++ b/src/Uno.Core/Extensions/FuncExtensions.ApplyMemoized.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + #if !SILVERLIGHT using System; using System.Collections.Concurrent; @@ -179,4 +180,4 @@ public static Func AsWeakMemoized action, Cancel } } } -#endif \ No newline at end of file +#endif diff --git a/src/Uno.Core/Extensions/FuncExtensions.cs b/src/Uno.Core/Extensions/FuncExtensions.cs index 0d7245b..3a326a5 100644 --- a/src/Uno.Core/Extensions/FuncExtensions.cs +++ b/src/Uno.Core/Extensions/FuncExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,79 +14,80 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; namespace Uno.Extensions { - public static partial class FuncExtensions - { - public static Func Not(this Func func) - { - return item => !func(item); - } + public static partial class FuncExtensions + { + public static Func Not(this Func func) + { + return item => !func(item); + } - public static Func ToFunc(this Func func) - { - return () => func(null); - } + public static Func ToFunc(this Func func) + { + return () => func(null); + } - public static Func ToFunc(this Func func) - { - return notUsed => func(); - } + public static Func ToFunc(this Func func) + { + return notUsed => func(); + } - public static Action ToAction(this Func func) - { - // TODO: conver to method group? - return item => func(item); - } + public static Action ToAction(this Func func) + { + // TODO: conver to method group? + return item => func(item); + } - public static Action ToAction(this Func func) - { - return () => func(null); - } + public static Action ToAction(this Func func) + { + return () => func(null); + } - public static Action ToAction(this Action> action) - { - return (i, item) => action(new KeyValuePair(i, item)); - } + public static Action ToAction(this Action> action) + { + return (i, item) => action(new KeyValuePair(i, item)); + } - public static Func ToFunc(this Action action) - { - return item => - { - action(item); - return null; - }; - } + public static Func ToFunc(this Action action) + { + return item => + { + action(item); + return null; + }; + } - public static Func ToInterceptor(this Action action) - { - return item => - { - action(item); - return item; - }; - } + public static Func ToInterceptor(this Action action) + { + return item => + { + action(item); + return item; + }; + } - public static Func ToFunc(this Action action) - { - return ToFunc(action); - } + public static Func ToFunc(this Action action) + { + return ToFunc(action); + } - public static Func ToFunc(this Action action) - { - return item => - { - action(); - return item; - }; - } + public static Func ToFunc(this Action action) + { + return item => + { + action(); + return item; + }; + } - public static Func ToFunc(this Func func) - { - return () => (U) (object) func(); - } - } -} \ No newline at end of file + public static Func ToFunc(this Func func) + { + return () => (U) (object) func(); + } + } +} diff --git a/src/Uno.Core/Extensions/FuncMemoizeExtensions.cs b/src/Uno.Core/Extensions/FuncMemoizeExtensions.cs index 02121dd..6745df7 100644 --- a/src/Uno.Core/Extensions/FuncMemoizeExtensions.cs +++ b/src/Uno.Core/Extensions/FuncMemoizeExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Extensions/IExtensionPoint.Generic.cs b/src/Uno.Core/Extensions/IExtensionPoint.Generic.cs index 40a9ddf..636945b 100644 --- a/src/Uno.Core/Extensions/IExtensionPoint.Generic.cs +++ b/src/Uno.Core/Extensions/IExtensionPoint.Generic.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,10 +14,11 @@ // limitations under the License. // // ****************************************************************** + namespace Uno.Extensions { - public interface IExtensionPoint : IExtensionPoint - { - new T ExtendedValue { get; } - } -} \ No newline at end of file + public interface IExtensionPoint : IExtensionPoint + { + new T ExtendedValue { get; } + } +} diff --git a/src/Uno.Core/Extensions/IExtensionPoint.cs b/src/Uno.Core/Extensions/IExtensionPoint.cs index 2497427..270f34d 100644 --- a/src/Uno.Core/Extensions/IExtensionPoint.cs +++ b/src/Uno.Core/Extensions/IExtensionPoint.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,13 +14,14 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno.Extensions { - public interface IExtensionPoint - { - object ExtendedValue { get; } - Type ExtendedType { get; } - } -} \ No newline at end of file + public interface IExtensionPoint + { + object ExtendedValue { get; } + Type ExtendedType { get; } + } +} diff --git a/src/Uno.Core/Extensions/IIndentedStringBuilder.cs b/src/Uno.Core/Extensions/IIndentedStringBuilder.cs index dec795e..099a5d3 100644 --- a/src/Uno.Core/Extensions/IIndentedStringBuilder.cs +++ b/src/Uno.Core/Extensions/IIndentedStringBuilder.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno.Extensions @@ -71,4 +72,4 @@ public interface IIndentedStringBuilder /// string ToString(); } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Extensions/IndentedStringBuilder.cs b/src/Uno.Core/Extensions/IndentedStringBuilder.cs index e112725..0c62e8d 100644 --- a/src/Uno.Core/Extensions/IndentedStringBuilder.cs +++ b/src/Uno.Core/Extensions/IndentedStringBuilder.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Text; diff --git a/src/Uno.Core/Extensions/IndentedStringBuilderExtensions.cs b/src/Uno.Core/Extensions/IndentedStringBuilderExtensions.cs index cbdfe4f..a4423ad 100644 --- a/src/Uno.Core/Extensions/IndentedStringBuilderExtensions.cs +++ b/src/Uno.Core/Extensions/IndentedStringBuilderExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Globalization; @@ -21,8 +22,8 @@ namespace Uno.Extensions { - public static class IndentedStringBuilderExtensions - { + public static class IndentedStringBuilderExtensions + { public static void AppendLine(this IIndentedStringBuilder builder, IFormatProvider formatProvider, string pattern, params object[] replacements) { builder.AppendFormat(formatProvider, pattern, replacements); diff --git a/src/Uno.Core/Extensions/InvocationLockingMode.cs b/src/Uno.Core/Extensions/InvocationLockingMode.cs index 8a607cd..420a1a5 100644 --- a/src/Uno.Core/Extensions/InvocationLockingMode.cs +++ b/src/Uno.Core/Extensions/InvocationLockingMode.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + namespace Uno.Extensions { /// @@ -31,4 +32,4 @@ public enum InvocationLockingMode /// Share, } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Extensions/NullableExtensions.cs b/src/Uno.Core/Extensions/NullableExtensions.cs index 0d45b7e..b3e0a37 100644 --- a/src/Uno.Core/Extensions/NullableExtensions.cs +++ b/src/Uno.Core/Extensions/NullableExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Extensions/ObjectExtensions.cs b/src/Uno.Core/Extensions/ObjectExtensions.cs index 3b2fd0e..b6b1618 100644 --- a/src/Uno.Core/Extensions/ObjectExtensions.cs +++ b/src/Uno.Core/Extensions/ObjectExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,149 +14,150 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; namespace Uno.Extensions { - public static class ObjectExtensions - { - public static ExtensionPoint Extensions(this T value) - { - return new ExtensionPoint(value); - } - - public static bool IsDefault(this ExtensionPoint extensionPoint) - { - return Equals(extensionPoint.ExtendedValue, default(T)); - } - - public static void Dispose(this ExtensionPoint extensionPoint) - { - var disposable = extensionPoint.ExtendedValue as IDisposable; - - disposable.Maybe(d => d.Dispose()); - } - - public static IDisposable Using(this ExtensionPoint extensionPoint) - { - var disposable = extensionPoint.ExtendedValue as IDisposable; - - return disposable ?? NullDisposable.Instance; - } - - public static void Maybe(this TInstance instance, Action action) - { - if (instance != null) - { - action(); - } - } - - public static void Maybe(this TInstance instance, Action action) - { - if (instance != null) - { - action(instance); - } - } - - public static void Maybe(this object instance, Action action) - where TInstance : class - { - Maybe(instance as TInstance, action); - } - - public static TResult SelectOrDefault(this TInstance instance, Func selector) - { - return SelectOrDefault(instance, selector, default(TResult)); - } - - public static TResult SelectOrDefault(this TInstance instance, Func selector, TResult defaultValue) - { - return instance == null ? defaultValue : selector(instance); - } - - public static bool SafeEquals(this T obj, T other) - where T : class - { - if (obj == null) - { - return other == null; - } - else - { - return obj.Equals(other); - } - } - - /// - /// A helper method to allow for locally defined extension-method like methods. Avoids the creation of an external static class - /// in the context of fluent expressions. - /// - public static TResult Apply(this TSource source, Func selector) - { - return selector(source); - } - - /// - /// A helper method that allows the execution of an action in a fluent expression. - /// - /// The action to execute on the source object - /// The source instance - public static TSource Apply(this TSource source, Action action) - { - action(source); - - return source; - } - - /// - /// A helper method that allows the execution of an action in a fluent expression. The action will be executed if the condition is true. - /// - /// A boolean value that indicates if the action should be executed. - /// The action to execute, the parameter will contain source - /// Returns the source instance - public static TSource Apply(this TSource source, bool condition, Action action) - { - if (condition) - { - action(source); - } - - return source; - } - - /// - /// Gets a boolean value that determines if a specific value is within a list of accepted values. - /// Use this when it's not necessary or when it's overkill to declare the list of accepted values - /// as a readonly field. For example, can be used to check if one enum value is within a set without that - /// enum being marked as [Flags]. - /// - /// - /// The source value. - /// The list of accepted values. - /// - public static bool IsOneOf(this TSource source, params TSource[] acceptedValues) - { - return acceptedValues?.Contains(source) ?? false; - } - - /// - /// Gets a boolean value that determines if a specific value is within a list of accepted values. - /// Use this when it's not necessary or when it's overkill to declare the list of accepted values - /// as a readonly field. For example, can be used to check if one enum value is within a set without that - /// enum being marked as [Flags]. - /// - /// - /// The source value. - /// The comparer to use to determine equality. - /// The list of accepted values. - /// - public static bool IsOneOf(this TSource source, IEqualityComparer comparer, params TSource[] acceptedValues) - { - return acceptedValues?.Contains(source, comparer) ?? false; - } - } + public static class ObjectExtensions + { + public static ExtensionPoint Extensions(this T value) + { + return new ExtensionPoint(value); + } + + public static bool IsDefault(this ExtensionPoint extensionPoint) + { + return Equals(extensionPoint.ExtendedValue, default(T)); + } + + public static void Dispose(this ExtensionPoint extensionPoint) + { + var disposable = extensionPoint.ExtendedValue as IDisposable; + + disposable.Maybe(d => d.Dispose()); + } + + public static IDisposable Using(this ExtensionPoint extensionPoint) + { + var disposable = extensionPoint.ExtendedValue as IDisposable; + + return disposable ?? NullDisposable.Instance; + } + + public static void Maybe(this TInstance instance, Action action) + { + if (instance != null) + { + action(); + } + } + + public static void Maybe(this TInstance instance, Action action) + { + if (instance != null) + { + action(instance); + } + } + + public static void Maybe(this object instance, Action action) + where TInstance : class + { + Maybe(instance as TInstance, action); + } + + public static TResult SelectOrDefault(this TInstance instance, Func selector) + { + return SelectOrDefault(instance, selector, default(TResult)); + } + + public static TResult SelectOrDefault(this TInstance instance, Func selector, TResult defaultValue) + { + return instance == null ? defaultValue : selector(instance); + } + + public static bool SafeEquals(this T obj, T other) + where T : class + { + if (obj == null) + { + return other == null; + } + else + { + return obj.Equals(other); + } + } + + /// + /// A helper method to allow for locally defined extension-method like methods. Avoids the creation of an external static class + /// in the context of fluent expressions. + /// + public static TResult Apply(this TSource source, Func selector) + { + return selector(source); + } + + /// + /// A helper method that allows the execution of an action in a fluent expression. + /// + /// The action to execute on the source object + /// The source instance + public static TSource Apply(this TSource source, Action action) + { + action(source); + + return source; + } + + /// + /// A helper method that allows the execution of an action in a fluent expression. The action will be executed if the condition is true. + /// + /// A boolean value that indicates if the action should be executed. + /// The action to execute, the parameter will contain source + /// Returns the source instance + public static TSource Apply(this TSource source, bool condition, Action action) + { + if (condition) + { + action(source); + } + + return source; + } + + /// + /// Gets a boolean value that determines if a specific value is within a list of accepted values. + /// Use this when it's not necessary or when it's overkill to declare the list of accepted values + /// as a readonly field. For example, can be used to check if one enum value is within a set without that + /// enum being marked as [Flags]. + /// + /// + /// The source value. + /// The list of accepted values. + /// + public static bool IsOneOf(this TSource source, params TSource[] acceptedValues) + { + return acceptedValues?.Contains(source) ?? false; + } + + /// + /// Gets a boolean value that determines if a specific value is within a list of accepted values. + /// Use this when it's not necessary or when it's overkill to declare the list of accepted values + /// as a readonly field. For example, can be used to check if one enum value is within a set without that + /// enum being marked as [Flags]. + /// + /// + /// The source value. + /// The comparer to use to determine equality. + /// The list of accepted values. + /// + public static bool IsOneOf(this TSource source, IEqualityComparer comparer, params TSource[] acceptedValues) + { + return acceptedValues?.Contains(source, comparer) ?? false; + } + } } diff --git a/src/Uno.Core/Extensions/StorageFolderExtensions.cs b/src/Uno.Core/Extensions/StorageFolderExtensions.cs index 4ab246b..436d614 100644 --- a/src/Uno.Core/Extensions/StorageFolderExtensions.cs +++ b/src/Uno.Core/Extensions/StorageFolderExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + #if HAS_ISTORAGEFILE using System; using System.IO; @@ -52,4 +53,4 @@ public static async Task TryGetFileAsync(this IStorageFolder folde } } } -#endif \ No newline at end of file +#endif diff --git a/src/Uno.Core/Extensions/StreamExtensions.cs b/src/Uno.Core/Extensions/StreamExtensions.cs index bc55d6d..82eb262 100644 --- a/src/Uno.Core/Extensions/StreamExtensions.cs +++ b/src/Uno.Core/Extensions/StreamExtensions.cs @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Linq; using System.Text; diff --git a/src/Uno.Core/Extensions/StringBuilderExtensions.cs b/src/Uno.Core/Extensions/StringBuilderExtensions.cs index 89db2fd..63a30a9 100644 --- a/src/Uno.Core/Extensions/StringBuilderExtensions.cs +++ b/src/Uno.Core/Extensions/StringBuilderExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Globalization; using System.Text; @@ -76,4 +77,4 @@ public static IDisposable BlockInvariant(this IndentedStringBuilder builder, str return builder.Block(CultureInfo.InvariantCulture, pattern, parameters); } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Extensions/StringExtensions.Format.cs b/src/Uno.Core/Extensions/StringExtensions.Format.cs index 212598d..38867a7 100644 --- a/src/Uno.Core/Extensions/StringExtensions.Format.cs +++ b/src/Uno.Core/Extensions/StringExtensions.Format.cs @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Globalization; diff --git a/src/Uno.Core/Extensions/StringExtensions.cs b/src/Uno.Core/Extensions/StringExtensions.cs index 8fc3a47..ce21550 100644 --- a/src/Uno.Core/Extensions/StringExtensions.cs +++ b/src/Uno.Core/Extensions/StringExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ // limitations under the License. // // ****************************************************************** -#region Using directives + using System; using System.Collections.Generic; using System.Linq; @@ -22,14 +22,12 @@ using System.Text; using System.Text.RegularExpressions; -#endregion - namespace Uno.Extensions { public static partial class StringExtensions { #if (!SILVERLIGHT && !WINDOWS_UWP && HAS_COMPILEDREGEX) || WINDOWS_PHONE || HAS_COMPILEDREGEX - private static readonly Regex _newLineRegex = new Regex(@"^", RegexOptions.Compiled | RegexOptions.Multiline); + private static readonly Regex _newLineRegex = new Regex(@"^", RegexOptions.Compiled | RegexOptions.Multiline); #else private static readonly Lazy _newLineRegex = new Lazy(() => new Regex(@"^", RegexOptions.Multiline)); #endif diff --git a/src/Uno.Core/Extensions/TextWriterExtensions.cs b/src/Uno.Core/Extensions/TextWriterExtensions.cs index dae1532..dc7e9a7 100644 --- a/src/Uno.Core/Extensions/TextWriterExtensions.cs +++ b/src/Uno.Core/Extensions/TextWriterExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,23 +14,24 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Globalization; using System.IO; namespace Uno.Extensions { - public static class TextWriterExtensions - { - public static void Write(this TextWriter writer, string format, params object[] args) - { - writer.Write(string.Format(CultureInfo.InvariantCulture, format, args)); - } + public static class TextWriterExtensions + { + public static void Write(this TextWriter writer, string format, params object[] args) + { + writer.Write(string.Format(CultureInfo.InvariantCulture, format, args)); + } - public static void WriteLine(this TextWriter writer, string format, params object[] args) - { + public static void WriteLine(this TextWriter writer, string format, params object[] args) + { writer.Write(string.Format(CultureInfo.InvariantCulture, format, args)); - } + } public static void Write(this TextWriter writer, IFormatProvider formatProvider, string format, params object[] args) { @@ -42,4 +43,4 @@ public static void WriteLine(this TextWriter writer, IFormatProvider formatProvi writer.Write(string.Format(formatProvider, format, args)); } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Extensions/UriExtensions.cs b/src/Uno.Core/Extensions/UriExtensions.cs index 230e2ba..2e342f2 100644 --- a/src/Uno.Core/Extensions/UriExtensions.cs +++ b/src/Uno.Core/Extensions/UriExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Text; diff --git a/src/Uno.Core/Extensions/ValueType/ByteSupport.cs b/src/Uno.Core/Extensions/ValueType/ByteSupport.cs index f3079b8..6104174 100644 --- a/src/Uno.Core/Extensions/ValueType/ByteSupport.cs +++ b/src/Uno.Core/Extensions/ValueType/ByteSupport.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,48 +14,25 @@ // limitations under the License. // // ****************************************************************** + namespace Uno.Extensions.ValueType { - public class ByteSupport : ValueSupport - { - protected override byte CoreAnd(byte lhs, byte rhs) - { - return (byte) (lhs & rhs); - } - - protected override byte CoreOr(byte lhs, byte rhs) - { - return (byte) (lhs | rhs); - } - - protected override byte CoreNegate(byte instance) - { - return (byte) (-instance); - } - - protected override byte CoreNot(byte instance) - { - return (byte) (~instance); - } - - protected override byte CoreAdd(byte lhs, byte rhs) - { - return (byte) (lhs + rhs); - } - - protected override byte CoreSubstract(byte lhs, byte rhs) - { - return (byte) (lhs - rhs); - } - - protected override byte CoreMultiply(byte lhs, byte rhs) - { - return (byte) (lhs*rhs); - } - - protected override byte CoreDivide(byte lhs, byte rhs) - { - return (byte) (lhs/rhs); - } - } -} \ No newline at end of file + public class ByteSupport : ValueSupport + { + protected override byte CoreAnd(byte lhs, byte rhs) => (byte) (lhs & rhs); + + protected override byte CoreOr(byte lhs, byte rhs) => (byte) (lhs | rhs); + + protected override byte CoreNegate(byte instance) => (byte) (-instance); + + protected override byte CoreNot(byte instance) => (byte) (~instance); + + protected override byte CoreAdd(byte lhs, byte rhs) => (byte) (lhs + rhs); + + protected override byte CoreSubstract(byte lhs, byte rhs) => (byte) (lhs - rhs); + + protected override byte CoreMultiply(byte lhs, byte rhs) => (byte) (lhs*rhs); + + protected override byte CoreDivide(byte lhs, byte rhs) => (byte) (lhs/rhs); + } +} diff --git a/src/Uno.Core/Extensions/ValueType/EnumSupport.cs b/src/Uno.Core/Extensions/ValueType/EnumSupport.cs index 36d0f93..c0bc793 100644 --- a/src/Uno.Core/Extensions/ValueType/EnumSupport.cs +++ b/src/Uno.Core/Extensions/ValueType/EnumSupport.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,49 +14,32 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno.Extensions.ValueType { - public class EnumSupport : ValueSupport - { - private readonly IValueSupport support; - - public EnumSupport() - { - var type = Enum.GetUnderlyingType(typeof (T)); - - support = ValueSupport.Get(type); - } - - protected override T CoreAnd(T lhs, T rhs) - { - return (T) support.And(lhs, rhs); - } - - protected override T CoreXor(T lhs, T rhs) - { - return (T) support.Xor(lhs, rhs); - } - - protected override T CoreAdd(T lhs, T rhs) - { - return CoreOr(lhs, rhs); - } - - protected override T CoreSubstract(T lhs, T rhs) - { - return (T) support.And(lhs, support.Not(rhs)); - } - - protected override T CoreOr(T lhs, T rhs) - { - return (T) support.Or(lhs, rhs); - } - - protected override T CoreNot(T instance) - { - return (T) support.Not(instance); - } - } -} \ No newline at end of file + public class EnumSupport : ValueSupport + { + private readonly IValueSupport support; + + public EnumSupport() + { + var type = Enum.GetUnderlyingType(typeof (T)); + + support = ValueSupport.Get(type); + } + + protected override T CoreAnd(T lhs, T rhs) => (T) support.And(lhs, rhs); + + protected override T CoreXor(T lhs, T rhs) => (T) support.Xor(lhs, rhs); + + protected override T CoreAdd(T lhs, T rhs) => CoreOr(lhs, rhs); + + protected override T CoreSubstract(T lhs, T rhs) => (T) support.And(lhs, support.Not(rhs)); + + protected override T CoreOr(T lhs, T rhs) => (T) support.Or(lhs, rhs); + + protected override T CoreNot(T instance) => (T) support.Not(instance); + } +} diff --git a/src/Uno.Core/Extensions/ValueType/IValueSupport.Generic.cs b/src/Uno.Core/Extensions/ValueType/IValueSupport.Generic.cs index a51eaa5..ee8f86b 100644 --- a/src/Uno.Core/Extensions/ValueType/IValueSupport.Generic.cs +++ b/src/Uno.Core/Extensions/ValueType/IValueSupport.Generic.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,18 +14,19 @@ // limitations under the License. // // ****************************************************************** + namespace Uno.Extensions.ValueType { - public interface IValueSupport : IValueSupport - { - T And(T lhs, T rhs); - T Or(T lhs, T rhs); - T Xor(T lhs, T rhs); - T Add(T lhs, T rhs); - T Substract(T lhs, T rhs); - T Multiply(T lhs, T rhs); - T Divide(T lhs, T rhs); - T Negate(T instance); - T Not(T instance); - } -} \ No newline at end of file + public interface IValueSupport : IValueSupport + { + T And(T lhs, T rhs); + T Or(T lhs, T rhs); + T Xor(T lhs, T rhs); + T Add(T lhs, T rhs); + T Substract(T lhs, T rhs); + T Multiply(T lhs, T rhs); + T Divide(T lhs, T rhs); + T Negate(T instance); + T Not(T instance); + } +} diff --git a/src/Uno.Core/Extensions/ValueType/IValueSupport.cs b/src/Uno.Core/Extensions/ValueType/IValueSupport.cs index 78d333e..9b89084 100644 --- a/src/Uno.Core/Extensions/ValueType/IValueSupport.cs +++ b/src/Uno.Core/Extensions/ValueType/IValueSupport.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,18 +14,19 @@ // limitations under the License. // // ****************************************************************** + namespace Uno.Extensions.ValueType { - public interface IValueSupport - { - object And(object lhs, object rhs); - object Or(object lhs, object rhs); - object Xor(object lhs, object rhs); - object Add(object lhs, object rhs); - object Substract(object lhs, object rhs); - object Multiply(object lhs, object rhs); - object Divide(object lhs, object rhs); - object Negate(object instance); - object Not(object instance); - } -} \ No newline at end of file + public interface IValueSupport + { + object And(object lhs, object rhs); + object Or(object lhs, object rhs); + object Xor(object lhs, object rhs); + object Add(object lhs, object rhs); + object Substract(object lhs, object rhs); + object Multiply(object lhs, object rhs); + object Divide(object lhs, object rhs); + object Negate(object instance); + object Not(object instance); + } +} diff --git a/src/Uno.Core/Extensions/ValueType/Int32Support.cs b/src/Uno.Core/Extensions/ValueType/Int32Support.cs index f08f949..12d0428 100644 --- a/src/Uno.Core/Extensions/ValueType/Int32Support.cs +++ b/src/Uno.Core/Extensions/ValueType/Int32Support.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,53 +14,27 @@ // limitations under the License. // // ****************************************************************** + namespace Uno.Extensions.ValueType { - public class Int32Support : ValueSupport + public class Int32Support : ValueSupport { - protected override int CoreAnd(int lhs, int rhs) - { - return lhs & rhs; - } + protected override int CoreAnd(int lhs, int rhs) => lhs & rhs; - protected override int CoreOr(int lhs, int rhs) - { - return lhs | rhs; - } + protected override int CoreOr(int lhs, int rhs) => lhs | rhs; - protected override int CoreXor(int lhs, int rhs) - { - return lhs ^ rhs; - } + protected override int CoreXor(int lhs, int rhs) => lhs ^ rhs; - protected override int CoreAdd(int lhs, int rhs) - { - return lhs + rhs; - } + protected override int CoreAdd(int lhs, int rhs) => lhs + rhs; - protected override int CoreSubstract(int lhs, int rhs) - { - return lhs - rhs; - } + protected override int CoreSubstract(int lhs, int rhs) => lhs - rhs; - protected override int CoreMultiply(int lhs, int rhs) - { - return lhs*rhs; - } + protected override int CoreMultiply(int lhs, int rhs) => lhs*rhs; - protected override int CoreDivide(int lhs, int rhs) - { - return lhs/rhs; - } + protected override int CoreDivide(int lhs, int rhs) => lhs/rhs; - protected override int CoreNegate(int instance) - { - return -instance; - } + protected override int CoreNegate(int instance) => -instance; - protected override int CoreNot(int instance) - { - return ~instance; - } + protected override int CoreNot(int instance) => ~instance; } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Extensions/ValueType/ValueSupport.Generic.cs b/src/Uno.Core/Extensions/ValueType/ValueSupport.Generic.cs index 98df904..191db0b 100644 --- a/src/Uno.Core/Extensions/ValueType/ValueSupport.Generic.cs +++ b/src/Uno.Core/Extensions/ValueType/ValueSupport.Generic.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,149 +14,69 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno.Extensions.ValueType { - public class ValueSupport : IValueSupport - { - #region IValueSupport Members - - public T And(T lhs, T rhs) - { - return CoreAnd(lhs, rhs); - } - - public T Or(T lhs, T rhs) - { - return CoreOr(lhs, rhs); - } - - public T Xor(T lhs, T rhs) - { - return CoreXor(lhs, rhs); - } - - public T Add(T lhs, T rhs) - { - return CoreAdd(lhs, rhs); - } - - public T Substract(T lhs, T rhs) - { - return CoreSubstract(lhs, rhs); - } - - public T Multiply(T lhs, T rhs) - { - return CoreMultiply(lhs, rhs); - } - - public T Divide(T lhs, T rhs) - { - return CoreDivide(lhs, rhs); - } - - public T Negate(T instance) - { - return CoreNegate(instance); - } - - public T Not(T instance) - { - return CoreNot(instance); - } - - object IValueSupport.And(object lhs, object rhs) - { - return CoreAnd((T) lhs, (T) rhs); - } - - object IValueSupport.Or(object lhs, object rhs) - { - return CoreOr((T) lhs, (T) rhs); - } - - object IValueSupport.Xor(object lhs, object rhs) - { - return CoreXor((T) lhs, (T) rhs); - } - - object IValueSupport.Add(object lhs, object rhs) - { - return CoreAdd((T) lhs, (T) rhs); - } - - object IValueSupport.Substract(object lhs, object rhs) - { - return CoreSubstract((T) lhs, (T) rhs); - } - - object IValueSupport.Multiply(object lhs, object rhs) - { - return CoreMultiply((T) lhs, (T) rhs); - } - - object IValueSupport.Divide(object lhs, object rhs) - { - return CoreDivide((T) lhs, (T) rhs); - } - - object IValueSupport.Negate(object instance) - { - return CoreNegate((T) instance); - } - - object IValueSupport.Not(object instance) - { - return CoreNot((T) instance); - } - - #endregion - - protected virtual T CoreAnd(T lhs, T rhs) - { - throw new InvalidOperationException(); - } - - protected virtual T CoreOr(T lhs, T rhs) - { - throw new InvalidOperationException(); - } - - protected virtual T CoreXor(T lhs, T rhs) - { - throw new InvalidOperationException(); - } - - protected virtual T CoreAdd(T lhs, T rhs) - { - throw new InvalidOperationException(); - } - - protected virtual T CoreSubstract(T lhs, T rhs) - { - throw new InvalidOperationException(); - } - - protected virtual T CoreMultiply(T lhs, T rhs) - { - throw new InvalidOperationException(); - } - - protected virtual T CoreDivide(T lhs, T rhs) - { - throw new InvalidOperationException(); - } - - protected virtual T CoreNegate(T instance) - { - throw new InvalidOperationException(); - } - - protected virtual T CoreNot(T instance) - { - throw new InvalidOperationException(); - } - } -} \ No newline at end of file + public class ValueSupport : IValueSupport + { + #region IValueSupport Members + + public T And(T lhs, T rhs) => CoreAnd(lhs, rhs); + + public T Or(T lhs, T rhs) => CoreOr(lhs, rhs); + + public T Xor(T lhs, T rhs) => CoreXor(lhs, rhs); + + public T Add(T lhs, T rhs) => CoreAdd(lhs, rhs); + + public T Substract(T lhs, T rhs) => CoreSubstract(lhs, rhs); + + public T Multiply(T lhs, T rhs) => CoreMultiply(lhs, rhs); + + public T Divide(T lhs, T rhs) => CoreDivide(lhs, rhs); + + public T Negate(T instance) => CoreNegate(instance); + + public T Not(T instance) => CoreNot(instance); + + object IValueSupport.And(object lhs, object rhs) => CoreAnd((T) lhs, (T) rhs); + + object IValueSupport.Or(object lhs, object rhs) => CoreOr((T) lhs, (T) rhs); + + object IValueSupport.Xor(object lhs, object rhs) => CoreXor((T) lhs, (T) rhs); + + object IValueSupport.Add(object lhs, object rhs) => CoreAdd((T) lhs, (T) rhs); + + object IValueSupport.Substract(object lhs, object rhs) => CoreSubstract((T) lhs, (T) rhs); + + object IValueSupport.Multiply(object lhs, object rhs) => CoreMultiply((T) lhs, (T) rhs); + + object IValueSupport.Divide(object lhs, object rhs) => CoreDivide((T) lhs, (T) rhs); + + object IValueSupport.Negate(object instance) => CoreNegate((T) instance); + + object IValueSupport.Not(object instance) => CoreNot((T) instance); + + #endregion + + protected virtual T CoreAnd(T lhs, T rhs) => throw new InvalidOperationException(); + + protected virtual T CoreOr(T lhs, T rhs) => throw new InvalidOperationException(); + + protected virtual T CoreXor(T lhs, T rhs) => throw new InvalidOperationException(); + + protected virtual T CoreAdd(T lhs, T rhs) => throw new InvalidOperationException(); + + protected virtual T CoreSubstract(T lhs, T rhs) => throw new InvalidOperationException(); + + protected virtual T CoreMultiply(T lhs, T rhs) => throw new InvalidOperationException(); + + protected virtual T CoreDivide(T lhs, T rhs) => throw new InvalidOperationException(); + + protected virtual T CoreNegate(T instance) => throw new InvalidOperationException(); + + protected virtual T CoreNot(T instance) => throw new InvalidOperationException(); + } +} diff --git a/src/Uno.Core/Extensions/ValueType/ValueSupport.cs b/src/Uno.Core/Extensions/ValueType/ValueSupport.cs index 02949fa..bb6243b 100644 --- a/src/Uno.Core/Extensions/ValueType/ValueSupport.cs +++ b/src/Uno.Core/Extensions/ValueType/ValueSupport.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Reflection; @@ -21,36 +22,36 @@ namespace Uno.Extensions.ValueType { - public static class ValueSupport - { - //private static readonly SynchronizedDictionary support; - private static readonly IDictionary support; + public static class ValueSupport + { + //private static readonly SynchronizedDictionary support; + private static readonly IDictionary support; - static ValueSupport() - { - //support = new SynchronizedDictionary( - // new Dictionary() - // { - // { typeof(Int32), new Int32Support() }, - // { typeof(Byte), new ByteSupport() } - // }); - support = new Dictionary() - { - { typeof(Int32), new Int32Support() }, - { typeof(Byte), new ByteSupport() } - }; - } + static ValueSupport() + { + //support = new SynchronizedDictionary( + // new Dictionary() + // { + // { typeof(Int32), new Int32Support() }, + // { typeof(Byte), new ByteSupport() } + // }); + support = new Dictionary() + { + { typeof(Int32), new Int32Support() }, + { typeof(Byte), new ByteSupport() } + }; + } - public static IValueSupport Get() - { - var type = typeof (T); + public static IValueSupport Get() + { + var type = typeof (T); #if WINDOWS_UWP - if (type.GetTypeInfo().IsEnum) + if (type.GetTypeInfo().IsEnum) #else - if (type.IsEnum) + if (type.IsEnum) #endif - { + { lock (typeof(ValueSupport)) { //support.Lock.Write( @@ -61,18 +62,18 @@ public static IValueSupport Get() support.Add(type, new EnumSupport()); } } - } + } - return (IValueSupport) Get(type); - } + return (IValueSupport) Get(type); + } - public static IValueSupport Get(object instance) - { - return Get(instance.GetType()); - } + public static IValueSupport Get(object instance) + { + return Get(instance.GetType()); + } - public static IValueSupport Get(Type type) - { + public static IValueSupport Get(Type type) + { lock (typeof(ValueSupport)) { foreach (var kvp in support) @@ -84,7 +85,7 @@ public static IValueSupport Get(Type type) } } - throw new NotSupportedException(); - } - } + throw new NotSupportedException(); + } + } } diff --git a/src/Uno.Core/Extensions/ValueType/ValueSupportExtensions.cs b/src/Uno.Core/Extensions/ValueType/ValueSupportExtensions.cs index 3e238f1..fcc0aed 100644 --- a/src/Uno.Core/Extensions/ValueType/ValueSupportExtensions.cs +++ b/src/Uno.Core/Extensions/ValueType/ValueSupportExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,74 +14,42 @@ // limitations under the License. // // ****************************************************************** + namespace Uno.Extensions.ValueType { - public static class ValueSupportExtensions - { - public static T And(this T lhs, T rhs) - where T : struct - { - return ValueSupport.Get().And(lhs, rhs); - } + public static class ValueSupportExtensions + { + public static T And(this T lhs, T rhs) + where T : struct => ValueSupport.Get().And(lhs, rhs); - public static T Or(this T lhs, T rhs) - where T : struct - { - return ValueSupport.Get().Or(lhs, rhs); - } + public static T Or(this T lhs, T rhs) + where T : struct => ValueSupport.Get().Or(lhs, rhs); - public static T Xor(this T lhs, T rhs) - where T : struct - { - return ValueSupport.Get().Xor(lhs, rhs); - } + public static T Xor(this T lhs, T rhs) + where T : struct => ValueSupport.Get().Xor(lhs, rhs); - public static T Add(this T lhs, T rhs) - where T : struct - { - return ValueSupport.Get().Add(lhs, rhs); - } + public static T Add(this T lhs, T rhs) + where T : struct => ValueSupport.Get().Add(lhs, rhs); - public static T Substract(this T lhs, T rhs) - where T : struct - { - return ValueSupport.Get().Substract(lhs, rhs); - } + public static T Substract(this T lhs, T rhs) + where T : struct => ValueSupport.Get().Substract(lhs, rhs); - public static T Multiply(this T lhs, T rhs) - where T : struct - { - return ValueSupport.Get().Multiply(lhs, rhs); - } + public static T Multiply(this T lhs, T rhs) + where T : struct => ValueSupport.Get().Multiply(lhs, rhs); - public static T Divide(this T lhs, T rhs) - where T : struct - { - return ValueSupport.Get().Divide(lhs, rhs); - } + public static T Divide(this T lhs, T rhs) + where T : struct => ValueSupport.Get().Divide(lhs, rhs); - public static T Negate(this T instance) - where T : struct - { - return ValueSupport.Get().Negate(instance); - } + public static T Negate(this T instance) + where T : struct => ValueSupport.Get().Negate(instance); - public static T Not(this T instance) - where T : struct - { - return ValueSupport.Get().Not(instance); - } + public static T Not(this T instance) + where T : struct => ValueSupport.Get().Not(instance); - public static bool ContainsAny(this T lhs, T rhs) - where T : struct - { - return !Equals(lhs.And(rhs), (T) (object) 0); - } + public static bool ContainsAny(this T lhs, T rhs) + where T : struct => !Equals(lhs.And(rhs), (T) (object) 0); - public static bool ContainsAll(this T lhs, T rhs) - where T : struct - { - return Equals(lhs.And(rhs), rhs); - } - } -} \ No newline at end of file + public static bool ContainsAll(this T lhs, T rhs) + where T : struct => Equals(lhs.And(rhs), rhs); + } +} diff --git a/src/Uno.Core/Extensions/WeakReferenceExtensions.cs b/src/Uno.Core/Extensions/WeakReferenceExtensions.cs index e81976b..0afeaec 100644 --- a/src/Uno.Core/Extensions/WeakReferenceExtensions.cs +++ b/src/Uno.Core/Extensions/WeakReferenceExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + #if !SILVERLIGHT using System; using System.Collections.Generic; @@ -53,4 +54,4 @@ public static T FindOrCreate(this System.WeakReference wr, Func factory } } } -#endif \ No newline at end of file +#endif diff --git a/src/Uno.Core/FallbackValueAttribute.cs b/src/Uno.Core/FallbackValueAttribute.cs index f5f9598..a89606d 100644 --- a/src/Uno.Core/FallbackValueAttribute.cs +++ b/src/Uno.Core/FallbackValueAttribute.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno diff --git a/src/Uno.Core/Fields.cs b/src/Uno.Core/Fields.cs index 246f5f3..c5959bd 100644 --- a/src/Uno.Core/Fields.cs +++ b/src/Uno.Core/Fields.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,19 +14,20 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; namespace Uno { - public static class FieldsExtensions - { - public static Func> Concat( - this Func> baseFields, Func> derivedFields) - where TDerived : TBase - { - return item => baseFields(item).Concat(derivedFields(item)); - } - } -} \ No newline at end of file + public static class FieldsExtensions + { + public static Func> Concat( + this Func> baseFields, Func> derivedFields) + where TDerived : TBase + { + return item => baseFields(item).Concat(derivedFields(item)); + } + } +} diff --git a/src/Uno.Core/FuncAsync.cs b/src/Uno.Core/FuncAsync.cs index 35b04e7..39ba2f0 100644 --- a/src/Uno.Core/FuncAsync.cs +++ b/src/Uno.Core/FuncAsync.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Text; diff --git a/src/Uno.Core/Funcs.cs b/src/Uno.Core/Funcs.cs index c6cf10a..8deba3e 100644 --- a/src/Uno.Core/Funcs.cs +++ b/src/Uno.Core/Funcs.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -310,4 +311,4 @@ public static class NullableFuncs public static readonly Func FromNullable = item => item.GetValueOrDefault(); public static readonly Func ToNullable = item => item; } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Grouping.cs b/src/Uno.Core/Grouping.cs index 624d88a..acf040d 100644 --- a/src/Uno.Core/Grouping.cs +++ b/src/Uno.Core/Grouping.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections; using System.Collections.Generic; diff --git a/src/Uno.Core/I.cs b/src/Uno.Core/I.cs index c6d89df..5226c77 100644 --- a/src/Uno.Core/I.cs +++ b/src/Uno.Core/I.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -21,8 +22,8 @@ namespace Uno { - public interface I - { - T Value { get; } - } + public interface I + { + T Value { get; } + } } diff --git a/src/Uno.Core/IIdentifiable.cs b/src/Uno.Core/IIdentifiable.cs index 40aac62..a818836 100644 --- a/src/Uno.Core/IIdentifiable.cs +++ b/src/Uno.Core/IIdentifiable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,15 +14,13 @@ // limitations under the License. // // ****************************************************************** + using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Uno { - public interface IIdentifiable - { - Guid Id { get; set; } - } + public interface IIdentifiable + { + Guid Id { get; set; } + } } diff --git a/src/Uno.Core/IInitializable.cs b/src/Uno.Core/IInitializable.cs index 8cdb838..a556144 100644 --- a/src/Uno.Core/IInitializable.cs +++ b/src/Uno.Core/IInitializable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,10 +14,6 @@ // limitations under the License. // // ****************************************************************** -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Uno { diff --git a/src/Uno.Core/IInvalidatable.cs b/src/Uno.Core/IInvalidatable.cs index 7e79e01..240031a 100644 --- a/src/Uno.Core/IInvalidatable.cs +++ b/src/Uno.Core/IInvalidatable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,15 +14,11 @@ // limitations under the License. // // ****************************************************************** -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Uno { - public interface IInvalidatable - { - void Invalidate(); - } + public interface IInvalidatable + { + void Invalidate(); + } } diff --git a/src/Uno.Core/ILoadable.cs b/src/Uno.Core/ILoadable.cs index 728ab5f..1a6dae1 100644 --- a/src/Uno.Core/ILoadable.cs +++ b/src/Uno.Core/ILoadable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,13 +14,14 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno { - public interface ILoadable - { - bool IsLoaded { get; } - event EventHandler Loaded; - } -} \ No newline at end of file + public interface ILoadable + { + bool IsLoaded { get; } + event EventHandler Loaded; + } +} diff --git a/src/Uno.Core/IServiceLocatorProvider.cs b/src/Uno.Core/IServiceLocatorProvider.cs index 4e43934..8bc177a 100644 --- a/src/Uno.Core/IServiceLocatorProvider.cs +++ b/src/Uno.Core/IServiceLocatorProvider.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -22,8 +23,8 @@ namespace Uno { - public interface IServiceLocatorProvider - { - IServiceLocator ServiceLocator { get; } - } + public interface IServiceLocatorProvider + { + IServiceLocator ServiceLocator { get; } + } } diff --git a/src/Uno.Core/IUpdatable.cs b/src/Uno.Core/IUpdatable.cs index c8181f4..ee4b9d0 100644 --- a/src/Uno.Core/IUpdatable.cs +++ b/src/Uno.Core/IUpdatable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Text; @@ -29,8 +30,8 @@ namespace Uno /// This is useful for items bound to the view. When a newer instance with its Equals /// returning true for the old item comes in play, the old item is kept, but updated from that /// new instance. - public interface IUpdatable - { + public interface IUpdatable + { Task UpdateAsync(CancellationToken ct, T newerInstance); - } + } } diff --git a/src/Uno.Core/Instance.cs b/src/Uno.Core/Instance.cs index cc527dd..e026ea2 100644 --- a/src/Uno.Core/Instance.cs +++ b/src/Uno.Core/Instance.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -21,18 +22,18 @@ namespace Uno { - public class Instance : I - { - public Instance(Func provider) - { - Provider = provider; - } + public class Instance : I + { + public Instance(Func provider) + { + Provider = provider; + } - public Func Provider { get; private set; } + public Func Provider { get; private set; } - public T Value - { - get { return Provider(); } - } - } + public T Value + { + get { return Provider(); } + } + } } diff --git a/src/Uno.Core/InternalsWriteableFromAttribute.cs b/src/Uno.Core/InternalsWriteableFromAttribute.cs index adc7b38..6c73b70 100644 --- a/src/Uno.Core/InternalsWriteableFromAttribute.cs +++ b/src/Uno.Core/InternalsWriteableFromAttribute.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Text; diff --git a/src/Uno.Core/Key.cs b/src/Uno.Core/Key.cs index d1a31b2..92e62e4 100644 --- a/src/Uno.Core/Key.cs +++ b/src/Uno.Core/Key.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections; using System.Collections.Generic; @@ -22,47 +23,47 @@ namespace Uno { - /// - /// Represents a Key concept. - /// - public class Key - { - private static readonly Func> Fields = item => item.Items; + /// + /// Represents a Key concept. + /// + public class Key + { + private static readonly Func> Fields = item => item.Items; - /// - /// Constucts a new Key with an array of items. - /// - /// - public Key(params object[] items) - { - Items = items; - } + /// + /// Constucts a new Key with an array of items. + /// + /// + public Key(params object[] items) + { + Items = items; + } - /// - /// Constucts a new Key with an enumeration of items. - /// - /// - public Key(IEnumerable items) - : this(items.ToObjectArray()) - { - } + /// + /// Constucts a new Key with an enumeration of items. + /// + /// + public Key(IEnumerable items) + : this(items.ToObjectArray()) + { + } - public object[] Items { get; private set; } + public object[] Items { get; private set; } - /// - /// See Object pattern. - /// - public override int GetHashCode() - { - return this.Equality().GetHashCode(Fields); - } + /// + /// See Object pattern. + /// + public override int GetHashCode() + { + return this.Equality().GetHashCode(Fields); + } - /// - /// See Object pattern. - /// - public override bool Equals(object obj) - { - return this.Equality().Equal(obj, Fields); - } - } -} \ No newline at end of file + /// + /// See Object pattern. + /// + public override bool Equals(object obj) + { + return this.Equality().Equal(obj, Fields); + } + } +} diff --git a/src/Uno.Core/Lazy.cs b/src/Uno.Core/Lazy.cs index b257ba3..09e616f 100644 --- a/src/Uno.Core/Lazy.cs +++ b/src/Uno.Core/Lazy.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,24 +14,25 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Threading.Tasks; namespace Uno { - [Legacy("NV0049")] + [Legacy("NV0049")] public static class Lazy - { - public static T Get(ref T value, Func factory) + { + public static T Get(ref T value, Func factory) where T : class - { - if (value == null) - { - value = factory(); - } + { + if (value == null) + { + value = factory(); + } - return value; - } + return value; + } public static T Get(ref T value) where T : class @@ -44,5 +45,5 @@ public static T FindOrCreate(ref T value) { return Get(ref value, () => new T()); } - } + } } diff --git a/src/Uno.Core/LazyBehavior.cs b/src/Uno.Core/LazyBehavior.cs index 8631c6e..ac71526 100644 --- a/src/Uno.Core/LazyBehavior.cs +++ b/src/Uno.Core/LazyBehavior.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,12 +14,13 @@ // limitations under the License. // // ****************************************************************** + namespace Uno { - public enum LazyBehavior - { - Loaded, - Default, - Null - } -} \ No newline at end of file + public enum LazyBehavior + { + Loaded, + Default, + Null + } +} diff --git a/src/Uno.Core/Legacy.cs b/src/Uno.Core/Legacy.cs index 6091f72..1f9a582 100644 --- a/src/Uno.Core/Legacy.cs +++ b/src/Uno.Core/Legacy.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Localisation/CultureContext.cs b/src/Uno.Core/Localisation/CultureContext.cs index 983e8c8..0c35460 100644 --- a/src/Uno.Core/Localisation/CultureContext.cs +++ b/src/Uno.Core/Localisation/CultureContext.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + #if !WINDOWS_UWP using System; using System.Globalization; @@ -56,4 +57,4 @@ public static CultureContext Create(string cultureIdentifier) } } } -#endif \ No newline at end of file +#endif diff --git a/src/Uno.Core/Logging/LogExtensionPoint.cs b/src/Uno.Core/Logging/LogExtensionPoint.cs index c5626ed..6c0b618 100644 --- a/src/Uno.Core/Logging/LogExtensionPoint.cs +++ b/src/Uno.Core/Logging/LogExtensionPoint.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using CommonServiceLocator; using Microsoft.Extensions.Logging; @@ -21,14 +22,14 @@ namespace Uno.Extensions { - public static class LogExtensionPoint - { - private static ILoggerFactory _loggerFactory; + public static class LogExtensionPoint + { + private static ILoggerFactory _loggerFactory; - private static class Container - { - internal static readonly ILogger Logger = AmbientLoggerFactory.CreateLogger(); - } + private static class Container + { + internal static readonly ILogger Logger = AmbientLoggerFactory.CreateLogger(); + } /// /// Retreives the for this the Uno extension point. diff --git a/src/Uno.Core/Logging/LogExtensions.Conditional.cs b/src/Uno.Core/Logging/LogExtensions.Conditional.cs index 0acbb40..c7fb7cb 100644 --- a/src/Uno.Core/Logging/LogExtensions.Conditional.cs +++ b/src/Uno.Core/Logging/LogExtensions.Conditional.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; @@ -21,81 +22,81 @@ namespace Uno.Logging { - public static partial class LogExtensions - { - /// - /// Adds a debug log, but only if debug logs are enabled. If they're not, the provided messageDelegate - /// lambda will not be called. - /// - /// - /// - /// - public static void DebugIfEnabled(this ILogger log, Func messageSelector, Exception error = null) - { - if (log.IsEnabled(LogLevel.Debug)) - { - log.LogDebug(0, error, messageSelector(), error); - } - } + public static partial class LogExtensions + { + /// + /// Adds a debug log, but only if debug logs are enabled. If they're not, the provided messageDelegate + /// lambda will not be called. + /// + /// + /// + /// + public static void DebugIfEnabled(this ILogger log, Func messageSelector, Exception error = null) + { + if (log.IsEnabled(LogLevel.Debug)) + { + log.LogDebug(0, error, messageSelector(), error); + } + } - /// - /// Adds an info log, but only if info logs are enabled. If they're not, the provided messageDelegate - /// lambda will not be called. - /// - /// - /// - /// - public static void InfoIfEnabled(this ILogger log, Func messageSelector, Exception error = null) - { - if (log.IsEnabled(LogLevel.Information)) - { - log.LogInformation(0, error, messageSelector(), error); - } - } + /// + /// Adds an info log, but only if info logs are enabled. If they're not, the provided messageDelegate + /// lambda will not be called. + /// + /// + /// + /// + public static void InfoIfEnabled(this ILogger log, Func messageSelector, Exception error = null) + { + if (log.IsEnabled(LogLevel.Information)) + { + log.LogInformation(0, error, messageSelector(), error); + } + } - /// - /// Adds a warninglog, but only if warning logs are enabled. If they're not, the provided messageDelegate - /// lambda will not be called. - /// - /// - /// - /// - public static void WarnIfEnabled(this ILogger log, Func messageSelector, Exception error = null) - { - if (log.IsEnabled(LogLevel.Warning)) - { - log.LogWarning(0, error, messageSelector(), error); - } - } + /// + /// Adds a warninglog, but only if warning logs are enabled. If they're not, the provided messageDelegate + /// lambda will not be called. + /// + /// + /// + /// + public static void WarnIfEnabled(this ILogger log, Func messageSelector, Exception error = null) + { + if (log.IsEnabled(LogLevel.Warning)) + { + log.LogWarning(0, error, messageSelector(), error); + } + } - /// - /// Adds an error log, but only if error logs are enabled. If they're not, the provided messageDelegate - /// lambda will not be called. - /// - /// - /// - /// - public static void ErrorIfEnabled(this ILogger log, Func messageSelector, Exception error = null) - { - if (log.IsEnabled(LogLevel.Error)) - { - log.LogError(0, error, messageSelector(), error); - } - } + /// + /// Adds an error log, but only if error logs are enabled. If they're not, the provided messageDelegate + /// lambda will not be called. + /// + /// + /// + /// + public static void ErrorIfEnabled(this ILogger log, Func messageSelector, Exception error = null) + { + if (log.IsEnabled(LogLevel.Error)) + { + log.LogError(0, error, messageSelector(), error); + } + } - /// - /// Adds a critical error log, but only if fatal error logs are enabled. If they're not, the provided messageDelegate - /// lambda will not be called. - /// - /// - /// - /// - public static void CriticalIfEnabled(this ILogger log, Func messageSelector, Exception error = null) - { - if (log.IsEnabled(LogLevel.Critical)) - { - log.LogCritical(0, error, messageSelector(), error); - } - } - } + /// + /// Adds a critical error log, but only if fatal error logs are enabled. If they're not, the provided messageDelegate + /// lambda will not be called. + /// + /// + /// + /// + public static void CriticalIfEnabled(this ILogger log, Func messageSelector, Exception error = null) + { + if (log.IsEnabled(LogLevel.Critical)) + { + log.LogCritical(0, error, messageSelector(), error); + } + } + } } diff --git a/src/Uno.Core/Logging/LogExtensions.cs b/src/Uno.Core/Logging/LogExtensions.cs index 4e8e29e..017ca33 100644 --- a/src/Uno.Core/Logging/LogExtensions.cs +++ b/src/Uno.Core/Logging/LogExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using Microsoft.Extensions.Logging; using System; using System.Globalization; diff --git a/src/Uno.Core/NotFoundException.cs b/src/Uno.Core/NotFoundException.cs index 2c2df22..26018b0 100644 --- a/src/Uno.Core/NotFoundException.cs +++ b/src/Uno.Core/NotFoundException.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,52 +14,53 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Runtime.Serialization; #if !SILVERLIGHT && !WINDOWS_UWP && !XAMARIN namespace Uno { - /// - /// A NotFoundException is thrown when demanding something that doesn't exist be found. - /// - public class NotFoundException : ApplicationException - { - /// - /// See Exception Pattern. - /// - public NotFoundException() - { - } + /// + /// A NotFoundException is thrown when demanding something that doesn't exist be found. + /// + public class NotFoundException : ApplicationException + { + /// + /// See Exception Pattern. + /// + public NotFoundException() + { + } - /// - /// See Exception Pattern. - /// - /// - public NotFoundException(string message) - : base(message) - { - } + /// + /// See Exception Pattern. + /// + /// + public NotFoundException(string message) + : base(message) + { + } - /// - /// See Exception Pattern. - /// - /// - /// - protected NotFoundException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } + /// + /// See Exception Pattern. + /// + /// + /// + protected NotFoundException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } - /// - /// See Exception Pattern. - /// - /// - /// - public NotFoundException(string message, Exception innerException) - : base(message, innerException) - { - } - } + /// + /// See Exception Pattern. + /// + /// + /// + public NotFoundException(string message, Exception innerException) + : base(message, innerException) + { + } + } } -#endif \ No newline at end of file +#endif diff --git a/src/Uno.Core/Null.cs b/src/Uno.Core/Null.cs index cef55a6..cdd10bb 100644 --- a/src/Uno.Core/Null.cs +++ b/src/Uno.Core/Null.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,18 +14,19 @@ // limitations under the License. // // ****************************************************************** + namespace Uno { - /// - /// A container for a object that has no meaning (replaces void). - /// - public class Null - { - /// - /// Private constructor, no one will ever construct these things, pass null. - /// - private Null() - { - } - } -} \ No newline at end of file + /// + /// A container for a object that has no meaning (replaces void). + /// + public class Null + { + /// + /// Private constructor, no one will ever construct these things, pass null. + /// + private Null() + { + } + } +} diff --git a/src/Uno.Core/NullDisposable.cs b/src/Uno.Core/NullDisposable.cs index d18e09c..a3e2bb3 100644 --- a/src/Uno.Core/NullDisposable.cs +++ b/src/Uno.Core/NullDisposable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,36 +14,37 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno { - /// - /// An empty implementation of the IDisposable class. - /// - public class NullDisposable : IDisposable - { - /// - /// Provider for a instance of the NullDisposable - /// - public static readonly IDisposable Instance = new NullDisposable(); + /// + /// An empty implementation of the IDisposable class. + /// + public class NullDisposable : IDisposable + { + /// + /// Provider for a instance of the NullDisposable + /// + public static readonly IDisposable Instance = new NullDisposable(); - /// - /// Private constructor, use Instance. - /// - private NullDisposable() - { - } + /// + /// Private constructor, use Instance. + /// + private NullDisposable() + { + } - #region IDisposable Members + #region IDisposable Members - /// - /// See IDisposable. - /// - public void Dispose() - { - } + /// + /// See IDisposable. + /// + public void Dispose() + { + } - #endregion - } -} \ No newline at end of file + #endregion + } +} diff --git a/src/Uno.Core/ObjectReferenceEqualityComparer.cs b/src/Uno.Core/ObjectReferenceEqualityComparer.cs index 5cc16ab..423b010 100644 --- a/src/Uno.Core/ObjectReferenceEqualityComparer.cs +++ b/src/Uno.Core/ObjectReferenceEqualityComparer.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Text; diff --git a/src/Uno.Core/Options/None.cs b/src/Uno.Core/Options/None.cs index 3eb9429..97eb70a 100644 --- a/src/Uno.Core/Options/None.cs +++ b/src/Uno.Core/Options/None.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.CodeDom; using System.Diagnostics; @@ -48,4 +49,4 @@ private None() : base(OptionType.None) { } /// public override string ToString() => $"None<{typeof(T).Name}>()"; } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Options/Option.cs b/src/Uno.Core/Options/Option.cs index a93c00f..94be792 100644 --- a/src/Uno.Core/Options/Option.cs +++ b/src/Uno.Core/Options/Option.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + namespace Uno { /// diff --git a/src/Uno.Core/Options/OptionEqualityComparer.cs b/src/Uno.Core/Options/OptionEqualityComparer.cs index b619cfa..d34b319 100644 --- a/src/Uno.Core/Options/OptionEqualityComparer.cs +++ b/src/Uno.Core/Options/OptionEqualityComparer.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System.Collections; using System.Collections.Generic; diff --git a/src/Uno.Core/Options/OptionExtensions.cs b/src/Uno.Core/Options/OptionExtensions.cs index e6f01dd..50f1201 100644 --- a/src/Uno.Core/Options/OptionExtensions.cs +++ b/src/Uno.Core/Options/OptionExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno @@ -76,4 +77,4 @@ public static object SomeOrDefault(this Option option, object defaultValue = nul ? value : defaultValue; } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Options/OptionType.cs b/src/Uno.Core/Options/OptionType.cs index 9ed4633..bffb09e 100644 --- a/src/Uno.Core/Options/OptionType.cs +++ b/src/Uno.Core/Options/OptionType.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + namespace Uno { /// @@ -31,4 +32,4 @@ public enum OptionType : byte /// Some = 1 } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Options/Some.cs b/src/Uno.Core/Options/Some.cs index 89e92be..933728a 100644 --- a/src/Uno.Core/Options/Some.cs +++ b/src/Uno.Core/Options/Some.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System.Diagnostics; namespace Uno @@ -98,4 +99,4 @@ public override int GetHashCode() /// public static implicit operator Some(T o) => Some(o); } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Pair.cs b/src/Uno.Core/Pair.cs index ec06d38..5761740 100644 --- a/src/Uno.Core/Pair.cs +++ b/src/Uno.Core/Pair.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using Uno.Extensions; @@ -21,87 +22,87 @@ namespace Uno { - //TODO Replace with Tuple - /// - /// Represents a Pair of Ts. - /// - /// The type of elements in this Pair. - public class Pair - { - private static readonly Func, IEnumerable> Fields = item => new object[] {item.X, item.Y}; - - /// - /// Constructs a new Pair. - /// - public Pair() - { - } - - /// - /// Constructs a new Pair with it's X and Y items set. - /// - /// The X item. - /// The Y item. - public Pair(T x, T y) - { - X = x; - Y = y; - } - - /// - /// Accessor for the X item. - /// - public T X { get; set; } - - /// - /// Acessor for the Y item. - /// - public T Y { get; set; } - - /// - /// See Object pattern. - /// - public override int GetHashCode() - { - return this.Equality().GetHashCode(Fields); - } - - /// - /// See Object pattern. - /// - public override bool Equals(object obj) - { - return this.Equality().Equal(obj, Fields); - } - } - - public class Pair - { - private static readonly Func, IEnumerable> Fields = - item => new object[] {item.Key, item.Value}; - - public Pair() - { - } - - public Pair(TKey key, TValue value) - { - Key = key; - Value = value; - } - - public TKey Key { get; set; } - - public TValue Value { get; set; } - - public override int GetHashCode() - { - return this.Equality().GetHashCode(Fields); - } - - public override bool Equals(object obj) - { - return this.Equality().Equal(obj, Fields); - } - } -} \ No newline at end of file + //TODO Replace with Tuple + /// + /// Represents a Pair of Ts. + /// + /// The type of elements in this Pair. + public class Pair + { + private static readonly Func, IEnumerable> Fields = item => new object[] {item.X, item.Y}; + + /// + /// Constructs a new Pair. + /// + public Pair() + { + } + + /// + /// Constructs a new Pair with it's X and Y items set. + /// + /// The X item. + /// The Y item. + public Pair(T x, T y) + { + X = x; + Y = y; + } + + /// + /// Accessor for the X item. + /// + public T X { get; set; } + + /// + /// Acessor for the Y item. + /// + public T Y { get; set; } + + /// + /// See Object pattern. + /// + public override int GetHashCode() + { + return this.Equality().GetHashCode(Fields); + } + + /// + /// See Object pattern. + /// + public override bool Equals(object obj) + { + return this.Equality().Equal(obj, Fields); + } + } + + public class Pair + { + private static readonly Func, IEnumerable> Fields = + item => new object[] {item.Key, item.Value}; + + public Pair() + { + } + + public Pair(TKey key, TValue value) + { + Key = key; + Value = value; + } + + public TKey Key { get; set; } + + public TValue Value { get; set; } + + public override int GetHashCode() + { + return this.Equality().GetHashCode(Fields); + } + + public override bool Equals(object obj) + { + return this.Equality().Equal(obj, Fields); + } + } +} diff --git a/src/Uno.Core/Params.cs b/src/Uno.Core/Params.cs index 00f8330..907aed4 100644 --- a/src/Uno.Core/Params.cs +++ b/src/Uno.Core/Params.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,15 +14,16 @@ // limitations under the License. // // ****************************************************************** + using System.Collections.Generic; namespace Uno { - public static class Params - { - public static IEnumerable AsEnumerable(params T[] values) - { - return values; - } - } -} \ No newline at end of file + public static class Params + { + public static IEnumerable AsEnumerable(params T[] values) + { + return values; + } + } +} diff --git a/src/Uno.Core/Predicates.Generic.cs b/src/Uno.Core/Predicates.Generic.cs index 73dece7..5f729d5 100644 --- a/src/Uno.Core/Predicates.Generic.cs +++ b/src/Uno.Core/Predicates.Generic.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,13 +14,14 @@ // limitations under the License. // // ****************************************************************** + using System; using Uno.Extensions; namespace Uno { /// - /// A set of common prediactes + /// A set of common predicates /// /// Type of parameter of predicates public static class Predicates @@ -45,4 +46,4 @@ public static class Predicates /// public static readonly Predicate False = _ => false; } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Predicates.cs b/src/Uno.Core/Predicates.cs index f3dd273..8266d5a 100644 --- a/src/Uno.Core/Predicates.cs +++ b/src/Uno.Core/Predicates.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using Uno.Extensions; @@ -44,4 +45,4 @@ public static class Predicates /// public static readonly Predicate False = Predicates.False; } -} \ No newline at end of file +} diff --git a/src/Uno.Core/ReadOnlyException.cs b/src/Uno.Core/ReadOnlyException.cs index c8d6d3d..5861da8 100644 --- a/src/Uno.Core/ReadOnlyException.cs +++ b/src/Uno.Core/ReadOnlyException.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,53 +14,54 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Runtime.Serialization; #if !SILVERLIGHT && !WINDOWS_UWP && !XAMARIN namespace Uno { - /// - /// A ReadOnlyException is thrown when accessing a logically readonly - /// accessor when it is presents a readwrite interface. - /// - public class ReadOnlyException : ApplicationException - { - /// - /// See Exception Pattern. - /// - public ReadOnlyException() - { - } + /// + /// A ReadOnlyException is thrown when accessing a logically readonly + /// accessor when it is presents a readwrite interface. + /// + public class ReadOnlyException : ApplicationException + { + /// + /// See Exception Pattern. + /// + public ReadOnlyException() + { + } - /// - /// See Exception Pattern. - /// - /// - public ReadOnlyException(string message) - : base(message) - { - } + /// + /// See Exception Pattern. + /// + /// + public ReadOnlyException(string message) + : base(message) + { + } - /// - /// See Exception Pattern. - /// - /// - /// - protected ReadOnlyException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } + /// + /// See Exception Pattern. + /// + /// + /// + protected ReadOnlyException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } - /// - /// See Exception Pattern. - /// - /// - /// - public ReadOnlyException(string message, Exception innerException) - : base(message, innerException) - { - } - } + /// + /// See Exception Pattern. + /// + /// + /// + public ReadOnlyException(string message, Exception innerException) + : base(message, innerException) + { + } + } } -#endif \ No newline at end of file +#endif diff --git a/src/Uno.Core/Reflection/AssemblyExtensions.cs b/src/Uno.Core/Reflection/AssemblyExtensions.cs index 47107fc..08b4897 100644 --- a/src/Uno.Core/Reflection/AssemblyExtensions.cs +++ b/src/Uno.Core/Reflection/AssemblyExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Reflection; using System.Text; @@ -21,13 +22,13 @@ namespace Uno.Extensions { - public static class AssemblyExtensions - { - public static Version GetVersionNumber(this Assembly assembly) - { - // Note: Assembly.GetExecutingAssembly().GetName() is not accessible in WP7 - return new Version(Regex.Match(assembly.FullName, @"(\d+)(.\d+)(.\d+)?(.\d+)?").ToString()); - } + public static class AssemblyExtensions + { + public static Version GetVersionNumber(this Assembly assembly) + { + // Note: Assembly.GetExecutingAssembly().GetName() is not accessible in WP7 + return new Version(Regex.Match(assembly.FullName, @"(\d+)(.\d+)(.\d+)?(.\d+)?").ToString()); + } public static string GetProductName(this Assembly assembly) { @@ -35,7 +36,7 @@ public static string GetProductName(this Assembly assembly) return productNameAttribute == null ? null : productNameAttribute.Product; } - public static string GetCopyright(this Assembly assembly) + public static string GetCopyright(this Assembly assembly) { var assemblyCopyrightAttribute = assembly.GetAssemblyAttribute(); return assemblyCopyrightAttribute == null ? null : assemblyCopyrightAttribute.Copyright; diff --git a/src/Uno.Core/Reflection/BindingBehavior.cs b/src/Uno.Core/Reflection/BindingBehavior.cs index 94fe007..12b5241 100644 --- a/src/Uno.Core/Reflection/BindingBehavior.cs +++ b/src/Uno.Core/Reflection/BindingBehavior.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,15 +14,16 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno.Reflection { - [Flags] - public enum BindingBehavior - { - Inherited = 1, - Interface = 2, - All = Inherited | Interface - } -} \ No newline at end of file + [Flags] + public enum BindingBehavior + { + Inherited = 1, + Interface = 2, + All = Inherited | Interface + } +} diff --git a/src/Uno.Core/Reflection/BindingContract.Metro.cs b/src/Uno.Core/Reflection/BindingContract.Metro.cs index cfbcf46..efbf59f 100644 --- a/src/Uno.Core/Reflection/BindingContract.Metro.cs +++ b/src/Uno.Core/Reflection/BindingContract.Metro.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + #if HAS_CRIPPLEDREFLECTION && !XAMARIN using System; using System.Reflection; @@ -21,50 +22,50 @@ namespace Uno.Reflection { - public class BindingContract : IContract - { - internal static readonly BindingContract Default; + public class BindingContract : IContract + { + internal static readonly BindingContract Default; - internal static readonly BindingContract DefaultIgnoreCase; + internal static readonly BindingContract DefaultIgnoreCase; - static BindingContract() - { - Default = new BindingContract(); - DefaultIgnoreCase = new BindingContract(); - } + static BindingContract() + { + Default = new BindingContract(); + DefaultIgnoreCase = new BindingContract(); + } - public BindingContract() - { - } + public BindingContract() + { + } - public MemberTypes MemberType { get; set; } + public MemberTypes MemberType { get; set; } - public Type ReturnType { get; set; } + public Type ReturnType { get; set; } - public Type[] SafeTypes - { - get { return Types ?? new Type[0]; } - } + public Type[] SafeTypes + { + get { return Types ?? new Type[0]; } + } - public Type[] Types { get; set; } + public Type[] Types { get; set; } - public BindingBehavior Behavior { get; set; } - } + public BindingBehavior Behavior { get; set; } + } - // Summary: - // Marks each type of member that is defined as a derived class of MemberInfo. - [Flags] - public enum MemberTypes - { - Constructor = 1, - Event = 2, - Field = 4, - Method = 8, - Property = 16, - TypeInfo = 32, - Custom = 64, - NestedType = 128, - All = 191, - } + // Summary: + // Marks each type of member that is defined as a derived class of MemberInfo. + [Flags] + public enum MemberTypes + { + Constructor = 1, + Event = 2, + Field = 4, + Method = 8, + Property = 16, + TypeInfo = 32, + Custom = 64, + NestedType = 128, + All = 191, + } } -#endif \ No newline at end of file +#endif diff --git a/src/Uno.Core/Reflection/BindingContract.cs b/src/Uno.Core/Reflection/BindingContract.cs index b46eb58..0f47a8d 100644 --- a/src/Uno.Core/Reflection/BindingContract.cs +++ b/src/Uno.Core/Reflection/BindingContract.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + #if !HAS_CRIPPLEDREFLECTION || XAMARIN using System; using System.Reflection; @@ -21,63 +22,63 @@ namespace Uno.Reflection { - public class BindingContract : IContract - { - internal static readonly BindingContract Default; + public class BindingContract : IContract + { + internal static readonly BindingContract Default; - //internal static readonly BindingContract DefaultIgnoreCase; + //internal static readonly BindingContract DefaultIgnoreCase; - public static BindingFlags DefaultBindingFlags = BindingFlags.DeclaredOnly | BindingFlags.Static | - BindingFlags.Instance | BindingFlags.Public | - BindingFlags.NonPublic; + public static BindingFlags DefaultBindingFlags = BindingFlags.DeclaredOnly | BindingFlags.Static | + BindingFlags.Instance | BindingFlags.Public | + BindingFlags.NonPublic; - public static BindingFlags DefaultBindingFlagsIgnoreCase = DefaultBindingFlags | BindingFlags.IgnoreCase; + public static BindingFlags DefaultBindingFlagsIgnoreCase = DefaultBindingFlags | BindingFlags.IgnoreCase; - static BindingContract() - { - Default = new BindingContract(DefaultBindingFlags); - //DefaultIgnoreCase = new BindingContract(DefaultBindingFlagsIgnoreCase); - } + static BindingContract() + { + Default = new BindingContract(DefaultBindingFlags); + //DefaultIgnoreCase = new BindingContract(DefaultBindingFlagsIgnoreCase); + } - public BindingContract() - : this(DefaultBindingFlags) - { - } + public BindingContract() + : this(DefaultBindingFlags) + { + } - public BindingContract(BindingFlags bindingFlags) - : this(bindingFlags, null) - { - } + public BindingContract(BindingFlags bindingFlags) + : this(bindingFlags, null) + { + } - public BindingContract(BindingFlags bindingFlags, Type[] types) - : this(MemberTypes.All, bindingFlags, null, types, BindingBehavior.All) - { - } + public BindingContract(BindingFlags bindingFlags, Type[] types) + : this(MemberTypes.All, bindingFlags, null, types, BindingBehavior.All) + { + } - public BindingContract(MemberTypes memberType, BindingFlags bindingFlags, Type returnType, Type[] types, - BindingBehavior behavior) - { - MemberType = memberType; - BindingFlags = bindingFlags; - ReturnType = returnType; - Types = types; - Behavior = behavior; - } + public BindingContract(MemberTypes memberType, BindingFlags bindingFlags, Type returnType, Type[] types, + BindingBehavior behavior) + { + MemberType = memberType; + BindingFlags = bindingFlags; + ReturnType = returnType; + Types = types; + Behavior = behavior; + } - public MemberTypes MemberType { get; set; } + public MemberTypes MemberType { get; set; } - public BindingFlags BindingFlags { get; set; } + public BindingFlags BindingFlags { get; set; } - public Type ReturnType { get; set; } + public Type ReturnType { get; set; } - public Type[] SafeTypes - { - get { return Types ?? new Type[0]; } - } + public Type[] SafeTypes + { + get { return Types ?? new Type[0]; } + } - public Type[] Types { get; set; } + public Type[] Types { get; set; } - public BindingBehavior Behavior { get; set; } - } + public BindingBehavior Behavior { get; set; } + } } -#endif \ No newline at end of file +#endif diff --git a/src/Uno.Core/Reflection/DefaultReflectionExtensions.cs b/src/Uno.Core/Reflection/DefaultReflectionExtensions.cs index aa3bcf5..d01c7db 100644 --- a/src/Uno.Core/Reflection/DefaultReflectionExtensions.cs +++ b/src/Uno.Core/Reflection/DefaultReflectionExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -23,200 +24,200 @@ namespace Uno.Reflection { - public class DefaultReflectionExtensions : IReflectionExtensions - { - #region IReflectionExtensions Members - - public virtual object Get(IReflectionExtensionPoint extensionPoint, string memberName) - { - return Get(extensionPoint, memberName); - } - - public virtual T Get(IReflectionExtensionPoint extensionPoint, string memberName) - { - return (T) FindValueDescriptor(extensionPoint, memberName).GetValue(extensionPoint.ExtendedValue); - } - - public virtual object Get(IReflectionExtensionPoint extensionPoint, IEnumerable memberNames) - { - return Get(extensionPoint, memberNames); - } - - public virtual T Get(IReflectionExtensionPoint extensionPoint, IEnumerable memberNames) - { - return Get(extensionPoint, GetDescriptors(extensionPoint, memberNames).Cast()); - } - - public virtual object Get(IReflectionExtensionPoint extensionPoint, - IEnumerable descriptors) - { - return Get(extensionPoint, descriptors); - } - - public virtual T Get(IReflectionExtensionPoint extensionPoint, - IEnumerable descriptors) - { - var value = extensionPoint.ExtendedValue; - - descriptors.ForEach(item => value = item.GetValue(value)); - - return (T) value; - } - - public virtual void Set(IReflectionExtensionPoint extensionPoint, string memberName, T value) - { - FindValueDescriptor(extensionPoint, memberName).SetValue(extensionPoint.ExtendedValue, value); - } - - public virtual void Set(IReflectionExtensionPoint extensionPoint, IEnumerable memberNames, T value) - { - Set(extensionPoint, GetDescriptors(extensionPoint, memberNames).Cast(), value); - } - - public virtual void Set(IReflectionExtensionPoint extensionPoint, - IEnumerable descriptors, T value) - { - var allButLast = descriptors.Take(descriptors.Count() - 1); - - var last = descriptors.Last(); - - var currentValue = extensionPoint.Get(allButLast); - - currentValue.Reflection().Set(last.MemberInfo.Name, value); - } - - public virtual IEnumerable GetValueDescriptors(IReflectionExtensionPoint extensionPoint, - IEnumerable memberNames) - { - return GetDescriptors(extensionPoint, memberNames).Cast(); - } - - public virtual IEnumerable GetDescriptors(IReflectionExtensionPoint extensionPoint, - IEnumerable memberNames) - { - IMemberDescriptor descriptor = null; - - foreach (var memberName in memberNames) - { - descriptor = descriptor == null - ? FindDescriptor(extensionPoint, memberName) - : FindDescriptor(descriptor, memberName); - - yield return descriptor; - } - } - - public virtual IMemberDescriptor GetDescriptor(IReflectionExtensionPoint extensionPoint) - { + public class DefaultReflectionExtensions : IReflectionExtensions + { + #region IReflectionExtensions Members + + public virtual object Get(IReflectionExtensionPoint extensionPoint, string memberName) + { + return Get(extensionPoint, memberName); + } + + public virtual T Get(IReflectionExtensionPoint extensionPoint, string memberName) + { + return (T) FindValueDescriptor(extensionPoint, memberName).GetValue(extensionPoint.ExtendedValue); + } + + public virtual object Get(IReflectionExtensionPoint extensionPoint, IEnumerable memberNames) + { + return Get(extensionPoint, memberNames); + } + + public virtual T Get(IReflectionExtensionPoint extensionPoint, IEnumerable memberNames) + { + return Get(extensionPoint, GetDescriptors(extensionPoint, memberNames).Cast()); + } + + public virtual object Get(IReflectionExtensionPoint extensionPoint, + IEnumerable descriptors) + { + return Get(extensionPoint, descriptors); + } + + public virtual T Get(IReflectionExtensionPoint extensionPoint, + IEnumerable descriptors) + { + var value = extensionPoint.ExtendedValue; + + descriptors.ForEach(item => value = item.GetValue(value)); + + return (T) value; + } + + public virtual void Set(IReflectionExtensionPoint extensionPoint, string memberName, T value) + { + FindValueDescriptor(extensionPoint, memberName).SetValue(extensionPoint.ExtendedValue, value); + } + + public virtual void Set(IReflectionExtensionPoint extensionPoint, IEnumerable memberNames, T value) + { + Set(extensionPoint, GetDescriptors(extensionPoint, memberNames).Cast(), value); + } + + public virtual void Set(IReflectionExtensionPoint extensionPoint, + IEnumerable descriptors, T value) + { + var allButLast = descriptors.Take(descriptors.Count() - 1); + + var last = descriptors.Last(); + + var currentValue = extensionPoint.Get(allButLast); + + currentValue.Reflection().Set(last.MemberInfo.Name, value); + } + + public virtual IEnumerable GetValueDescriptors(IReflectionExtensionPoint extensionPoint, + IEnumerable memberNames) + { + return GetDescriptors(extensionPoint, memberNames).Cast(); + } + + public virtual IEnumerable GetDescriptors(IReflectionExtensionPoint extensionPoint, + IEnumerable memberNames) + { + IMemberDescriptor descriptor = null; + + foreach (var memberName in memberNames) + { + descriptor = descriptor == null + ? FindDescriptor(extensionPoint, memberName) + : FindDescriptor(descriptor, memberName); + + yield return descriptor; + } + } + + public virtual IMemberDescriptor GetDescriptor(IReflectionExtensionPoint extensionPoint) + { #if !WINDOWS_UWP - return GetDescriptor(extensionPoint.ExtendedType); + return GetDescriptor(extensionPoint.ExtendedType); #else - return GetDescriptor(extensionPoint.ExtendedType.GetTypeInfo()); + return GetDescriptor(extensionPoint.ExtendedType.GetTypeInfo()); #endif - } + } - public virtual IMemberDescriptor GetDescriptor(IMemberDescriptor descriptor, string memberName) - { - var item = FindDescriptor(descriptor, memberName); + public virtual IMemberDescriptor GetDescriptor(IMemberDescriptor descriptor, string memberName) + { + var item = FindDescriptor(descriptor, memberName); - return item.Validation().Found(); - } + return item.Validation().Found(); + } - public virtual IMemberDescriptor FindDescriptor(IMemberDescriptor descriptor, string memberName) - { - var mi = descriptor.Type.FindMemberInfo(memberName, BindingContract.Default); + public virtual IMemberDescriptor FindDescriptor(IMemberDescriptor descriptor, string memberName) + { + var mi = descriptor.Type.FindMemberInfo(memberName, BindingContract.Default); - return mi == null ? null : GetDescriptor(mi); - } + return mi == null ? null : GetDescriptor(mi); + } - public virtual IValueMemberDescriptor GetValueDescriptor(IReflectionExtensionPoint extensionPoint, - string memberName) - { - var descriptor = FindValueDescriptor(extensionPoint, memberName); + public virtual IValueMemberDescriptor GetValueDescriptor(IReflectionExtensionPoint extensionPoint, + string memberName) + { + var descriptor = FindValueDescriptor(extensionPoint, memberName); - return descriptor.Validation().Found(); - } + return descriptor.Validation().Found(); + } - public virtual IValueMemberDescriptor FindValueDescriptor(IReflectionExtensionPoint extensionPoint, - string memberName) - { - return (IValueMemberDescriptor) FindDescriptor(extensionPoint, memberName); - } + public virtual IValueMemberDescriptor FindValueDescriptor(IReflectionExtensionPoint extensionPoint, + string memberName) + { + return (IValueMemberDescriptor) FindDescriptor(extensionPoint, memberName); + } - public virtual IMemberDescriptor GetDescriptor(IReflectionExtensionPoint extensionPoint, string memberName) - { - var descriptor = FindDescriptor(extensionPoint, memberName); + public virtual IMemberDescriptor GetDescriptor(IReflectionExtensionPoint extensionPoint, string memberName) + { + var descriptor = FindDescriptor(extensionPoint, memberName); - return descriptor.Validation().Found(); - } + return descriptor.Validation().Found(); + } - public virtual IMemberDescriptor FindDescriptor(IReflectionExtensionPoint extensionPoint, string memberName) - { - return FindDescriptor(extensionPoint, memberName, BindingContract.Default); - } + public virtual IMemberDescriptor FindDescriptor(IReflectionExtensionPoint extensionPoint, string memberName) + { + return FindDescriptor(extensionPoint, memberName, BindingContract.Default); + } - public virtual IMemberDescriptor FindDescriptor(IReflectionExtensionPoint extensionPoint, string memberName, - BindingContract contract) - { - var mi = extensionPoint.ExtendedType.FindMemberInfo(memberName, contract); + public virtual IMemberDescriptor FindDescriptor(IReflectionExtensionPoint extensionPoint, string memberName, + BindingContract contract) + { + var mi = extensionPoint.ExtendedType.FindMemberInfo(memberName, contract); - return mi == null ? null : GetDescriptor(mi); - } + return mi == null ? null : GetDescriptor(mi); + } - public virtual IReflectionExtensionPoint Reflection(Type type) - { - return new ReflectionExtensionPoint(type); - } + public virtual IReflectionExtensionPoint Reflection(Type type) + { + return new ReflectionExtensionPoint(type); + } - public virtual IReflectionExtensionPoint Reflection(T instance) - { - return new ReflectionExtensionPoint(instance); - } + public virtual IReflectionExtensionPoint Reflection(T instance) + { + return new ReflectionExtensionPoint(instance); + } - public virtual IDisposable Observe(IEventDescriptor descriptor, object publisher, object observer, - string methodName) - { + public virtual IDisposable Observe(IEventDescriptor descriptor, object publisher, object observer, + string methodName) + { #if !WINDOWS_UWP && !HAS_CRIPPLEDREFLECTION - var callback = Delegate.CreateDelegate(descriptor.Type, observer, methodName); + var callback = Delegate.CreateDelegate(descriptor.Type, observer, methodName); - descriptor.Add.Invoke(publisher, callback); + descriptor.Add.Invoke(publisher, callback); - Action dispose = () => descriptor.Remove.Invoke(publisher, callback); + Action dispose = () => descriptor.Remove.Invoke(publisher, callback); - return dispose.ToDisposable(); + return dispose.ToDisposable(); #else - throw new NotImplementedException(); + throw new NotImplementedException(); #endif - } + } - public virtual IMemberDescriptor GetDescriptor(MemberInfo mi) - { - var descriptor = FindDescriptor(mi); + public virtual IMemberDescriptor GetDescriptor(MemberInfo mi) + { + var descriptor = FindDescriptor(mi); - if (descriptor == null) - { - throw new ArgumentException("Not Supported"); - } - return descriptor; - } + if (descriptor == null) + { + throw new ArgumentException("Not Supported"); + } + return descriptor; + } - public virtual IMemberDescriptor GetDescriptor(IReflectionExtensionPoint extensionPoint, Expression> func) - { - return GetMemberInfo((LambdaExpression)func); - } + public virtual IMemberDescriptor GetDescriptor(IReflectionExtensionPoint extensionPoint, Expression> func) + { + return GetMemberInfo((LambdaExpression)func); + } - public virtual IMemberDescriptor GetDescriptor(IReflectionExtensionPoint extensionPoint, Expression> func) - { - return GetMemberInfo((LambdaExpression)func); - } + public virtual IMemberDescriptor GetDescriptor(IReflectionExtensionPoint extensionPoint, Expression> func) + { + return GetMemberInfo((LambdaExpression)func); + } - #endregion + #endregion - // TODO: rewrite if-else statements - protected virtual IMemberDescriptor FindDescriptor(MemberInfo mi) - { - var propertyInfo = mi as PropertyInfo; + // TODO: rewrite if-else statements + protected virtual IMemberDescriptor FindDescriptor(MemberInfo mi) + { + var propertyInfo = mi as PropertyInfo; if (propertyInfo == null) { @@ -253,7 +254,7 @@ protected virtual IMemberDescriptor FindDescriptor(MemberInfo mi) } } #else - return null; + return null; #endif } else @@ -271,7 +272,7 @@ protected virtual IMemberDescriptor FindDescriptor(MemberInfo mi) #if !WINDOWS_PHONE && !NETFX_CORE && !HAS_CRIPPLEDREFLECTION return new FieldDescriptor(fieldInfo); #else - return null; + return null; #endif } } @@ -279,20 +280,20 @@ protected virtual IMemberDescriptor FindDescriptor(MemberInfo mi) { return new PropertyDescriptor(propertyInfo); } - } + } - private IMemberDescriptor GetMemberInfo(LambdaExpression func) - { - MethodCallExpression call = func.Body as MethodCallExpression; + private IMemberDescriptor GetMemberInfo(LambdaExpression func) + { + MethodCallExpression call = func.Body as MethodCallExpression; - MemberExpression member = func.Body as MemberExpression; + MemberExpression member = func.Body as MemberExpression; - if (member != null) - { - return FindDescriptor(member.Member); - } + if (member != null) + { + return FindDescriptor(member.Member); + } - throw new ArgumentException("The expression must call a method, a property or get a field at the first level."); - } - } -} \ No newline at end of file + throw new ArgumentException("The expression must call a method, a property or get a field at the first level."); + } + } +} diff --git a/src/Uno.Core/Reflection/EventDescriptor.cs b/src/Uno.Core/Reflection/EventDescriptor.cs index d23b81e..b773c03 100644 --- a/src/Uno.Core/Reflection/EventDescriptor.cs +++ b/src/Uno.Core/Reflection/EventDescriptor.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Reflection; using Uno.Extensions; @@ -21,37 +22,37 @@ namespace Uno.Reflection { - public class EventDescriptor : MemberDescriptor, IEventDescriptor - { - private Dictionary descriptors = new Dictionary(); - - public EventDescriptor(EventInfo eventInfo) - : base(eventInfo) - { - } - - #region IEventDescriptor Members - - public override Type Type - { - get { return MemberInfo.EventHandlerType; } - } - - public override bool IsStatic - { - get { return Add.IsStatic; } - } - - public IMethodDescriptor Add - { - get { return descriptors.FindOrCreate("Add", () => (IMethodDescriptor)MemberInfo.GetAddMethod(true).GetDescriptor()); } - } - - public IMethodDescriptor Remove - { - get { return descriptors.FindOrCreate("Remove", () => (IMethodDescriptor)MemberInfo.GetRemoveMethod(true).GetDescriptor()); } - } - - #endregion - } -} \ No newline at end of file + public class EventDescriptor : MemberDescriptor, IEventDescriptor + { + private Dictionary descriptors = new Dictionary(); + + public EventDescriptor(EventInfo eventInfo) + : base(eventInfo) + { + } + + #region IEventDescriptor Members + + public override Type Type + { + get { return MemberInfo.EventHandlerType; } + } + + public override bool IsStatic + { + get { return Add.IsStatic; } + } + + public IMethodDescriptor Add + { + get { return descriptors.FindOrCreate("Add", () => (IMethodDescriptor)MemberInfo.GetAddMethod(true).GetDescriptor()); } + } + + public IMethodDescriptor Remove + { + get { return descriptors.FindOrCreate("Remove", () => (IMethodDescriptor)MemberInfo.GetRemoveMethod(true).GetDescriptor()); } + } + + #endregion + } +} diff --git a/src/Uno.Core/Reflection/FieldDescriptor.cs b/src/Uno.Core/Reflection/FieldDescriptor.cs index 506d7e0..c61c4c2 100644 --- a/src/Uno.Core/Reflection/FieldDescriptor.cs +++ b/src/Uno.Core/Reflection/FieldDescriptor.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + #if !HAS_CRIPPLEDREFLECTION using System; using System.Reflection; @@ -24,12 +25,12 @@ namespace Uno.Reflection { - public class FieldDescriptor : ValueMemberDescriptor - { - public FieldDescriptor(FieldInfo fi) - : base(fi) - { - } + public class FieldDescriptor : ValueMemberDescriptor + { + public FieldDescriptor(FieldInfo fi) + : base(fi) + { + } public override Type Type => MemberInfo.FieldType; @@ -70,47 +71,47 @@ public FieldDescriptor(FieldInfo fi) /// parameter types before the call. Invalid parameters could result in unexpected behavior. /// public static Action ToCompiledSetValue(RuntimeTypeHandle typeHandle, RuntimeFieldHandle fieldHandle, bool strict) - { - var fieldInfo = FieldInfo.GetFieldFromHandle(fieldHandle, typeHandle); + { + var fieldInfo = FieldInfo.GetFieldFromHandle(fieldHandle, typeHandle); - if (fieldInfo.IsStatic || fieldInfo.DeclaringType.IsValueType) - { - // Don't compile code for static fields - return fieldInfo.SetValue; - } + if (fieldInfo.IsStatic || fieldInfo.DeclaringType.IsValueType) + { + // Don't compile code for static fields + return fieldInfo.SetValue; + } - var name = "Set_{0}.{1}-{2}".InvariantCultureFormat(fieldInfo.DeclaringType.Name, fieldInfo.Name, Guid.NewGuid()); + var name = "Set_{0}.{1}-{2}".InvariantCultureFormat(fieldInfo.DeclaringType.Name, fieldInfo.Name, Guid.NewGuid()); - var method = new DynamicMethod(name, typeof(void), new[] { typeof(object), typeof(object) }, typeof(FieldDescriptor), true); + var method = new DynamicMethod(name, typeof(void), new[] { typeof(object), typeof(object) }, typeof(FieldDescriptor), true); var il = method.GetILGenerator(); - il.Emit(OpCodes.Ldarg_0); + il.Emit(OpCodes.Ldarg_0); - if (strict) - { - il.Emit(OpCodes.Castclass, fieldInfo.DeclaringType); - } + if (strict) + { + il.Emit(OpCodes.Castclass, fieldInfo.DeclaringType); + } - il.Emit(OpCodes.Ldarg_1); + il.Emit(OpCodes.Ldarg_1); - if (fieldInfo.FieldType.IsValueType) - { - il.Emit(OpCodes.Unbox_Any, fieldInfo.FieldType); - } - else - { - if (strict) - { - il.Emit(OpCodes.Castclass, fieldInfo.FieldType); - } - } + if (fieldInfo.FieldType.IsValueType) + { + il.Emit(OpCodes.Unbox_Any, fieldInfo.FieldType); + } + else + { + if (strict) + { + il.Emit(OpCodes.Castclass, fieldInfo.FieldType); + } + } - il.Emit(OpCodes.Stfld, fieldInfo); - il.Emit(OpCodes.Ret); + il.Emit(OpCodes.Stfld, fieldInfo); + il.Emit(OpCodes.Ret); - return method.CreateDelegate(typeof(Action)) as Action; - } + return method.CreateDelegate(typeof(Action)) as Action; + } /// /// Creates a compiled method that will get the value of a field @@ -143,41 +144,41 @@ public static Action ToCompiledSetValue(RuntimeTypeHandle typeHa /// parameter types before the call. An invalid parameter could result in unexpected behavior. /// public static Func ToCompiledGetValue(RuntimeTypeHandle typeHandle, RuntimeFieldHandle fieldHandle, bool strict) - { - var fieldInfo = FieldInfo.GetFieldFromHandle(fieldHandle, typeHandle); + { + var fieldInfo = FieldInfo.GetFieldFromHandle(fieldHandle, typeHandle); - if (fieldInfo.IsStatic || fieldInfo.DeclaringType.IsValueType) - { - // Don't compile code for static fields or fields from value types - return fieldInfo.GetValue; - } + if (fieldInfo.IsStatic || fieldInfo.DeclaringType.IsValueType) + { + // Don't compile code for static fields or fields from value types + return fieldInfo.GetValue; + } - var name = "Get_{0}.{1}-{2}".InvariantCultureFormat(fieldInfo.DeclaringType.Name, fieldInfo.Name, Guid.NewGuid()); + var name = "Get_{0}.{1}-{2}".InvariantCultureFormat(fieldInfo.DeclaringType.Name, fieldInfo.Name, Guid.NewGuid()); var method = new DynamicMethod(name, typeof(object), new[] { typeof(object) }, typeof(FieldDescriptor), true); var il = method.GetILGenerator(); - il.DeclareLocal(typeof(object)); + il.DeclareLocal(typeof(object)); - il.Emit(OpCodes.Ldarg_0); + il.Emit(OpCodes.Ldarg_0); - if (strict) - { - il.Emit(OpCodes.Castclass, fieldInfo.DeclaringType); - } + if (strict) + { + il.Emit(OpCodes.Castclass, fieldInfo.DeclaringType); + } - il.Emit(OpCodes.Ldfld, fieldInfo); + il.Emit(OpCodes.Ldfld, fieldInfo); - if (fieldInfo.FieldType.IsValueType) - { - il.Emit(OpCodes.Box, fieldInfo.FieldType); - } + if (fieldInfo.FieldType.IsValueType) + { + il.Emit(OpCodes.Box, fieldInfo.FieldType); + } - il.Emit(OpCodes.Ret); + il.Emit(OpCodes.Ret); - return method.CreateDelegate(typeof(Func)) as Func; - } - } + return method.CreateDelegate(typeof(Func)) as Func; + } + } } -#endif \ No newline at end of file +#endif diff --git a/src/Uno.Core/Reflection/IContract.cs b/src/Uno.Core/Reflection/IContract.cs index c79d4d6..f2f090d 100644 --- a/src/Uno.Core/Reflection/IContract.cs +++ b/src/Uno.Core/Reflection/IContract.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,9 +14,10 @@ // limitations under the License. // // ****************************************************************** + namespace Uno.Contracts { - public interface IContract - { - } -} \ No newline at end of file + public interface IContract + { + } +} diff --git a/src/Uno.Core/Reflection/IEventDescriptor.cs b/src/Uno.Core/Reflection/IEventDescriptor.cs index 4a0fa46..ca49092 100644 --- a/src/Uno.Core/Reflection/IEventDescriptor.cs +++ b/src/Uno.Core/Reflection/IEventDescriptor.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,11 +14,12 @@ // limitations under the License. // // ****************************************************************** + namespace Uno.Reflection { - public interface IEventDescriptor : IMemberDescriptor - { - IMethodDescriptor Add { get; } - IMethodDescriptor Remove { get; } - } -} \ No newline at end of file + public interface IEventDescriptor : IMemberDescriptor + { + IMethodDescriptor Add { get; } + IMethodDescriptor Remove { get; } + } +} diff --git a/src/Uno.Core/Reflection/IMemberDescriptor.cs b/src/Uno.Core/Reflection/IMemberDescriptor.cs index 227a5c2..f63d3ba 100644 --- a/src/Uno.Core/Reflection/IMemberDescriptor.cs +++ b/src/Uno.Core/Reflection/IMemberDescriptor.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,26 +14,27 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Reflection; namespace Uno.Reflection { - public interface IMemberDescriptor - { - Type Type { get; } + public interface IMemberDescriptor + { + Type Type { get; } - MemberInfo MemberInfo { get; } + MemberInfo MemberInfo { get; } - bool IsStatic { get; } - bool IsInstance { get; } + bool IsStatic { get; } + bool IsInstance { get; } - bool IsGeneric { get; } + bool IsGeneric { get; } - bool IsOpen { get; } - bool IsClosed { get; } + bool IsOpen { get; } + bool IsClosed { get; } - IMemberDescriptor Open(); - IMemberDescriptor Close(params Type[] types); - } -} \ No newline at end of file + IMemberDescriptor Open(); + IMemberDescriptor Close(params Type[] types); + } +} diff --git a/src/Uno.Core/Reflection/IMethodDescriptor.cs b/src/Uno.Core/Reflection/IMethodDescriptor.cs index 6630f68..77f9d9a 100644 --- a/src/Uno.Core/Reflection/IMethodDescriptor.cs +++ b/src/Uno.Core/Reflection/IMethodDescriptor.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,30 +14,31 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno.Reflection { - public interface IMethodDescriptor : IMemberDescriptor - { - object Invoke(object instance, params object[] args); + public interface IMethodDescriptor : IMemberDescriptor + { + object Invoke(object instance, params object[] args); - /// - /// Build a compiled method that will call the specified method. - /// - /// The method to invoke - /// A delegate that will call the requested method - Func ToCompiledMethodInvoke(); + /// + /// Build a compiled method that will call the specified method. + /// + /// The method to invoke + /// A delegate that will call the requested method + Func ToCompiledMethodInvoke(); - /// - /// Build a compiled method that will call the specified method. - /// - /// The method to invoke - /// Removes some type checking to enhance performance if set to false. - /// A delegate that will call the requested method - /// - /// The use of the strict parameter is required if the caller of the generated method does not validate - /// parameter types before the call. An invalid parameter could result in unexpected behavior. - /// - Func ToCompiledMethodInvoke(bool strict); - } -} \ No newline at end of file + /// + /// Build a compiled method that will call the specified method. + /// + /// The method to invoke + /// Removes some type checking to enhance performance if set to false. + /// A delegate that will call the requested method + /// + /// The use of the strict parameter is required if the caller of the generated method does not validate + /// parameter types before the call. An invalid parameter could result in unexpected behavior. + /// + Func ToCompiledMethodInvoke(bool strict); + } +} diff --git a/src/Uno.Core/Reflection/IReflectionExtensionPoint.cs b/src/Uno.Core/Reflection/IReflectionExtensionPoint.cs index 9f78a5d..f22bd7e 100644 --- a/src/Uno.Core/Reflection/IReflectionExtensionPoint.cs +++ b/src/Uno.Core/Reflection/IReflectionExtensionPoint.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,15 +14,16 @@ // limitations under the License. // // ****************************************************************** + using Uno.Extensions; namespace Uno.Reflection { - public interface IReflectionExtensionPoint : IExtensionPoint - { - } + public interface IReflectionExtensionPoint : IExtensionPoint + { + } - public interface IReflectionExtensionPoint : IReflectionExtensionPoint - { - } -} \ No newline at end of file + public interface IReflectionExtensionPoint : IReflectionExtensionPoint + { + } +} diff --git a/src/Uno.Core/Reflection/IReflectionExtensions.cs b/src/Uno.Core/Reflection/IReflectionExtensions.cs index 8c28420..00dfc1c 100644 --- a/src/Uno.Core/Reflection/IReflectionExtensions.cs +++ b/src/Uno.Core/Reflection/IReflectionExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Reflection; @@ -21,49 +22,49 @@ namespace Uno.Reflection { - public interface IReflectionExtensions - { - IReflectionExtensionPoint Reflection(Type type); - IReflectionExtensionPoint Reflection(T instance); + public interface IReflectionExtensions + { + IReflectionExtensionPoint Reflection(Type type); + IReflectionExtensionPoint Reflection(T instance); - object Get(IReflectionExtensionPoint extensionPoint, string memberName); - T Get(IReflectionExtensionPoint extensionPoint, string memberName); + object Get(IReflectionExtensionPoint extensionPoint, string memberName); + T Get(IReflectionExtensionPoint extensionPoint, string memberName); - object Get(IReflectionExtensionPoint extensionPoint, IEnumerable memberNames); - T Get(IReflectionExtensionPoint extensionPoint, IEnumerable memberNames); + object Get(IReflectionExtensionPoint extensionPoint, IEnumerable memberNames); + T Get(IReflectionExtensionPoint extensionPoint, IEnumerable memberNames); - object Get(IReflectionExtensionPoint extensionPoint, IEnumerable descriptors); - T Get(IReflectionExtensionPoint extensionPoint, IEnumerable descriptors); + object Get(IReflectionExtensionPoint extensionPoint, IEnumerable descriptors); + T Get(IReflectionExtensionPoint extensionPoint, IEnumerable descriptors); - void Set(IReflectionExtensionPoint extensionPoint, string memberName, T value); - void Set(IReflectionExtensionPoint extensionPoint, IEnumerable memberNames, T value); - void Set(IReflectionExtensionPoint extensionPoint, IEnumerable descriptors, T value); + void Set(IReflectionExtensionPoint extensionPoint, string memberName, T value); + void Set(IReflectionExtensionPoint extensionPoint, IEnumerable memberNames, T value); + void Set(IReflectionExtensionPoint extensionPoint, IEnumerable descriptors, T value); - IEnumerable GetValueDescriptors(IReflectionExtensionPoint extensionPoint, - IEnumerable memberNames); + IEnumerable GetValueDescriptors(IReflectionExtensionPoint extensionPoint, + IEnumerable memberNames); - IEnumerable GetDescriptors(IReflectionExtensionPoint extensionPoint, - IEnumerable memberNames); + IEnumerable GetDescriptors(IReflectionExtensionPoint extensionPoint, + IEnumerable memberNames); - IMemberDescriptor GetDescriptor(IMemberDescriptor descriptor, string memberName); - IMemberDescriptor GetDescriptor(IReflectionExtensionPoint extensionPoint, Expression> func); - IMemberDescriptor GetDescriptor(IReflectionExtensionPoint extensionPoint, Expression> func); + IMemberDescriptor GetDescriptor(IMemberDescriptor descriptor, string memberName); + IMemberDescriptor GetDescriptor(IReflectionExtensionPoint extensionPoint, Expression> func); + IMemberDescriptor GetDescriptor(IReflectionExtensionPoint extensionPoint, Expression> func); - IMemberDescriptor FindDescriptor(IMemberDescriptor descriptor, string memberName); + IMemberDescriptor FindDescriptor(IMemberDescriptor descriptor, string memberName); - IValueMemberDescriptor GetValueDescriptor(IReflectionExtensionPoint extensionPoint, string memberName); - IValueMemberDescriptor FindValueDescriptor(IReflectionExtensionPoint extensionPoint, string memberName); + IValueMemberDescriptor GetValueDescriptor(IReflectionExtensionPoint extensionPoint, string memberName); + IValueMemberDescriptor FindValueDescriptor(IReflectionExtensionPoint extensionPoint, string memberName); - //TODO GetMethodDescriptor + FindMethodDescriptor - IMemberDescriptor GetDescriptor(IReflectionExtensionPoint extensionPoint); - IMemberDescriptor GetDescriptor(IReflectionExtensionPoint extensionPoint, string memberName); - IMemberDescriptor FindDescriptor(IReflectionExtensionPoint extensionPoint, string memberName); + //TODO GetMethodDescriptor + FindMethodDescriptor + IMemberDescriptor GetDescriptor(IReflectionExtensionPoint extensionPoint); + IMemberDescriptor GetDescriptor(IReflectionExtensionPoint extensionPoint, string memberName); + IMemberDescriptor FindDescriptor(IReflectionExtensionPoint extensionPoint, string memberName); - IMemberDescriptor FindDescriptor(IReflectionExtensionPoint extensionPoint, string memberName, - BindingContract contract); + IMemberDescriptor FindDescriptor(IReflectionExtensionPoint extensionPoint, string memberName, + BindingContract contract); - IMemberDescriptor GetDescriptor(MemberInfo mi); + IMemberDescriptor GetDescriptor(MemberInfo mi); - IDisposable Observe(IEventDescriptor descriptor, object publisher, object observer, string methodName); - } -} \ No newline at end of file + IDisposable Observe(IEventDescriptor descriptor, object publisher, object observer, string methodName); + } +} diff --git a/src/Uno.Core/Reflection/IValueMemberDescriptor.cs b/src/Uno.Core/Reflection/IValueMemberDescriptor.cs index d96cb49..5f94154 100644 --- a/src/Uno.Core/Reflection/IValueMemberDescriptor.cs +++ b/src/Uno.Core/Reflection/IValueMemberDescriptor.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,48 +14,49 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno.Reflection { - public interface IValueMemberDescriptor : IMemberDescriptor - { - object GetValue(object instance); - void SetValue(object instance, object value); + public interface IValueMemberDescriptor : IMemberDescriptor + { + object GetValue(object instance); + void SetValue(object instance, object value); - /// - /// Creates a compiled method that will allow a the assignation of the current member. - /// - /// A delegate taking an instance as the first parameter, and the value as the second parameter. - Action ToCompiledSetValue(); + /// + /// Creates a compiled method that will allow a the assignation of the current member. + /// + /// A delegate taking an instance as the first parameter, and the value as the second parameter. + Action ToCompiledSetValue(); - /// - /// Creates a compiled method that will allow a the assignation of the current member. - /// - /// Removes some type checking to enhance performance if set to false. - /// A delegate taking an instance as the first parameter, and the value as the second parameter. - /// - /// The use of the strict parameter is required if the caller of the generated method does not validate - /// parameter types before the call. Invalid parameters could result in unexpected behavior. - /// - Action ToCompiledSetValue(bool strict); + /// + /// Creates a compiled method that will allow a the assignation of the current member. + /// + /// Removes some type checking to enhance performance if set to false. + /// A delegate taking an instance as the first parameter, and the value as the second parameter. + /// + /// The use of the strict parameter is required if the caller of the generated method does not validate + /// parameter types before the call. Invalid parameters could result in unexpected behavior. + /// + Action ToCompiledSetValue(bool strict); - /// - /// Creates a compiled method that will get the value of of the current member. - /// - /// The field to get the value from. - /// - Func ToCompiledGetValue(); + /// + /// Creates a compiled method that will get the value of of the current member. + /// + /// The field to get the value from. + /// + Func ToCompiledGetValue(); - /// - /// Creates a compiled method that will get the value of of the current member. - /// - /// The field to get the value from. - /// Removes some type checking to enhance performance if set to false. - /// A delegate taking an instance as the first parameter, and returns the value of the field. - /// - /// The use of the strict parameter is required if the caller of the generated method does not validate - /// parameter types before the call. An invalid parameter could result in unexpected behavior. - /// - Func ToCompiledGetValue(bool strict); - } -} \ No newline at end of file + /// + /// Creates a compiled method that will get the value of of the current member. + /// + /// The field to get the value from. + /// Removes some type checking to enhance performance if set to false. + /// A delegate taking an instance as the first parameter, and returns the value of the field. + /// + /// The use of the strict parameter is required if the caller of the generated method does not validate + /// parameter types before the call. An invalid parameter could result in unexpected behavior. + /// + Func ToCompiledGetValue(bool strict); + } +} diff --git a/src/Uno.Core/Reflection/MemberDescriptor.cs b/src/Uno.Core/Reflection/MemberDescriptor.cs index 2a6076e..ddd449f 100644 --- a/src/Uno.Core/Reflection/MemberDescriptor.cs +++ b/src/Uno.Core/Reflection/MemberDescriptor.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,72 +14,73 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Reflection; using Uno.Extensions; namespace Uno.Reflection { - public abstract class MemberDescriptor : IMemberDescriptor - where TMemberInfo : MemberInfo - { - private readonly TMemberInfo memberInfo; + public abstract class MemberDescriptor : IMemberDescriptor + where TMemberInfo : MemberInfo + { + private readonly TMemberInfo memberInfo; - // TODO: protected constructor? - public MemberDescriptor(TMemberInfo memberInfo) - { - this.memberInfo = memberInfo.Validation().NotNull("memberInfo"); - } + // TODO: protected constructor? + public MemberDescriptor(TMemberInfo memberInfo) + { + this.memberInfo = memberInfo.Validation().NotNull("memberInfo"); + } - public TMemberInfo MemberInfo - { - get { return memberInfo; } - } + public TMemberInfo MemberInfo + { + get { return memberInfo; } + } - #region IMemberDescriptor Members + #region IMemberDescriptor Members - public abstract Type Type { get; } + public abstract Type Type { get; } - MemberInfo IMemberDescriptor.MemberInfo - { - get { return memberInfo; } - } + MemberInfo IMemberDescriptor.MemberInfo + { + get { return memberInfo; } + } - public virtual bool IsStatic - { - get { return false; } - } + public virtual bool IsStatic + { + get { return false; } + } - public virtual bool IsInstance - { - get { return !IsStatic; } - } + public virtual bool IsInstance + { + get { return !IsStatic; } + } - public virtual bool IsGeneric - { - get { return false; } - } + public virtual bool IsGeneric + { + get { return false; } + } - public virtual bool IsOpen - { - get { return false; } - } + public virtual bool IsOpen + { + get { return false; } + } - public virtual bool IsClosed - { - get { return !IsOpen; } - } + public virtual bool IsClosed + { + get { return !IsOpen; } + } - public virtual IMemberDescriptor Open() - { - throw new InvalidOperationException(); - } + public virtual IMemberDescriptor Open() + { + throw new InvalidOperationException(); + } - public virtual IMemberDescriptor Close(params Type[] types) - { - throw new InvalidOperationException(); - } + public virtual IMemberDescriptor Close(params Type[] types) + { + throw new InvalidOperationException(); + } - #endregion - } -} \ No newline at end of file + #endregion + } +} diff --git a/src/Uno.Core/Reflection/MemberDescriptorExtensions.cs b/src/Uno.Core/Reflection/MemberDescriptorExtensions.cs index c9c6ac8..91b096f 100644 --- a/src/Uno.Core/Reflection/MemberDescriptorExtensions.cs +++ b/src/Uno.Core/Reflection/MemberDescriptorExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Reflection; using System.Linq; @@ -21,14 +22,14 @@ namespace Uno.Extensions { - //TODO Use Extensions Pattern or move to ReflectionExtensions. Or maybe MemberInfoExtensions directly. - public static class MemberDescriptorExtensions - { - public static T FindAttribute(this IMemberDescriptor descriptor) - where T : Attribute - { - var attributes = descriptor.MemberInfo.GetCustomAttributes(typeof (T), true); - return attributes.FirstOrDefault() as T; - } - } -} \ No newline at end of file + //TODO Use Extensions Pattern or move to ReflectionExtensions. Or maybe MemberInfoExtensions directly. + public static class MemberDescriptorExtensions + { + public static T FindAttribute(this IMemberDescriptor descriptor) + where T : Attribute + { + var attributes = descriptor.MemberInfo.GetCustomAttributes(typeof (T), true); + return attributes.FirstOrDefault() as T; + } + } +} diff --git a/src/Uno.Core/Reflection/NestedTypeDescriptor.cs b/src/Uno.Core/Reflection/NestedTypeDescriptor.cs index b47d22e..54bba59 100644 --- a/src/Uno.Core/Reflection/NestedTypeDescriptor.cs +++ b/src/Uno.Core/Reflection/NestedTypeDescriptor.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,78 +14,79 @@ // limitations under the License. // // ****************************************************************** + #if !WINDOWS_UWP using System; namespace Uno.Reflection { - public class NestedTypeDescriptor : TypeDescriptor, IValueMemberDescriptor - { - public NestedTypeDescriptor(Type type) - : base(type) - { - } + public class NestedTypeDescriptor : TypeDescriptor, IValueMemberDescriptor + { + public NestedTypeDescriptor(Type type) + : base(type) + { + } - #region IValueMemberDescriptor Members + #region IValueMemberDescriptor Members - public override Type Type - { - get { return MemberInfo; } - } + public override Type Type + { + get { return MemberInfo; } + } - public override bool IsStatic - { - get { return true; } - } + public override bool IsStatic + { + get { return true; } + } - public override IMemberDescriptor Open() - { - return IsClosed ? new NestedTypeDescriptor(MemberInfo.GetGenericTypeDefinition()) : base.Open(); - } + public override IMemberDescriptor Open() + { + return IsClosed ? new NestedTypeDescriptor(MemberInfo.GetGenericTypeDefinition()) : base.Open(); + } - // TODO: params are ignored - public override IMemberDescriptor Close(params Type[] types) - { - if (!IsOpen) - { - return base.Close(types); - } - var closedType = MemberInfo.MakeGenericType(types); + // TODO: params are ignored + public override IMemberDescriptor Close(params Type[] types) + { + if (!IsOpen) + { + return base.Close(types); + } + var closedType = MemberInfo.MakeGenericType(types); - return new NestedTypeDescriptor(closedType); - } + return new NestedTypeDescriptor(closedType); + } - public object GetValue(object instance) - { - return instance; - } + public object GetValue(object instance) + { + return instance; + } - public void SetValue(object instance, object value) - { - throw new NotImplementedException(); - } + public void SetValue(object instance, object value) + { + throw new NotImplementedException(); + } - public Action ToCompiledSetValue() - { - return SetValue; - } + public Action ToCompiledSetValue() + { + return SetValue; + } - public Action ToCompiledSetValue(bool strict) - { - return SetValue; - } + public Action ToCompiledSetValue(bool strict) + { + return SetValue; + } - public Func ToCompiledGetValue() - { - return GetValue; - } + public Func ToCompiledGetValue() + { + return GetValue; + } - public Func ToCompiledGetValue(bool strict) - { - return GetValue; - } + public Func ToCompiledGetValue(bool strict) + { + return GetValue; + } - #endregion - } + #endregion + } } -#endif \ No newline at end of file +#endif diff --git a/src/Uno.Core/Reflection/PropertyDescriptor.cs b/src/Uno.Core/Reflection/PropertyDescriptor.cs index b9fc342..5261c85 100644 --- a/src/Uno.Core/Reflection/PropertyDescriptor.cs +++ b/src/Uno.Core/Reflection/PropertyDescriptor.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,57 +14,58 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Reflection; using Uno.Extensions; namespace Uno.Reflection { - public class PropertyDescriptor : ValueMemberDescriptor - { - public PropertyDescriptor(PropertyInfo pi) - : base(pi) - { - } + public class PropertyDescriptor : ValueMemberDescriptor + { + public PropertyDescriptor(PropertyInfo pi) + : base(pi) + { + } - public override Type Type - { - get { return MemberInfo.PropertyType; } - } + public override Type Type + { + get { return MemberInfo.PropertyType; } + } - public override bool IsStatic - { - get { return MemberInfo.GetGetMethod(true).IsStatic; } - } + public override bool IsStatic + { + get { return MemberInfo.GetGetMethod(true).IsStatic; } + } - public override object GetValue(object instance) - { - return MemberInfo.GetValue(instance, null); - } + public override object GetValue(object instance) + { + return MemberInfo.GetValue(instance, null); + } - public override void SetValue(object instance, object value) - { - MemberInfo.SetValue(instance, value, null); - } + public override void SetValue(object instance, object value) + { + MemberInfo.SetValue(instance, value, null); + } - public override Func ToCompiledGetValue() - { - return instance => MemberInfo.GetValue(instance, null); - } + public override Func ToCompiledGetValue() + { + return instance => MemberInfo.GetValue(instance, null); + } - public override Func ToCompiledGetValue(bool strict) - { - return instance => MemberInfo.GetValue(instance, null); - } + public override Func ToCompiledGetValue(bool strict) + { + return instance => MemberInfo.GetValue(instance, null); + } - public override Action ToCompiledSetValue() - { - return (instance, value) => MemberInfo.SetValue(instance, value, null); - } + public override Action ToCompiledSetValue() + { + return (instance, value) => MemberInfo.SetValue(instance, value, null); + } - public override Action ToCompiledSetValue(bool strict) - { - return (instance, value) => MemberInfo.SetValue(instance, value, null); - } - } -} \ No newline at end of file + public override Action ToCompiledSetValue(bool strict) + { + return (instance, value) => MemberInfo.SetValue(instance, value, null); + } + } +} diff --git a/src/Uno.Core/Reflection/ReflectionExtensionPoint.cs b/src/Uno.Core/Reflection/ReflectionExtensionPoint.cs index f5bd706..349d2d5 100644 --- a/src/Uno.Core/Reflection/ReflectionExtensionPoint.cs +++ b/src/Uno.Core/Reflection/ReflectionExtensionPoint.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,21 +14,22 @@ // limitations under the License. // // ****************************************************************** + using System; using Uno.Extensions; namespace Uno.Reflection { - public class ReflectionExtensionPoint : ExtensionPoint, IReflectionExtensionPoint, IReflectionExtensionPoint - { - public ReflectionExtensionPoint(Type type) - : base(type) - { - } + public class ReflectionExtensionPoint : ExtensionPoint, IReflectionExtensionPoint, IReflectionExtensionPoint + { + public ReflectionExtensionPoint(Type type) + : base(type) + { + } - public ReflectionExtensionPoint(T value) - : base(value) - { - } - } -} \ No newline at end of file + public ReflectionExtensionPoint(T value) + : base(value) + { + } + } +} diff --git a/src/Uno.Core/Reflection/ReflectionExtensions.cs b/src/Uno.Core/Reflection/ReflectionExtensions.cs index 9090765..3f00e38 100644 --- a/src/Uno.Core/Reflection/ReflectionExtensions.cs +++ b/src/Uno.Core/Reflection/ReflectionExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Reflection; @@ -22,174 +23,174 @@ namespace Uno.Extensions { - public static class ReflectionExtensions - { - public static IReflectionExtensions Extensions - { - get { return ExtensionsProvider.Get(); } - } - - public static object Get(this IReflectionExtensionPoint extensionPoint, string memberName) - { - return Extensions.Get(extensionPoint, memberName); - } - - public static T Get(this IReflectionExtensionPoint extensionPoint, string memberName) - { - return Extensions.Get(extensionPoint, memberName); - } - - public static T Get(this IReflectionExtensionPoint extensionPoint, string memberName) - { - return Extensions.Get(extensionPoint, memberName); - } - - public static object Get(this IReflectionExtensionPoint extensionPoint, IEnumerable memberNames) - { - return Extensions.Get(extensionPoint, memberNames); - } - - public static T Get(this IReflectionExtensionPoint extensionPoint, IEnumerable memberNames) - { - return Extensions.Get(extensionPoint, memberNames); - } - - public static T Get(this IReflectionExtensionPoint extensionPoint, IEnumerable memberNames) - { - return Extensions.Get(extensionPoint, memberNames); - } - - public static object Get(this IReflectionExtensionPoint extensionPoint, - IEnumerable descriptors) - { - return Extensions.Get(extensionPoint, descriptors); - } - - public static T Get(this IReflectionExtensionPoint extensionPoint, - IEnumerable descriptors) - { - return Extensions.Get(extensionPoint, descriptors); - } - - public static T Get(this IReflectionExtensionPoint extensionPoint, - IEnumerable descriptors) - { - return Extensions.Get(extensionPoint, descriptors); - } - - public static void Set(this IReflectionExtensionPoint extensionPoint, string memberName, T value) - { - Extensions.Set(extensionPoint, memberName, value); - } - - public static void Set(this IReflectionExtensionPoint extensionPoint, IEnumerable memberNames, - T value) - { - Extensions.Set(extensionPoint, memberNames, value); - } - - public static void Set(this IReflectionExtensionPoint extensionPoint, IEnumerable memberNames, - T value) - { - Extensions.Set(extensionPoint, memberNames, value); - } - - public static void Set(this IReflectionExtensionPoint extensionPoint, - IEnumerable descriptors, T value) - { - Extensions.Set(extensionPoint, descriptors, value); - } - - public static void Set(this IReflectionExtensionPoint extensionPoint, - IEnumerable descriptors, T value) - { - Extensions.Set(extensionPoint, descriptors, value); - } - - public static IEnumerable GetValueDescriptors( - this IReflectionExtensionPoint extensionPoint, IEnumerable memberNames) - { - return Extensions.GetValueDescriptors(extensionPoint, memberNames); - } - - public static IEnumerable GetDescriptors(this IReflectionExtensionPoint extensionPoint, - IEnumerable memberNames) - { - return Extensions.GetDescriptors(extensionPoint, memberNames); - } - - public static IMemberDescriptor GetDescriptor(this IReflectionExtensionPoint extensionPoint) - { - return Extensions.GetDescriptor(extensionPoint); - } - - public static IMemberDescriptor GetDescriptor(this IMemberDescriptor descriptor, string memberName) - { - return Extensions.GetDescriptor(descriptor, memberName); - } - - public static IMemberDescriptor FindDescriptor(this IMemberDescriptor descriptor, string memberName) - { - return Extensions.FindDescriptor(descriptor, memberName); - } - - public static IValueMemberDescriptor GetValueDescriptor(this IReflectionExtensionPoint extensionPoint, - string memberName) - { - return Extensions.GetValueDescriptor(extensionPoint, memberName); - } - - public static IValueMemberDescriptor FindValueDescriptor(this IReflectionExtensionPoint extensionPoint, - string memberName) - { - return Extensions.FindValueDescriptor(extensionPoint, memberName); - } + public static class ReflectionExtensions + { + public static IReflectionExtensions Extensions + { + get { return ExtensionsProvider.Get(); } + } + + public static object Get(this IReflectionExtensionPoint extensionPoint, string memberName) + { + return Extensions.Get(extensionPoint, memberName); + } + + public static T Get(this IReflectionExtensionPoint extensionPoint, string memberName) + { + return Extensions.Get(extensionPoint, memberName); + } + + public static T Get(this IReflectionExtensionPoint extensionPoint, string memberName) + { + return Extensions.Get(extensionPoint, memberName); + } + + public static object Get(this IReflectionExtensionPoint extensionPoint, IEnumerable memberNames) + { + return Extensions.Get(extensionPoint, memberNames); + } + + public static T Get(this IReflectionExtensionPoint extensionPoint, IEnumerable memberNames) + { + return Extensions.Get(extensionPoint, memberNames); + } + + public static T Get(this IReflectionExtensionPoint extensionPoint, IEnumerable memberNames) + { + return Extensions.Get(extensionPoint, memberNames); + } + + public static object Get(this IReflectionExtensionPoint extensionPoint, + IEnumerable descriptors) + { + return Extensions.Get(extensionPoint, descriptors); + } + + public static T Get(this IReflectionExtensionPoint extensionPoint, + IEnumerable descriptors) + { + return Extensions.Get(extensionPoint, descriptors); + } + + public static T Get(this IReflectionExtensionPoint extensionPoint, + IEnumerable descriptors) + { + return Extensions.Get(extensionPoint, descriptors); + } + + public static void Set(this IReflectionExtensionPoint extensionPoint, string memberName, T value) + { + Extensions.Set(extensionPoint, memberName, value); + } + + public static void Set(this IReflectionExtensionPoint extensionPoint, IEnumerable memberNames, + T value) + { + Extensions.Set(extensionPoint, memberNames, value); + } + + public static void Set(this IReflectionExtensionPoint extensionPoint, IEnumerable memberNames, + T value) + { + Extensions.Set(extensionPoint, memberNames, value); + } + + public static void Set(this IReflectionExtensionPoint extensionPoint, + IEnumerable descriptors, T value) + { + Extensions.Set(extensionPoint, descriptors, value); + } + + public static void Set(this IReflectionExtensionPoint extensionPoint, + IEnumerable descriptors, T value) + { + Extensions.Set(extensionPoint, descriptors, value); + } + + public static IEnumerable GetValueDescriptors( + this IReflectionExtensionPoint extensionPoint, IEnumerable memberNames) + { + return Extensions.GetValueDescriptors(extensionPoint, memberNames); + } + + public static IEnumerable GetDescriptors(this IReflectionExtensionPoint extensionPoint, + IEnumerable memberNames) + { + return Extensions.GetDescriptors(extensionPoint, memberNames); + } + + public static IMemberDescriptor GetDescriptor(this IReflectionExtensionPoint extensionPoint) + { + return Extensions.GetDescriptor(extensionPoint); + } + + public static IMemberDescriptor GetDescriptor(this IMemberDescriptor descriptor, string memberName) + { + return Extensions.GetDescriptor(descriptor, memberName); + } + + public static IMemberDescriptor FindDescriptor(this IMemberDescriptor descriptor, string memberName) + { + return Extensions.FindDescriptor(descriptor, memberName); + } + + public static IValueMemberDescriptor GetValueDescriptor(this IReflectionExtensionPoint extensionPoint, + string memberName) + { + return Extensions.GetValueDescriptor(extensionPoint, memberName); + } + + public static IValueMemberDescriptor FindValueDescriptor(this IReflectionExtensionPoint extensionPoint, + string memberName) + { + return Extensions.FindValueDescriptor(extensionPoint, memberName); + } public static IMemberDescriptor GetDescriptor(this IReflectionExtensionPoint extensionPoint, string memberName) - { - return Extensions.GetDescriptor(extensionPoint, memberName); - } - - public static IMemberDescriptor GetDescriptor(this IReflectionExtensionPoint extensionPoint, Expression> func) - { - return Extensions.GetDescriptor(extensionPoint, func); - } - - public static IMemberDescriptor GetDescriptor(this IReflectionExtensionPoint extensionPoint, Expression> func) - { - return Extensions.GetDescriptor(extensionPoint, func); - } - - public static IMemberDescriptor FindDescriptor(this IReflectionExtensionPoint extensionPoint, string memberName) - { - return Extensions.FindDescriptor(extensionPoint, memberName); - } - - public static IMemberDescriptor FindDescriptor(this IReflectionExtensionPoint extensionPoint, string memberName, - BindingContract contract) - { - return Extensions.FindDescriptor(extensionPoint, memberName, contract); - } - - public static IReflectionExtensionPoint Reflection(this Type type) - { - return Extensions.Reflection(type); - } - - public static IReflectionExtensionPoint Reflection(this T instance) - { - return Extensions.Reflection(instance); - } - - public static IDisposable Observe(this IEventDescriptor descriptor, object publisher, object observer, - string methodName) - { - return Extensions.Observe(descriptor, publisher, observer, methodName); - } - - public static IMemberDescriptor GetDescriptor(this MemberInfo mi) - { - return Extensions.GetDescriptor(mi); - } - } + { + return Extensions.GetDescriptor(extensionPoint, memberName); + } + + public static IMemberDescriptor GetDescriptor(this IReflectionExtensionPoint extensionPoint, Expression> func) + { + return Extensions.GetDescriptor(extensionPoint, func); + } + + public static IMemberDescriptor GetDescriptor(this IReflectionExtensionPoint extensionPoint, Expression> func) + { + return Extensions.GetDescriptor(extensionPoint, func); + } + + public static IMemberDescriptor FindDescriptor(this IReflectionExtensionPoint extensionPoint, string memberName) + { + return Extensions.FindDescriptor(extensionPoint, memberName); + } + + public static IMemberDescriptor FindDescriptor(this IReflectionExtensionPoint extensionPoint, string memberName, + BindingContract contract) + { + return Extensions.FindDescriptor(extensionPoint, memberName, contract); + } + + public static IReflectionExtensionPoint Reflection(this Type type) + { + return Extensions.Reflection(type); + } + + public static IReflectionExtensionPoint Reflection(this T instance) + { + return Extensions.Reflection(instance); + } + + public static IDisposable Observe(this IEventDescriptor descriptor, object publisher, object observer, + string methodName) + { + return Extensions.Observe(descriptor, publisher, observer, methodName); + } + + public static IMemberDescriptor GetDescriptor(this MemberInfo mi) + { + return Extensions.GetDescriptor(mi); + } + } } diff --git a/src/Uno.Core/Reflection/TypeDescriptor.cs b/src/Uno.Core/Reflection/TypeDescriptor.cs index 033e67e..7cedefa 100644 --- a/src/Uno.Core/Reflection/TypeDescriptor.cs +++ b/src/Uno.Core/Reflection/TypeDescriptor.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,55 +14,56 @@ // limitations under the License. // // ****************************************************************** + #if !WINDOWS_UWP using System; namespace Uno.Reflection { - public class TypeDescriptor : MemberDescriptor - { - public TypeDescriptor(Type type) - : base(type) - { - } + public class TypeDescriptor : MemberDescriptor + { + public TypeDescriptor(Type type) + : base(type) + { + } - public override Type Type - { - get { return MemberInfo; } - } + public override Type Type + { + get { return MemberInfo; } + } - public override bool IsStatic - { - get { return MemberInfo.IsAbstract && MemberInfo.IsSealed; } - } + public override bool IsStatic + { + get { return MemberInfo.IsAbstract && MemberInfo.IsSealed; } + } - public override bool IsGeneric - { - get { return MemberInfo.IsGenericType; } - } + public override bool IsGeneric + { + get { return MemberInfo.IsGenericType; } + } - public override bool IsOpen - { - get { return MemberInfo.IsGenericTypeDefinition; } - } + public override bool IsOpen + { + get { return MemberInfo.IsGenericTypeDefinition; } + } - public override IMemberDescriptor Open() - { - return IsClosed ? new TypeDescriptor(MemberInfo.GetGenericTypeDefinition()) : base.Open(); - } + public override IMemberDescriptor Open() + { + return IsClosed ? new TypeDescriptor(MemberInfo.GetGenericTypeDefinition()) : base.Open(); + } - // TODO: params are ignored - public override IMemberDescriptor Close(params Type[] types) - { - if (!IsOpen) - { - return base.Close(types); - } - - var closedType = MemberInfo.MakeGenericType(types); + // TODO: params are ignored + public override IMemberDescriptor Close(params Type[] types) + { + if (!IsOpen) + { + return base.Close(types); + } + + var closedType = MemberInfo.MakeGenericType(types); - return new TypeDescriptor(closedType); - } - } + return new TypeDescriptor(closedType); + } + } } -#endif \ No newline at end of file +#endif diff --git a/src/Uno.Core/Reflection/TypeExtensions.cs b/src/Uno.Core/Reflection/TypeExtensions.cs index 8f2dbf4..ed4bf9a 100644 --- a/src/Uno.Core/Reflection/TypeExtensions.cs +++ b/src/Uno.Core/Reflection/TypeExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -24,39 +25,39 @@ namespace Uno.Extensions { - public static class TypeExtensions - { - public static object New(this Type type, params object[] args) - { - return Activator.CreateInstance(type, args); - } - - public static T New(this Type type, params object[] args) - { - return (T)New(type, args); - } - - public static bool Is(this Type type) - { - return type.Is(typeof(T)); - } - - public static bool Is(this Type instance, Type type) - { - return type.IsAssignableFrom(instance); - } - - public static MemberInfo GetMemberInfo(this Type type, string memberName) - { - return GetMemberInfo(type, memberName, BindingContract.Default); - } - - public static MemberInfo GetMemberInfo(this Type type, string memberName, BindingContract contract) - { - var mi = FindMemberInfo(type, memberName, contract); - - return mi.Validation().Found(); - } + public static class TypeExtensions + { + public static object New(this Type type, params object[] args) + { + return Activator.CreateInstance(type, args); + } + + public static T New(this Type type, params object[] args) + { + return (T)New(type, args); + } + + public static bool Is(this Type type) + { + return type.Is(typeof(T)); + } + + public static bool Is(this Type instance, Type type) + { + return type.IsAssignableFrom(instance); + } + + public static MemberInfo GetMemberInfo(this Type type, string memberName) + { + return GetMemberInfo(type, memberName, BindingContract.Default); + } + + public static MemberInfo GetMemberInfo(this Type type, string memberName, BindingContract contract) + { + var mi = FindMemberInfo(type, memberName, contract); + + return mi.Validation().Found(); + } #if HAS_NO_TYPEINFO public static Type GetTypeInfo(this Type type) @@ -73,10 +74,10 @@ public static IEnumerable GetConstructors(this TypeInfo type) #endif #if !WINDOWS_UWP - public static MemberInfo FindMemberInfo(this Type type, string memberName) - { - return FindMemberInfo(type, memberName, BindingContract.Default); - } + public static MemberInfo FindMemberInfo(this Type type, string memberName) + { + return FindMemberInfo(type, memberName, BindingContract.Default); + } #endif #if WINDOWS_UWP @@ -85,112 +86,112 @@ public static Assembly GetAssembly(this Type type) return type.GetTypeInfo().Assembly; } #else - public static Assembly GetAssembly(this Type type) - { - return type.Assembly; - } + public static Assembly GetAssembly(this Type type) + { + return type.Assembly; + } #endif - public static MemberInfo FindMemberInfo(this Type type, string memberName, BindingContract contract) - { - var mi = FindInheritedMember(type, memberName, contract); - - if (mi == null && - contract.Behavior.ContainsAll(BindingBehavior.Interface)) - { - foreach (var interfaceType in type.GetInterfaces()) - { - mi = FindInheritedMember(interfaceType, memberName, contract); - - if (mi != null) - { - break; - } - } - } - - return mi; - } - - public static MemberInfo FindInheritedMember(Type type, string memberName, BindingContract contract) - { - MemberInfo mi = null; - - while (type != null) - { - mi = FindMember(type, memberName, contract); - - if (mi != null || - !contract.Behavior.ContainsAll(BindingBehavior.Inherited)) - { - break; - } + public static MemberInfo FindMemberInfo(this Type type, string memberName, BindingContract contract) + { + var mi = FindInheritedMember(type, memberName, contract); + + if (mi == null && + contract.Behavior.ContainsAll(BindingBehavior.Interface)) + { + foreach (var interfaceType in type.GetInterfaces()) + { + mi = FindInheritedMember(interfaceType, memberName, contract); + + if (mi != null) + { + break; + } + } + } + + return mi; + } + + public static MemberInfo FindInheritedMember(Type type, string memberName, BindingContract contract) + { + MemberInfo mi = null; + + while (type != null) + { + mi = FindMember(type, memberName, contract); + + if (mi != null || + !contract.Behavior.ContainsAll(BindingBehavior.Inherited)) + { + break; + } #if !WINDOWS_UWP && !HAS_CRIPPLEDREFLECTION - type = type.BaseType; + type = type.BaseType; #else type = type.GetTypeInfo().BaseType; #endif - } + } - return mi; - } + return mi; + } - public static MemberInfo FindMember(Type type, string memberName, BindingContract contract) - { - MemberInfo memberInfo; + public static MemberInfo FindMember(Type type, string memberName, BindingContract contract) + { + MemberInfo memberInfo; - if (contract.MemberType.ContainsAll(MemberTypes.Property)) - { + if (contract.MemberType.ContainsAll(MemberTypes.Property)) + { #if !WINDOWS_UWP && !HAS_CRIPPLEDREFLECTION - memberInfo = type.GetProperty(memberName, contract.BindingFlags, null, contract.ReturnType, - contract.SafeTypes, null); + memberInfo = type.GetProperty(memberName, contract.BindingFlags, null, contract.ReturnType, + contract.SafeTypes, null); #elif HAS_CRIPPLEDREFLECTION && !HAS_TYPEINFO memberInfo = type.GetProperty(memberName, contract.ReturnType, contract.SafeTypes); #else memberInfo = type.GetTypeInfo().GetDeclaredProperty(memberName); #endif - if (memberInfo != null) - { - return memberInfo; - } - } + if (memberInfo != null) + { + return memberInfo; + } + } - if (contract.MemberType.ContainsAll(MemberTypes.Event)) - { + if (contract.MemberType.ContainsAll(MemberTypes.Event)) + { #if !WINDOWS_UWP && !HAS_CRIPPLEDREFLECTION - memberInfo = type.GetEvent(memberName, contract.BindingFlags); + memberInfo = type.GetEvent(memberName, contract.BindingFlags); #else memberInfo = type.GetTypeInfo().GetDeclaredEvent(memberName); #endif - if (memberInfo != null) - { - return memberInfo; - } - } + if (memberInfo != null) + { + return memberInfo; + } + } - if (contract.MemberType.ContainsAll(MemberTypes.Field)) - { + if (contract.MemberType.ContainsAll(MemberTypes.Field)) + { #if !WINDOWS_UWP && !HAS_CRIPPLEDREFLECTION - memberInfo = type.GetField(memberName, contract.BindingFlags); + memberInfo = type.GetField(memberName, contract.BindingFlags); #else memberInfo = type.GetTypeInfo().GetDeclaredField(memberName); #endif - if (memberInfo != null) - { - return memberInfo; - } - } + if (memberInfo != null) + { + return memberInfo; + } + } - if (contract.MemberType.ContainsAll(MemberTypes.Method)) - { + if (contract.MemberType.ContainsAll(MemberTypes.Method)) + { #if !WINDOWS_UWP && !HAS_CRIPPLEDREFLECTION - memberInfo = contract.Types == null - ? type.GetMethod(memberName, contract.BindingFlags) - : type.GetMethod(memberName, contract.BindingFlags, null, contract.Types, null); + memberInfo = contract.Types == null + ? type.GetMethod(memberName, contract.BindingFlags) + : type.GetMethod(memberName, contract.BindingFlags, null, contract.Types, null); #elif HAS_CRIPPLEDREFLECTION && !HAS_TYPEINFO memberInfo = contract.Types == null ? type.GetMethod(memberName, contract.BindingFlags) @@ -204,152 +205,152 @@ public static MemberInfo FindMember(Type type, string memberName, BindingContrac ); #endif - if (memberInfo != null) - { - return memberInfo; - } - } + if (memberInfo != null) + { + return memberInfo; + } + } - if (contract.MemberType.ContainsAll(MemberTypes.NestedType)) - { + if (contract.MemberType.ContainsAll(MemberTypes.NestedType)) + { #if !WINDOWS_UWP - memberInfo = type.GetNestedType(memberName, contract.BindingFlags); + memberInfo = type.GetNestedType(memberName, contract.BindingFlags); #else memberInfo = type.GetTypeInfo().GetDeclaredNestedType(memberName); #endif - if (memberInfo != null) - { - return memberInfo; - } - } - - return null; - } - - /// - /// Recursively get all interfaces of a type - /// - public static IEnumerable GetAllInterfaces(this Type type) - { - foreach (var iface in type.GetInterfaces()) - { - yield return iface; - - foreach (var subInterfaces in iface.GetAllInterfaces()) - { - yield return subInterfaces; - } - } - } - - public static TAttribute FindAttribute(this Type type) - where TAttribute : Attribute - { - return type.GetCustomAttributes(typeof(TAttribute), true).FirstOrDefault() as TAttribute; - } + if (memberInfo != null) + { + return memberInfo; + } + } + + return null; + } + + /// + /// Recursively get all interfaces of a type + /// + public static IEnumerable GetAllInterfaces(this Type type) + { + foreach (var iface in type.GetInterfaces()) + { + yield return iface; + + foreach (var subInterfaces in iface.GetAllInterfaces()) + { + yield return subInterfaces; + } + } + } + + public static TAttribute FindAttribute(this Type type) + where TAttribute : Attribute + { + return type.GetCustomAttributes(typeof(TAttribute), true).FirstOrDefault() as TAttribute; + } /// /// Gets the inheritance hierarchy of supplied type. /// - public static IEnumerable GetBaseTypes(this Type type) - { - var previousType = type; - while (true) - { + public static IEnumerable GetBaseTypes(this Type type) + { + var previousType = type; + while (true) + { #if !WINDOWS_UWP - var baseType = previousType.BaseType; + var baseType = previousType.BaseType; #else var baseType = previousType.GetTypeInfo().BaseType; #endif - if (baseType == null || baseType.FullName == previousType.FullName) - { - yield break; - } - else - { - yield return baseType; - previousType = baseType; - } - } - } + if (baseType == null || baseType.FullName == previousType.FullName) + { + yield break; + } + else + { + yield return baseType; + previousType = baseType; + } + } + } #if !WINDOWS_UWP - /// - /// Determine if implements IEnumerable<T>. - /// - /// The type of ITEM or null if is not IEnumerable - public static Type EnumerableOf(this Type type) - { - if (type.IsArray) - { - return type.GetElementType(); - } - - if (type.IsInterface && type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IEnumerable<>)) - { - return type.GetGenericArguments().First(); - } - - return type.GetAllInterfaces().FirstOrDefault(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IEnumerable<>)).SelectOrDefault(i => i.GetGenericArguments().First()); - } + /// + /// Determine if implements IEnumerable<T>. + /// + /// The type of ITEM or null if is not IEnumerable + public static Type EnumerableOf(this Type type) + { + if (type.IsArray) + { + return type.GetElementType(); + } + + if (type.IsInterface && type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IEnumerable<>)) + { + return type.GetGenericArguments().First(); + } + + return type.GetAllInterfaces().FirstOrDefault(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IEnumerable<>)).SelectOrDefault(i => i.GetGenericArguments().First()); + } #endif #if !HAS_NO_TYPEINFO - /// - /// Gets the declared property by searching the flattened hierarchy. - /// - /// The type to search into - /// The name of the declared property - /// The property info if found, otherwise null. - public static PropertyInfo GetFlattenedDeclaredProperty(this Type type, string name) - { - return type - .GetTypeInfo() - .Flatten(t => t.BaseType != typeof(object) ? t.BaseType.GetTypeInfo() : null) - .Select(t => t.GetDeclaredProperty(name)) - .FirstOrDefault(t => t != null); - } - - /// - /// Gets the declared field by searching the flattened hierarchy. - /// - /// The type to search into - /// The name of the declared field - /// The field info if found, otherwise null. - public static FieldInfo GetFlattenedDeclaredField(this Type type, string name) - { - return type - .GetTypeInfo() - .Flatten(t => t.BaseType != typeof(object) ? t.BaseType.GetTypeInfo() : null) - .Select(t => t.GetDeclaredField(name)) - .FirstOrDefault(t => t != null); - } + /// + /// Gets the declared property by searching the flattened hierarchy. + /// + /// The type to search into + /// The name of the declared property + /// The property info if found, otherwise null. + public static PropertyInfo GetFlattenedDeclaredProperty(this Type type, string name) + { + return type + .GetTypeInfo() + .Flatten(t => t.BaseType != typeof(object) ? t.BaseType.GetTypeInfo() : null) + .Select(t => t.GetDeclaredProperty(name)) + .FirstOrDefault(t => t != null); + } + + /// + /// Gets the declared field by searching the flattened hierarchy. + /// + /// The type to search into + /// The name of the declared field + /// The field info if found, otherwise null. + public static FieldInfo GetFlattenedDeclaredField(this Type type, string name) + { + return type + .GetTypeInfo() + .Flatten(t => t.BaseType != typeof(object) ? t.BaseType.GetTypeInfo() : null) + .Select(t => t.GetDeclaredField(name)) + .FirstOrDefault(t => t != null); + } #endif #if !WINDOWS_UWP - private static Func _isNullable = Funcs.Create((Type t) => IsNullable(t)).AsLockedMemoized(); - - /// - /// Returns a cached result of the the IsNullable method, as it works - /// in O(n) where n is the depth of the hierarchy. - /// - public static bool IsNullableCached(this Type type) - { - return _isNullable(type); - } - - /// - /// Gets whether null can be assigned to a variable of the given - /// - /// The type on which to test nullability - /// - public static bool IsNullable(this Type type) - { - return - !type.GetTypeInfo().IsValueType // is reference type - || Nullable.GetUnderlyingType(type) != null; // is Nullable - } + private static Func _isNullable = Funcs.Create((Type t) => IsNullable(t)).AsLockedMemoized(); + + /// + /// Returns a cached result of the the IsNullable method, as it works + /// in O(n) where n is the depth of the hierarchy. + /// + public static bool IsNullableCached(this Type type) + { + return _isNullable(type); + } + + /// + /// Gets whether null can be assigned to a variable of the given + /// + /// The type on which to test nullability + /// + public static bool IsNullable(this Type type) + { + return + !type.GetTypeInfo().IsValueType // is reference type + || Nullable.GetUnderlyingType(type) != null; // is Nullable + } #endif - } + } } diff --git a/src/Uno.Core/Reflection/TypeInfoExtensions.Metro.cs b/src/Uno.Core/Reflection/TypeInfoExtensions.Metro.cs index 0519720..2c4cc08 100644 --- a/src/Uno.Core/Reflection/TypeInfoExtensions.Metro.cs +++ b/src/Uno.Core/Reflection/TypeInfoExtensions.Metro.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -25,95 +26,95 @@ namespace Uno.Extensions { #if HAS_TYPEINFO || WINDOWS_UWP - public static class TypeInfoExtensions - { + public static class TypeInfoExtensions + { #if !HAS_TYPEINFO_EXTENSIONS - public static MemberInfo FindMemberInfo(this Type type, string memberName) - { + public static MemberInfo FindMemberInfo(this Type type, string memberName) + { return type.GetTypeInfo().DeclaredMembers.FirstOrDefault(m => m.Name == memberName); - } + } public static bool IsAssignableFrom(this Type type, Type memberName) - { - return type.GetTypeInfo().IsAssignableFrom(memberName.GetTypeInfo()); - } + { + return type.GetTypeInfo().IsAssignableFrom(memberName.GetTypeInfo()); + } #endif - public static IEnumerable GetCustomAttributes(this Type type, Type attributeType, bool includeInherited) - { - return CustomAttributeExtensions.GetCustomAttributes(type.GetTypeInfo(), attributeType, includeInherited); - } + public static IEnumerable GetCustomAttributes(this Type type, Type attributeType, bool includeInherited) + { + return CustomAttributeExtensions.GetCustomAttributes(type.GetTypeInfo(), attributeType, includeInherited); + } #if !HAS_TYPEINFO_EXTENSIONS public static IEnumerable GetInterfaces(this Type type) - { - return type.GetTypeInfo().ImplementedInterfaces; - } + { + return type.GetTypeInfo().ImplementedInterfaces; + } - public static PropertyInfo GetProperty(this Type type, string name) - { - return type.GetTypeInfo().GetDeclaredProperty(name); - } + public static PropertyInfo GetProperty(this Type type, string name) + { + return type.GetTypeInfo().GetDeclaredProperty(name); + } - public static FieldInfo GetField(this Type type, string name) - { - return type.GetTypeInfo().GetDeclaredField(name); - } + public static FieldInfo GetField(this Type type, string name) + { + return type.GetTypeInfo().GetDeclaredField(name); + } - public static IEnumerable GetFields(this Type type) - { - return type.GetTypeInfo().DeclaredFields; - } + public static IEnumerable GetFields(this Type type) + { + return type.GetTypeInfo().DeclaredFields; + } - public static ConstructorInfo GetConstructor(this Type t, Type[] parameters) - { - return t.GetTypeInfo() - .DeclaredConstructors - .FirstOrDefault( - c => c.GetParameters() - .Select(p => p.ParameterType) - .Equality() - .Equal(parameters) - ); - } + public static ConstructorInfo GetConstructor(this Type t, Type[] parameters) + { + return t.GetTypeInfo() + .DeclaredConstructors + .FirstOrDefault( + c => c.GetParameters() + .Select(p => p.ParameterType) + .Equality() + .Equal(parameters) + ); + } - public static MethodInfo GetAddMethod(this EventInfo info, bool throws = true) - { - return info.AddMethod; - } + public static MethodInfo GetAddMethod(this EventInfo info, bool throws = true) + { + return info.AddMethod; + } - public static MethodInfo GetRemoveMethod(this EventInfo info, bool throws = true) - { - return info.RemoveMethod; - } + public static MethodInfo GetRemoveMethod(this EventInfo info, bool throws = true) + { + return info.RemoveMethod; + } - public static MethodInfo GetGetMethod(this PropertyInfo info, bool throws = true) - { - return info.GetMethod; - } + public static MethodInfo GetGetMethod(this PropertyInfo info, bool throws = true) + { + return info.GetMethod; + } - public static MethodInfo GetSetMethod(this PropertyInfo info, bool throws = true) - { - return info.SetMethod; - } + public static MethodInfo GetSetMethod(this PropertyInfo info, bool throws = true) + { + return info.SetMethod; + } #endif public static CustomAttributeData[] GetCustomAttributesData(this FieldInfo info) - { - return info.CustomAttributes.ToArray(); - } + { + return info.CustomAttributes.ToArray(); + } #if !HAS_TYPEINFO_EXTENSIONS - public static Type[] GetGenericArguments(this Type type) - { - return type.GetTypeInfo().GenericTypeArguments; - } + public static Type[] GetGenericArguments(this Type type) + { + return type.GetTypeInfo().GenericTypeArguments; + } - public static MethodInfo GetMethod(this Type type, string name) - { - return type.GetTypeInfo().GetDeclaredMethod(name); - } + public static MethodInfo GetMethod(this Type type, string name) + { + return type.GetTypeInfo().GetDeclaredMethod(name); + } #endif - } + } #endif } diff --git a/src/Uno.Core/Reflection/ValueMemberDescriptor.cs b/src/Uno.Core/Reflection/ValueMemberDescriptor.cs index 1ba33d2..65af5dd 100644 --- a/src/Uno.Core/Reflection/ValueMemberDescriptor.cs +++ b/src/Uno.Core/Reflection/ValueMemberDescriptor.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,51 +14,52 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Reflection; namespace Uno.Reflection { - public abstract class ValueMemberDescriptor : MemberDescriptor, IValueMemberDescriptor - where TMemberInfo : MemberInfo - { - public ValueMemberDescriptor(TMemberInfo memberInfo) - : base(memberInfo) - { - } + public abstract class ValueMemberDescriptor : MemberDescriptor, IValueMemberDescriptor + where TMemberInfo : MemberInfo + { + public ValueMemberDescriptor(TMemberInfo memberInfo) + : base(memberInfo) + { + } - #region IValueMemberDescriptor Members + #region IValueMemberDescriptor Members - public virtual object GetValue(object instance) - { - throw new NotImplementedException(); - } + public virtual object GetValue(object instance) + { + throw new NotImplementedException(); + } - public virtual void SetValue(object instance, object value) - { - throw new NotImplementedException(); - } + public virtual void SetValue(object instance, object value) + { + throw new NotImplementedException(); + } - public virtual Action ToCompiledSetValue() - { - throw new NotImplementedException(); - } + public virtual Action ToCompiledSetValue() + { + throw new NotImplementedException(); + } - public virtual Action ToCompiledSetValue(bool strict) - { - throw new NotImplementedException(); - } + public virtual Action ToCompiledSetValue(bool strict) + { + throw new NotImplementedException(); + } - public virtual Func ToCompiledGetValue() - { - throw new NotImplementedException(); - } + public virtual Func ToCompiledGetValue() + { + throw new NotImplementedException(); + } - public virtual Func ToCompiledGetValue(bool strict) - { - throw new NotImplementedException(); - } + public virtual Func ToCompiledGetValue(bool strict) + { + throw new NotImplementedException(); + } - #endregion - } -} \ No newline at end of file + #endregion + } +} diff --git a/src/Uno.Core/RegularExpressions/MatchExtensions.cs b/src/Uno.Core/RegularExpressions/MatchExtensions.cs index de72b1f..d6c08c5 100644 --- a/src/Uno.Core/RegularExpressions/MatchExtensions.cs +++ b/src/Uno.Core/RegularExpressions/MatchExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -22,24 +23,24 @@ namespace Uno.Extensions { - /// - /// Provide extentions for the System.Text.RegularExpressions.Match class - /// - public static class MatchExtensions - { - /// - /// Converts a Regular Expression Match instance to an enumerable of Regular Expression Match instances - /// - /// A Regular Expression Match instance - /// An enumerable of matches - public static IEnumerable AsEnumerable(this Match match) - { - while (match.Success) - { - yield return match; + /// + /// Provide extentions for the System.Text.RegularExpressions.Match class + /// + public static class MatchExtensions + { + /// + /// Converts a Regular Expression Match instance to an enumerable of Regular Expression Match instances + /// + /// A Regular Expression Match instance + /// An enumerable of matches + public static IEnumerable AsEnumerable(this Match match) + { + while (match.Success) + { + yield return match; - match = match.NextMatch(); - } - } - } + match = match.NextMatch(); + } + } + } } diff --git a/src/Uno.Core/Resources/EmbeddedResourceFactory.cs b/src/Uno.Core/Resources/EmbeddedResourceFactory.cs index 7c98773..0b445c6 100644 --- a/src/Uno.Core/Resources/EmbeddedResourceFactory.cs +++ b/src/Uno.Core/Resources/EmbeddedResourceFactory.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System.IO; using System.Reflection; diff --git a/src/Uno.Core/Runtime.cs b/src/Uno.Core/Runtime.cs index 2cccd86..63fcb0b 100644 --- a/src/Uno.Core/Runtime.cs +++ b/src/Uno.Core/Runtime.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.IO; diff --git a/src/Uno.Core/Serialization/SerializationExtensionPoint.cs b/src/Uno.Core/Serialization/SerializationExtensionPoint.cs index 9a7bdb7..79e1266 100644 --- a/src/Uno.Core/Serialization/SerializationExtensionPoint.cs +++ b/src/Uno.Core/Serialization/SerializationExtensionPoint.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,21 +14,22 @@ // limitations under the License. // // ****************************************************************** + using System; using Uno.Extensions; namespace Uno.Serialization { - public class SerializationExtensionPoint : ExtensionPoint - { - public SerializationExtensionPoint(T value) - : base(value) - { - } + public class SerializationExtensionPoint : ExtensionPoint + { + public SerializationExtensionPoint(T value) + : base(value) + { + } - public SerializationExtensionPoint(Type type) - : base(type) - { - } - } -} \ No newline at end of file + public SerializationExtensionPoint(Type type) + : base(type) + { + } + } +} diff --git a/src/Uno.Core/Serialization/SerializationExtensions.cs b/src/Uno.Core/Serialization/SerializationExtensions.cs index e10dd19..602fd73 100644 --- a/src/Uno.Core/Serialization/SerializationExtensions.cs +++ b/src/Uno.Core/Serialization/SerializationExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.IO; using System.Runtime.Serialization; @@ -25,112 +26,112 @@ namespace Uno.Extensions { - public static class SerializationExtensions - { - public static SerializationExtensionPoint Serialization(this T value) - { - return new SerializationExtensionPoint(value); - } + public static class SerializationExtensions + { + public static SerializationExtensionPoint Serialization(this T value) + { + return new SerializationExtensionPoint(value); + } - public static SerializationExtensionPoint Serialization(this Type type) - { - return new SerializationExtensionPoint(type); - } + public static SerializationExtensionPoint Serialization(this Type type) + { + return new SerializationExtensionPoint(type); + } - public static T DataContract(this SerializationExtensionPoint extensionPoint) - { - var serializer = new DataContractSerializer(extensionPoint.ExtendedType); + public static T DataContract(this SerializationExtensionPoint extensionPoint) + { + var serializer = new DataContractSerializer(extensionPoint.ExtendedType); - using (var stream = new MemoryStream()) - { - serializer.WriteObject(stream, extensionPoint.ExtendedValue); + using (var stream = new MemoryStream()) + { + serializer.WriteObject(stream, extensionPoint.ExtendedValue); - stream.Position = 0; + stream.Position = 0; - var newInstance = (T) serializer.ReadObject(stream); + var newInstance = (T) serializer.ReadObject(stream); - return newInstance; - } - } + return newInstance; + } + } #if !SILVERLIGHT && !WINDOWS_UWP && !XAMARIN - public static T Binary(this SerializationExtensionPoint extensionPoint) - { - var serializer = new BinaryFormatter(); - - using (var stream = new MemoryStream()) - { - serializer.Serialize(stream, extensionPoint.ExtendedValue); - - stream.Position = 0; - - var newInstance = (T) serializer.Deserialize(stream); - - return newInstance; - } - } - - public static void Binary(this SerializationExtensionPoint extensionPoint, Stream output) - { - if (extensionPoint.ExtendedValue != null) - { - var serializer = new BinaryFormatter(); - serializer.Serialize(output, extensionPoint.ExtendedValue); - output.Flush(); - } - } - - public static T Binary(this SerializationExtensionPoint extensionPoint, byte[] data) - { - var serializer = new BinaryFormatter(); - using (var stream = new MemoryStream(data)) - { - return (T)serializer.Deserialize(stream); - } - } + public static T Binary(this SerializationExtensionPoint extensionPoint) + { + var serializer = new BinaryFormatter(); + + using (var stream = new MemoryStream()) + { + serializer.Serialize(stream, extensionPoint.ExtendedValue); + + stream.Position = 0; + + var newInstance = (T) serializer.Deserialize(stream); + + return newInstance; + } + } + + public static void Binary(this SerializationExtensionPoint extensionPoint, Stream output) + { + if (extensionPoint.ExtendedValue != null) + { + var serializer = new BinaryFormatter(); + serializer.Serialize(output, extensionPoint.ExtendedValue); + output.Flush(); + } + } + + public static T Binary(this SerializationExtensionPoint extensionPoint, byte[] data) + { + var serializer = new BinaryFormatter(); + using (var stream = new MemoryStream(data)) + { + return (T)serializer.Deserialize(stream); + } + } #endif - public static T Xml(this SerializationExtensionPoint extensionPoint) - { - using (var stream = new MemoryStream()) - { - Xml(extensionPoint, stream, extensionPoint.ExtendedValue); + public static T Xml(this SerializationExtensionPoint extensionPoint) + { + using (var stream = new MemoryStream()) + { + Xml(extensionPoint, stream, extensionPoint.ExtendedValue); - stream.Position = 0; + stream.Position = 0; - return Xml(extensionPoint, stream); - } - } + return Xml(extensionPoint, stream); + } + } #if !WINDOWS_UWP && !XAMARIN - public static T Xml(this SerializationExtensionPoint extensionPoint, string path) - { - using (var stream = File.OpenRead(path)) - { - return Xml(extensionPoint, stream); - } - } - - public static void Xml(this SerializationExtensionPoint extensionPoint, string path, T value) - { - using (var stream = File.OpenWrite(path)) - { - Xml(extensionPoint, stream, value); - } - } + public static T Xml(this SerializationExtensionPoint extensionPoint, string path) + { + using (var stream = File.OpenRead(path)) + { + return Xml(extensionPoint, stream); + } + } + + public static void Xml(this SerializationExtensionPoint extensionPoint, string path, T value) + { + using (var stream = File.OpenWrite(path)) + { + Xml(extensionPoint, stream, value); + } + } #endif - public static T Xml(this SerializationExtensionPoint extensionPoint, Stream stream) - { - var serializer = new XmlSerializer(extensionPoint.ExtendedType); + public static T Xml(this SerializationExtensionPoint extensionPoint, Stream stream) + { + var serializer = new XmlSerializer(extensionPoint.ExtendedType); - return (T) serializer.Deserialize(stream); - } + return (T) serializer.Deserialize(stream); + } - public static void Xml(this SerializationExtensionPoint extensionPoint, Stream stream, T value) - { - var serializer = new XmlSerializer(extensionPoint.ExtendedType); + public static void Xml(this SerializationExtensionPoint extensionPoint, Stream stream, T value) + { + var serializer = new XmlSerializer(extensionPoint.ExtendedType); - serializer.Serialize(stream, value); - } - } -} \ No newline at end of file + serializer.Serialize(stream, value); + } + } +} diff --git a/src/Uno.Core/ServiceLocatorProviderExtensions.cs b/src/Uno.Core/ServiceLocatorProviderExtensions.cs index f23b44a..3f83984 100644 --- a/src/Uno.Core/ServiceLocatorProviderExtensions.cs +++ b/src/Uno.Core/ServiceLocatorProviderExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; @@ -22,13 +23,13 @@ namespace Uno.Extensions { - public static class ServiceLocatorProviderExtensions - { - public static IServiceLocator ServiceLocation(this object instance) - { - var provider = instance as IServiceLocatorProvider; + public static class ServiceLocatorProviderExtensions + { + public static IServiceLocator ServiceLocation(this object instance) + { + var provider = instance as IServiceLocatorProvider; - return provider == null ? null : provider.ServiceLocator; - } - } + return provider == null ? null : provider.ServiceLocator; + } + } } diff --git a/src/Uno.Core/Threading/AsyncEvent.cs b/src/Uno.Core/Threading/AsyncEvent.cs index 42bc7e2..1e3289f 100644 --- a/src/Uno.Core/Threading/AsyncEvent.cs +++ b/src/Uno.Core/Threading/AsyncEvent.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Concurrent; using System.Collections.Generic; diff --git a/src/Uno.Core/Threading/AsyncLock.cs b/src/Uno.Core/Threading/AsyncLock.cs index bf74c20..0bb61e0 100644 --- a/src/Uno.Core/Threading/AsyncLock.cs +++ b/src/Uno.Core/Threading/AsyncLock.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Threading; using System.Threading.Tasks; @@ -22,23 +23,23 @@ namespace Uno.Threading { - /// - /// An asynchronous lock, that can be used in conjuction with C# async/await - /// - public sealed class AsyncLock - { - private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1); + /// + /// An asynchronous lock, that can be used in conjuction with C# async/await + /// + public sealed class AsyncLock + { + private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1); - /// - /// Acquires the lock, then provides a disposable to release it. - /// - /// A cancellation token to cancel the lock - /// An IDisposable instance that allows the release of the lock. - public async Task LockAsync(CancellationToken ct) - { - await _semaphore.WaitAsync(ct); + /// + /// Acquires the lock, then provides a disposable to release it. + /// + /// A cancellation token to cancel the lock + /// An IDisposable instance that allows the release of the lock. + public async Task LockAsync(CancellationToken ct) + { + await _semaphore.WaitAsync(ct); - return Disposable.Create(() => _semaphore.Release()); - } - } + return Disposable.Create(() => _semaphore.Release()); + } + } } diff --git a/src/Uno.Core/Threading/FastAsyncLock.cs b/src/Uno.Core/Threading/FastAsyncLock.cs index 2ffaa6d..89e44b5 100644 --- a/src/Uno.Core/Threading/FastAsyncLock.cs +++ b/src/Uno.Core/Threading/FastAsyncLock.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Diagnostics; using System.Linq; @@ -238,4 +239,4 @@ public void Dispose() } } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Threading/FastTaskCompletionSource.cs b/src/Uno.Core/Threading/FastTaskCompletionSource.cs index 776477b..48139f0 100644 --- a/src/Uno.Core/Threading/FastTaskCompletionSource.cs +++ b/src/Uno.Core/Threading/FastTaskCompletionSource.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Runtime.CompilerServices; using System.Runtime.ExceptionServices; @@ -367,4 +368,4 @@ private async Task CreateAsyncTask() return await this; } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Threading/ISynchronizable.Generic.cs b/src/Uno.Core/Threading/ISynchronizable.Generic.cs index 785782e..c4473ba 100644 --- a/src/Uno.Core/Threading/ISynchronizable.Generic.cs +++ b/src/Uno.Core/Threading/ISynchronizable.Generic.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,10 +14,11 @@ // limitations under the License. // // ****************************************************************** + namespace Uno.Threading { - public interface ISynchronizable - { - ISynchronizableLock Lock { get; } - } -} \ No newline at end of file + public interface ISynchronizable + { + ISynchronizableLock Lock { get; } + } +} diff --git a/src/Uno.Core/Threading/ISynchronizableLock.cs b/src/Uno.Core/Threading/ISynchronizableLock.cs index b9ca5d8..a9a945e 100644 --- a/src/Uno.Core/Threading/ISynchronizableLock.cs +++ b/src/Uno.Core/Threading/ISynchronizableLock.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,15 +14,16 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno.Threading { - public interface ISynchronizableLock - { - TValue Read(int millisecondsTimeout, Func read); + public interface ISynchronizableLock + { + TValue Read(int millisecondsTimeout, Func read); - TValue Write(int millisecondsTimeout, Func write); + TValue Write(int millisecondsTimeout, Func write); /// /// Performs a write operation if the read operation return false. @@ -31,10 +32,10 @@ public interface ISynchronizableLock /// A lambda that will test if the data can be read /// A lambda that will perform the write if the read failed /// true if the read succeeded, otherwise false. - bool Write(int millisecondsTimeout, Func read, Action write); + bool Write(int millisecondsTimeout, Func read, Action write); - IDisposable CreateReaderScope(int millisecondsTimeout); + IDisposable CreateReaderScope(int millisecondsTimeout); - IDisposable CreateWriterScope(int millisecondsTimeout); - } -} \ No newline at end of file + IDisposable CreateWriterScope(int millisecondsTimeout); + } +} diff --git a/src/Uno.Core/Threading/Synchronizable.cs b/src/Uno.Core/Threading/Synchronizable.cs index 108a0a0..7423aba 100644 --- a/src/Uno.Core/Threading/Synchronizable.cs +++ b/src/Uno.Core/Threading/Synchronizable.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,12 +14,13 @@ // limitations under the License. // // ****************************************************************** + using System; namespace Uno.Threading { - public class Synchronizable : ISynchronizable - { + public class Synchronizable : ISynchronizable + { #if WINDOWS_PHONE // Prior to WP 8.0.10322 (GDR2), ReaderWriterLockSlim had a severe bug. Falling back to a standard lock @@ -27,10 +28,10 @@ public class Synchronizable : ISynchronizable private readonly static bool UseExclusiveLock = Environment.OSVersion.Version < new Version(8, 0, 10322); #endif - private readonly ISynchronizableLock syncLock; + private readonly ISynchronizableLock syncLock; - public Synchronizable(T instance) - { + public Synchronizable(T instance) + { #if XAMARIN // RWLockSlim on mono (3.2 as of writing) seems to be time consuming, particularly when performing unusually long SpinLocks. // Until this is resolved, revert to standard locking. @@ -47,15 +48,15 @@ public Synchronizable(T instance) syncLock = new SynchronizableLock(instance); } #endif // XAMARIN - } + } - #region ISynchronizable Members + #region ISynchronizable Members - public ISynchronizableLock Lock - { - get { return syncLock; } - } + public ISynchronizableLock Lock + { + get { return syncLock; } + } - #endregion - } + #endregion + } } diff --git a/src/Uno.Core/Threading/SynchronizableExtensions.cs b/src/Uno.Core/Threading/SynchronizableExtensions.cs index b9b6769..71faf95 100644 --- a/src/Uno.Core/Threading/SynchronizableExtensions.cs +++ b/src/Uno.Core/Threading/SynchronizableExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,40 +14,41 @@ // limitations under the License. // // ****************************************************************** + using System; using Uno.Threading; namespace Uno.Extensions { - public static class SynchronizableExtensions - { - public static void Read(this ISynchronizableLock sync, Action read) - { - Read(sync, item => - { - read(item); - return null; - }); - } + public static class SynchronizableExtensions + { + public static void Read(this ISynchronizableLock sync, Action read) + { + Read(sync, item => + { + read(item); + return null; + }); + } - public static void Write(this ISynchronizableLock sync, Action write) - { - Write(sync, item => - { - write(item); - return null; - }); - } + public static void Write(this ISynchronizableLock sync, Action write) + { + Write(sync, item => + { + write(item); + return null; + }); + } - public static TValue Write(this ISynchronizableLock sync, Func write) - { - return sync.Write(-1, write); - } + public static TValue Write(this ISynchronizableLock sync, Func write) + { + return sync.Write(-1, write); + } - public static TValue Read(this ISynchronizableLock sync, Func read) - { - return sync.Read(-1, read); - } + public static TValue Read(this ISynchronizableLock sync, Func read) + { + return sync.Read(-1, read); + } /// /// Performs a write operation if the read operation returns false. @@ -56,18 +57,18 @@ public static TValue Read(this ISynchronizableLock sync, FuncA lambda that will perform the write if the read failed /// true if the read succeeded, otherwise false. public static bool Write(this ISynchronizableLock sync, Func read, Action write) - { - return sync.Write(-1, read, write); - } + { + return sync.Write(-1, read, write); + } - public static IDisposable CreateReaderScope(this ISynchronizableLock sync) - { - return sync.CreateReaderScope(-1); - } + public static IDisposable CreateReaderScope(this ISynchronizableLock sync) + { + return sync.CreateReaderScope(-1); + } - public static IDisposable CreateWriterScope(this ISynchronizableLock sync) - { - return sync.CreateWriterScope(-1); - } - } -} \ No newline at end of file + public static IDisposable CreateWriterScope(this ISynchronizableLock sync) + { + return sync.CreateWriterScope(-1); + } + } +} diff --git a/src/Uno.Core/Threading/SynchronizableLock.Phone.cs b/src/Uno.Core/Threading/SynchronizableLock.Phone.cs index 8efe39c..db255d8 100644 --- a/src/Uno.Core/Threading/SynchronizableLock.Phone.cs +++ b/src/Uno.Core/Threading/SynchronizableLock.Phone.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Threading; using Uno.Extensions; @@ -21,72 +22,72 @@ namespace Uno.Threading { - public class SynchronizableExclusiveLock : ISynchronizableLock - { - private readonly T instance; + public class SynchronizableExclusiveLock : ISynchronizableLock + { + private readonly T instance; private object _gate = new object(); public SynchronizableExclusiveLock(T instance) - { - this.instance = instance; - } + { + this.instance = instance; + } - #region ISynchronizableLock Members + #region ISynchronizableLock Members - public virtual TValue Read(int millisecondsTimeout, Func read) - { - lock(_gate) - { - return read(instance); - } - } + public virtual TValue Read(int millisecondsTimeout, Func read) + { + lock(_gate) + { + return read(instance); + } + } - public virtual bool Write(int millisecondsTimeout, Func read, Action write) - { - lock(_gate) - { - if (read(instance)) - { - return true; - } - else - { - if (read(instance)) - { - return true; - } - else - { - write(instance); - } - } + public virtual bool Write(int millisecondsTimeout, Func read, Action write) + { + lock(_gate) + { + if (read(instance)) + { + return true; + } + else + { + if (read(instance)) + { + return true; + } + else + { + write(instance); + } + } - return false; - } - } + return false; + } + } - public virtual TValue Write(int millisecondsTimeout, Func write) - { + public virtual TValue Write(int millisecondsTimeout, Func write) + { lock (_gate) { - return write(instance); - } - } + return write(instance); + } + } - public virtual IDisposable CreateReaderScope(int millisecondsTimeout) - { + public virtual IDisposable CreateReaderScope(int millisecondsTimeout) + { Monitor.Enter(_gate); return Actions.Create(() => Monitor.Exit(_gate)).ToDisposable(); - } + } - public virtual IDisposable CreateWriterScope(int millisecondsTimeout) - { + public virtual IDisposable CreateWriterScope(int millisecondsTimeout) + { Monitor.Enter(_gate); return Actions.Create(() => Monitor.Exit(_gate)).ToDisposable(); } - #endregion - } + #endregion + } } diff --git a/src/Uno.Core/Threading/SynchronizableLock.cs b/src/Uno.Core/Threading/SynchronizableLock.cs index c2d8aa3..9246d68 100644 --- a/src/Uno.Core/Threading/SynchronizableLock.cs +++ b/src/Uno.Core/Threading/SynchronizableLock.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Threading; using Uno.Extensions; @@ -21,134 +22,133 @@ namespace Uno.Threading { - - public class SynchronizableLock : ISynchronizableLock - { - private readonly T instance; - - //TODO Use Slim Lock? - private ReaderWriterLockSlim readerWriter = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); - - public SynchronizableLock(T instance) - { - this.instance = instance; - } - - #region ISynchronizableLock Members - - public virtual TValue Read(int millisecondsTimeout, Func read) - { - if (readerWriter.TryEnterUpgradeableReadLock(millisecondsTimeout)) - { - try - { - return read(instance); - } - finally - { - readerWriter.ExitUpgradeableReadLock(); - } - } - - throw new TimeoutException("Failed to acquire read lock"); - } - - public virtual bool Write(int millisecondsTimeout, Func read, Action write) - { - if (readerWriter.TryEnterUpgradeableReadLock(millisecondsTimeout)) - { - - try - { - if (read(instance)) - { - return true; - } - else - { - if (readerWriter.TryEnterWriteLock(millisecondsTimeout)) - { - - try - { - if (read(instance)) - { - return true; - } - else - { - write(instance); - } - } - finally - { - readerWriter.ExitWriteLock(); - } - } - else - { - throw new TimeoutException("Failed to acquire write lock"); - } - } - } - finally - { - readerWriter.ExitUpgradeableReadLock(); - } - - return false; - } - - throw new TimeoutException("Failed to acquire read lock"); - } - - public virtual TValue Write(int millisecondsTimeout, Func write) - { - if (readerWriter.TryEnterWriteLock(millisecondsTimeout)) - { - try - { - return write(instance); - } - finally - { - readerWriter.ExitWriteLock(); - } - } - - throw new TimeoutException("Failed to acquire write lock"); - } - - public virtual IDisposable CreateReaderScope(int millisecondsTimeout) - { - if (readerWriter.TryEnterUpgradeableReadLock(millisecondsTimeout)) - { - return Actions.Create(() => readerWriter.ExitUpgradeableReadLock()).ToDisposable(); - } - - throw new TimeoutException("Failed to acquire read lock"); - } - - public virtual IDisposable CreateWriterScope(int millisecondsTimeout) - { - if (readerWriter.TryEnterWriteLock(millisecondsTimeout)) - { - return Actions.Create(() => readerWriter.ExitWriteLock()).ToDisposable(); - } - - throw new TimeoutException("Failed to acquire read lock"); - } - - #endregion - - #region Serialization Specific - - [OnDeserialized] - internal void OnDeserializedMethod(StreamingContext context) - { - if(readerWriter == null) - readerWriter = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); - } - #endregion - } + public class SynchronizableLock : ISynchronizableLock + { + private readonly T instance; + + //TODO Use Slim Lock? + private ReaderWriterLockSlim readerWriter = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); + + public SynchronizableLock(T instance) + { + this.instance = instance; + } + + #region ISynchronizableLock Members + + public virtual TValue Read(int millisecondsTimeout, Func read) + { + if (readerWriter.TryEnterUpgradeableReadLock(millisecondsTimeout)) + { + try + { + return read(instance); + } + finally + { + readerWriter.ExitUpgradeableReadLock(); + } + } + + throw new TimeoutException("Failed to acquire read lock"); + } + + public virtual bool Write(int millisecondsTimeout, Func read, Action write) + { + if (readerWriter.TryEnterUpgradeableReadLock(millisecondsTimeout)) + { + + try + { + if (read(instance)) + { + return true; + } + else + { + if (readerWriter.TryEnterWriteLock(millisecondsTimeout)) + { + + try + { + if (read(instance)) + { + return true; + } + else + { + write(instance); + } + } + finally + { + readerWriter.ExitWriteLock(); + } + } + else + { + throw new TimeoutException("Failed to acquire write lock"); + } + } + } + finally + { + readerWriter.ExitUpgradeableReadLock(); + } + + return false; + } + + throw new TimeoutException("Failed to acquire read lock"); + } + + public virtual TValue Write(int millisecondsTimeout, Func write) + { + if (readerWriter.TryEnterWriteLock(millisecondsTimeout)) + { + try + { + return write(instance); + } + finally + { + readerWriter.ExitWriteLock(); + } + } + + throw new TimeoutException("Failed to acquire write lock"); + } + + public virtual IDisposable CreateReaderScope(int millisecondsTimeout) + { + if (readerWriter.TryEnterUpgradeableReadLock(millisecondsTimeout)) + { + return Actions.Create(() => readerWriter.ExitUpgradeableReadLock()).ToDisposable(); + } + + throw new TimeoutException("Failed to acquire read lock"); + } + + public virtual IDisposable CreateWriterScope(int millisecondsTimeout) + { + if (readerWriter.TryEnterWriteLock(millisecondsTimeout)) + { + return Actions.Create(() => readerWriter.ExitWriteLock()).ToDisposable(); + } + + throw new TimeoutException("Failed to acquire read lock"); + } + + #endregion + + #region Serialization Specific + + [OnDeserialized] + internal void OnDeserializedMethod(StreamingContext context) + { + if(readerWriter == null) + readerWriter = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); + } + #endregion + } } diff --git a/src/Uno.Core/Threading/ThreadLocalSource.Phone.cs b/src/Uno.Core/Threading/ThreadLocalSource.Phone.cs index 08adb39..51b32ce 100644 --- a/src/Uno.Core/Threading/ThreadLocalSource.Phone.cs +++ b/src/Uno.Core/Threading/ThreadLocalSource.Phone.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Uno.Core/Transactional.Immutables.cs b/src/Uno.Core/Transactional.Immutables.cs index 2ace5e9..98f830b 100644 --- a/src/Uno.Core/Transactional.Immutables.cs +++ b/src/Uno.Core/Transactional.Immutables.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Collections.Immutable; diff --git a/src/Uno.Core/Transactional.cs b/src/Uno.Core/Transactional.cs index 84fdef2..a97bbed 100644 --- a/src/Uno.Core/Transactional.cs +++ b/src/Uno.Core/Transactional.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Collections.Immutable; diff --git a/src/Uno.Core/Tuple.CompileTimeValidation.cs b/src/Uno.Core/Tuple.CompileTimeValidation.cs index 5469b22..992cd6c 100644 --- a/src/Uno.Core/Tuple.CompileTimeValidation.cs +++ b/src/Uno.Core/Tuple.CompileTimeValidation.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,15 +14,16 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Text; namespace Uno.Core { - static class __Tuple_Validatoion - { + static class __Tuple_Validatoion + { #pragma warning disable 414 static (int, int) a = (0, 0); - } + } } diff --git a/src/Uno.Core/UnavailableResourceException.cs b/src/Uno.Core/UnavailableResourceException.cs index f3f8054..c682e94 100644 --- a/src/Uno.Core/UnavailableResourceException.cs +++ b/src/Uno.Core/UnavailableResourceException.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Text; diff --git a/src/Uno.Core/Validation/StringValidationExtensions.cs b/src/Uno.Core/Validation/StringValidationExtensions.cs index 3244e33..3c5bb6c 100644 --- a/src/Uno.Core/Validation/StringValidationExtensions.cs +++ b/src/Uno.Core/Validation/StringValidationExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using Uno.Validation; diff --git a/src/Uno.Core/Validation/ValidationExtensionPoint.cs b/src/Uno.Core/Validation/ValidationExtensionPoint.cs index 36b69cd..f0f7979 100644 --- a/src/Uno.Core/Validation/ValidationExtensionPoint.cs +++ b/src/Uno.Core/Validation/ValidationExtensionPoint.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,15 +14,16 @@ // limitations under the License. // // ****************************************************************** + using Uno.Extensions; namespace Uno.Validation { - public class ValidationExtensionPoint : ExtensionPoint - { - public ValidationExtensionPoint(T value) - : base(value) - { - } - } -} \ No newline at end of file + public class ValidationExtensionPoint : ExtensionPoint + { + public ValidationExtensionPoint(T value) + : base(value) + { + } + } +} diff --git a/src/Uno.Core/Validation/ValidationExtensions.cs b/src/Uno.Core/Validation/ValidationExtensions.cs index 0a0dd05..a1e4e66 100644 --- a/src/Uno.Core/Validation/ValidationExtensions.cs +++ b/src/Uno.Core/Validation/ValidationExtensions.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,41 +14,42 @@ // limitations under the License. // // ****************************************************************** + using System; using Uno.Validation; namespace Uno.Extensions { - public static class ValidationExtensions - { - public static ValidationExtensionPoint Validation(this T value) where T : class - { - return new ValidationExtensionPoint(value); - } + public static class ValidationExtensions + { + public static ValidationExtensionPoint Validation(this T value) where T : class + { + return new ValidationExtensionPoint(value); + } - public static T NotNull(this ValidationExtensionPoint extensionPoint, string name) where T : class - { - if (extensionPoint.ExtendedValue == null) - { - throw new ArgumentNullException(name); - } + public static T NotNull(this ValidationExtensionPoint extensionPoint, string name) where T : class + { + if (extensionPoint.ExtendedValue == null) + { + throw new ArgumentNullException(name); + } - return extensionPoint.ExtendedValue; - } - public static T Found(this ValidationExtensionPoint extensionPoint) where T : class - { - if (extensionPoint.ExtendedValue == null) - { - throw new ArgumentException(); - //throw new NotFoundException(); - } + return extensionPoint.ExtendedValue; + } + public static T Found(this ValidationExtensionPoint extensionPoint) where T : class + { + if (extensionPoint.ExtendedValue == null) + { + throw new ArgumentException(); + //throw new NotFoundException(); + } - return extensionPoint.ExtendedValue; - } - public static void NotSupported(this ValidationExtensionPoint extensionPoint) where T : class - { - throw new NotSupportedException(); - } + return extensionPoint.ExtendedValue; + } + public static void NotSupported(this ValidationExtensionPoint extensionPoint) where T : class + { + throw new NotSupportedException(); + } public static T IsTrue(this ValidationExtensionPoint extensionPoint, Func validation, string paramName, string message = null) where T : class { @@ -70,4 +71,4 @@ public static T IsFalse(this ValidationExtensionPoint extensionPoint, Func return extensionPoint.ExtendedValue; } } -} \ No newline at end of file +} diff --git a/src/Uno.Core/Validation/ValidationHelper.cs b/src/Uno.Core/Validation/ValidationHelper.cs index f9f70cb..4d86dc9 100644 --- a/src/Uno.Core/Validation/ValidationHelper.cs +++ b/src/Uno.Core/Validation/ValidationHelper.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Collections.Generic; using System.Globalization; diff --git a/src/Uno.Core/WeakReference.cs b/src/Uno.Core/WeakReference.cs index a505290..c182fcb 100644 --- a/src/Uno.Core/WeakReference.cs +++ b/src/Uno.Core/WeakReference.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,45 +14,37 @@ // limitations under the License. // // ****************************************************************** + #if !XAMARIN && !WINDOWS_UWP using System; namespace Uno { - public class WeakReference - { - private readonly WeakReference _reference; - public WeakReference(T target) - { - _reference = new WeakReference(target); - } + public class WeakReference + { + private readonly WeakReference _reference; + public WeakReference(T target) + { + _reference = new WeakReference(target); + } - public T Target - { - get { return (T)_reference.Target; } - set { _reference.Target = value; } - } + public T Target + { + get => (T)_reference.Target; + set => _reference.Target = value; + } - public bool IsAlive - { - get { return _reference.IsAlive; } - } + public bool IsAlive => _reference.IsAlive; - public bool TrackResurrection - { - get { return _reference.TrackResurrection; } - } + public bool TrackResurrection => _reference.TrackResurrection; - public bool TryGetTarget(out T target) - { - target = Target; - return _reference.IsAlive; - } + public bool TryGetTarget(out T target) + { + target = Target; + return _reference.IsAlive; + } - public T GetTarget() - { - return Target; - } - } + public T GetTarget() => Target; + } } -#endif \ No newline at end of file +#endif diff --git a/src/Uno.Core/WebRequestCreate.cs b/src/Uno.Core/WebRequestCreate.cs index b675025..5ffa7d8 100644 --- a/src/Uno.Core/WebRequestCreate.cs +++ b/src/Uno.Core/WebRequestCreate.cs @@ -1,5 +1,5 @@ // ****************************************************************** -// Copyright � 2015-2018 nventive inc. All rights reserved. +// Copyright � 2015-2020 nventive inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. // // ****************************************************************** + using System; using System.Net; using Uno.Extensions; @@ -92,4 +93,4 @@ public static IWebRequestCreate Decorate(this IWebRequestCreate webReq }); } } -} \ No newline at end of file +} From 3494c5dc12bc76e10c80bb38a5a2b70f4ff63a55 Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Sat, 21 Nov 2020 22:51:32 -0500 Subject: [PATCH 3/3] ci: removed unwanted file introduced in previous commit. --- .../Uno - Backup.Core.Build.csproj | 85 ------------------- 1 file changed, 85 deletions(-) delete mode 100644 src/Uno.Core.Build/Uno - Backup.Core.Build.csproj diff --git a/src/Uno.Core.Build/Uno - Backup.Core.Build.csproj b/src/Uno.Core.Build/Uno - Backup.Core.Build.csproj deleted file mode 100644 index 4f25ba7..0000000 --- a/src/Uno.Core.Build/Uno - Backup.Core.Build.csproj +++ /dev/null @@ -1,85 +0,0 @@ - - - net46 - $(AssemblyName) ($(TargetFramework)) - $(NoWarn);1998;1591;1573;1572;1574;1712;1711;1570;NU5128;NU5105 - - false - true - True - - full - True - false - - - - nventive - https://github.com/nventive/Uno.Core - https://nv-assets.azurewebsites.net/logos/uno.png - https://github.com/nventive/Uno.Core - A package that includes Uno.Core as a dependency for build tasks and Uno.SourceGeneration binaries. - Copyright (C) 2015-2020 nventive inc. - all rights reserved - - - - - - - - - true - build - - - true - build - - - true - build - - - true - build - - - - - - 15.1.1012 - runtime - all - - - 15.1.1012 - runtime - all - - - 15.1.1012 - runtime - all - - - 15.1.1012 - runtime - all - - - all - runtime; build; native; contentfiles; analyzers - - - - - - - - - - - \ No newline at end of file