Align .editorconfig with WinForms (#10080)

This effectively copies the .editorconfig from WinForms to align the baseline.

As there are many deviations from the rules in the sources, added a temporary .editorconfig in the product src directory. This will need to have rules pulled bit by bit as the projects are fixed. Most of the rules are pretty easy to fix, but would require some pretty massive codefix changes. They are reasonably safe to do, but they will create disruption for existing PRs as they'll need to rebase.

Created another .editorconfig specifically for the cycle breaker projects. Fixed the headers in the cycle breakers, but otherwise mostly left them alone.

Test projects were updated to pass without needing any overrides. As a general rule, we try to not disable rules for test projects as we want to keep good habits over the entire codebase.

The sooner the automated fixes are done, the better. It is better to have this done before Preview 1 and it is better to aggressively push to do them. Don't wait for full test passes in between changes, do a full pass once they are committed. The recommendation:

1. For each rule where there is an automated fix, run the fix and create a PR that says that you ran the codefix
2. Sanity review and merge each as quickly as possible (check off, merge as soon as green)
3. Run a full test pass when finished

Clearing the automated fixes should be able to be done in a couple weeks at most. Once the rules are turned on it will significantly improve the contribution process. Less clean up to review, less iteration over rules, etc.

Co-authored-by: Harshit <62823486+harshit7962@users.noreply.github.com>
This commit is contained in:
Jeremy Kuhne 2024-11-18 03:40:52 -08:00 коммит произвёл GitHub
Родитель d209c5c9ea
Коммит d73dd1dbd9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
95 изменённых файлов: 2856 добавлений и 2196 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -52,7 +52,6 @@
<!-- Packages that come from https://github.com/dotnet/arcade -->
<PropertyGroup>
<MicrosoftDotNetApiCompatVersion>9.0.0-beta.24053.1</MicrosoftDotNetApiCompatVersion>
<MicrosoftDotNetCodeAnalysisPackageVersion>10.0.0-beta.24564.1</MicrosoftDotNetCodeAnalysisPackageVersion>
</PropertyGroup>
<!-- Sourcelink -->
<PropertyGroup>
@ -83,10 +82,6 @@
<NetFramework48RefAssembliesVersion>0.0.0.1</NetFramework48RefAssembliesVersion>
<MicrosoftWindowsCsWin32PackageVersion>0.3.106</MicrosoftWindowsCsWin32PackageVersion>
</PropertyGroup>
<!-- External Analyzers -->
<PropertyGroup>
<MicrosoftCodeAnalysisNetAnalyzersVersion>7.0.0</MicrosoftCodeAnalysisNetAnalyzersVersion>
</PropertyGroup>
<!-- XUnit-related (not extensions) -->
<PropertyGroup>
<XUnitVersion>2.9.0</XUnitVersion>
@ -111,6 +106,22 @@
<CodecovVersion>1.9.0</CodecovVersion>
<ReportGeneratorVersion>4.0.9</ReportGeneratorVersion>
</PropertyGroup>
<!-- External Analyzers -->
<PropertyGroup>
<CSharpIsNullAnalyzersVersion>0.1.495</CSharpIsNullAnalyzersVersion>
<DotNetAnalyzersDocumentationAnalyzersVersion>1.0.0-beta.59</DotNetAnalyzersDocumentationAnalyzersVersion>
<MicrosoftCodeAnalysisAnalyzersVersion>3.11.0-beta1.24219.2</MicrosoftCodeAnalysisAnalyzersVersion>
<MicrosoftCodeAnalysisCommonPackageVersion>4.10.0-3.final</MicrosoftCodeAnalysisCommonPackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>$(MicrosoftCodeAnalysisCommonPackageVersion)</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisVisualBasicPackageVersion>$(MicrosoftCodeAnalysisCommonPackageVersion)</MicrosoftCodeAnalysisVisualBasicPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesVersion>$(MicrosoftCodeAnalysisCommonPackageVersion)</MicrosoftCodeAnalysisCSharpWorkspacesVersion>
<MicrosoftCodeAnalysisVisualBasicWorkspacesVersion>$(MicrosoftCodeAnalysisCommonPackageVersion)</MicrosoftCodeAnalysisVisualBasicWorkspacesVersion>
<MicrosoftCodeAnalysisPackagesVersion>1.1.3-beta1.24352.1</MicrosoftCodeAnalysisPackagesVersion>
<MicrosoftCodeAnalysisPublicApiAnalyzersVersion>$(MicrosoftCodeAnalysisAnalyzersVersion)</MicrosoftCodeAnalysisPublicApiAnalyzersVersion>
<MicrosoftCodeAnalysisNetAnalyzersVersion>8.0.0</MicrosoftCodeAnalysisNetAnalyzersVersion>
<StyleCopAnalyzersVersion>1.2.0-beta.556</StyleCopAnalyzersVersion>
<NugetPackagingVersion>6.11.0</NugetPackagingVersion>
</PropertyGroup>
<!--Package names-->
<PropertyGroup>
<SystemReflectionMetadataLoadContextPackage>System.Reflection.MetadataLoadContext</SystemReflectionMetadataLoadContextPackage>

Просмотреть файл

@ -1,7 +1,14 @@
<Project>
<PropertyGroup>
<!-- Do not warn about the version of analyzers being used in this project -->
<!-- Only upgrade NuGetAudit warnings to errors for official builds. -->
<WarningsNotAsErrors Condition="'$(OfficialBuild)' != 'true'">$(WarningsNotAsErrors);NU1901;NU1902;NU1903;NU1904</WarningsNotAsErrors>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<!--
Don't let Microsoft.CodeAnalysis.NetAnalyzers complain about the version being older than what is in the SDK.
-->
<_SkipUpgradeNetAnalyzersNuGetWarning>true</_SkipUpgradeNetAnalyzersNuGetWarning>
</PropertyGroup>

Просмотреть файл

@ -1,10 +1,17 @@
<Project>
<ItemGroup Condition="'$(IsTestProject)'!='true' AND '$(EnableAnalyzers)'=='true'">
<EditorConfigFiles Include="$(MSBuildThisFileDirectory)CodeAnalysis\CodeAnalysis.src.globalconfig" />
<!-- Managed Code Reference analyzers -->
<PackageReference Include="Microsoft.DotNet.CodeAnalysis" Version="$(MicrosoftDotNetCodeAnalysisPackageVersion)" />
<ItemGroup Condition="'$(EnableAnalyzers)'=='true'">
<!-- Managed Code analyzers -->
<!-- https://github.com/DotNetAnalyzers/StyleCopAnalyzers -->
<PackageReference Include="StyleCop.Analyzers" Version="$(StyleCopAnalyzersVersion)" PrivateAssets="all" />
<!-- https://github.com/dotnet/roslyn-analyzers -->
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="$(MicrosoftCodeAnalysisNetAnalyzersVersion)" PrivateAssets="all" />
<PackageReference Include="System.Runtime.Analyzers" Version="1.1.0" />
<PackageReference Include="System.Runtime.InteropServices.Analyzers" Version="1.1.0" />
<!-- https://github.com/DotNetAnalyzers/DocumentationAnalyzers -->
<PackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" Version="$(DotNetAnalyzersDocumentationAnalyzersVersion)" PrivateAssets="all" />
<!-- https://github.com/AArnott/CSharpIsNull -->
<PackageReference Include="CSharpIsNullAnalyzer" Version="$(CSharpIsNullAnalyzersVersion)" PrivateAssets="all" />
</ItemGroup>
</Project>

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,39 @@
# editorconfig.org
# This file contains temporary overrides for higher level .editorconfig rules.
# For cycle-breakers matching most rules is not as critical. Overrides that
# should NOT be re-enabled are marked as "none". Ones that can be fixed and
# removed are marked as "suggestion".
# C# and VB files
[*.{cs,vb}]
# CA1066: Implement IEquatable when overriding Object.Equals
dotnet_diagnostic.CA1066.severity = none
# CA1725: Parameter names should match base declaration
dotnet_diagnostic.CA1725.severity = none
# CA1822: Mark members as static
dotnet_diagnostic.CA1822.severity = none
# CA1823: Avoid unused private fields
dotnet_diagnostic.CA1823.severity = none
# IDE0034: Simplify 'default' expression
dotnet_diagnostic.IDE0034.severity = suggestion
# IDE0036: Order modifiers
dotnet_diagnostic.IDE0036.severity = suggestion
# IDE0044: Add readonly modifier
dotnet_diagnostic.IDE0044.severity = none
# IDE0051: Remove unused private members
dotnet_diagnostic.IDE0051.severity = none
# IDE0251: Make member 'readonly'
dotnet_diagnostic.IDE0251.severity = none
# IDE1006: Naming Styles
dotnet_diagnostic.IDE1006.severity = suggestion

Просмотреть файл

@ -7,6 +7,7 @@
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Platforms>AnyCPU</Platforms>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>

Просмотреть файл

@ -10,6 +10,7 @@
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
<!--The field '{0}' is never used -->
<NoWarn>$(NoWarn);0169</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>

Просмотреть файл

@ -8,6 +8,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Platforms>AnyCPU</Platforms>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>

Просмотреть файл

@ -10,6 +10,7 @@
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
<!--The field '{0}' is never used -->
<NoWarn>$(NoWarn);0169</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------

Просмотреть файл

@ -1,13 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
namespace System.Windows.Controls
namespace System.Windows.Controls
{
public partial struct PageRange
{
}
}
}

Просмотреть файл

@ -1,11 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
namespace System.Windows.Controls
namespace System.Windows.Controls
{
public enum PageRangeSelection
{
@ -14,4 +14,4 @@ namespace System.Windows.Controls
SelectedPages = 3,
UserPages = 1,
}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
@ -8,6 +8,6 @@
namespace System.Windows.Documents
{
public sealed partial class FixedDocument
{
{
}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
@ -8,6 +8,6 @@
namespace System.Windows.Documents
{
public partial class FixedDocumentSequence
{
{
}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
@ -8,6 +8,6 @@
namespace System.Windows.Documents
{
public sealed partial class FixedPage
{
{
}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
@ -45,4 +45,4 @@ namespace System.Windows.Documents.Serialization
public System.Windows.Xps.Serialization.PrintTicketLevel CurrentPrintTicketLevel { get { throw null; } }
public int Sequence { get { throw null; } }
}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
@ -48,4 +48,4 @@ namespace System.Windows.Documents.Serialization
public abstract void WriteAsync(System.Windows.Media.Visual visual, System.Printing.PrintTicket printTicket);
public abstract void WriteAsync(System.Windows.Media.Visual visual, System.Printing.PrintTicket printTicket, object userState);
}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
@ -21,4 +21,4 @@ namespace System.Windows.Documents.Serialization
public abstract void WriteAsync(System.Windows.Media.Visual visual, System.Printing.PrintTicket printTicket);
public abstract void WriteAsync(System.Windows.Media.Visual visual, System.Printing.PrintTicket printTicket, object userState);
}
}
}

Просмотреть файл

@ -9,6 +9,7 @@
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
<!--The field '{0}' is never used -->
<NoWarn>$(NoWarn);0169</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
@ -13,4 +13,4 @@ namespace System.Windows.Documents
/// </summary>
public static class PresentationUIStyleResources
{ }
}
}

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------

Просмотреть файл

@ -7,6 +7,7 @@
<!-- don't sign nor binplace this non-shipping assembly -->
<ShouldWriteSigningRequired>false</ShouldWriteSigningRequired>
<Platforms>AnyCPU</Platforms>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>

Просмотреть файл

@ -7,6 +7,7 @@
<!-- don't sign nor binplace this non-shipping assembly -->
<ShouldWriteSigningRequired>false</ShouldWriteSigningRequired>
<Platforms>AnyCPU</Platforms>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
@ -10,4 +10,4 @@ namespace System.Printing
public sealed partial class PrintCapabilities
{
}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
@ -11,4 +11,4 @@ namespace System.Printing
{
private PrintTicket() {}
}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
@ -10,4 +10,4 @@ namespace System.Printing
public enum PrintTicketScope
{
}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
@ -10,4 +10,4 @@ namespace System.Printing
public partial struct ValidationResult
{
}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
@ -11,4 +11,4 @@ namespace System.Windows.Xps.Packaging
{
private PackagingProgressEventArgs() {}
}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
@ -10,4 +10,4 @@ namespace System.Windows.Xps.Packaging
public partial class XpsDocument
{
}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
@ -10,4 +10,4 @@ namespace System.Windows.Xps.Serialization
public enum PrintTicketLevel
{
}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
@ -14,4 +14,4 @@ namespace System.Windows.Xps.Serialization.RCW
{
// INTENTIONALLY empty to avoid exposing the entire type closure to reference assemblies
}
}
}

Просмотреть файл

@ -7,6 +7,7 @@
<!-- don't sign nor binplace this non-shipping assembly -->
<ShouldWriteSigningRequired>false</ShouldWriteSigningRequired>
<Platforms>x86;x64;arm64</Platforms>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>

Просмотреть файл

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
@ -9,8 +9,8 @@ namespace System.Printing
{
public class PrintQueue
{
private PrintQueue()
{
private PrintQueue()
{
}
}
}
}

Просмотреть файл

@ -0,0 +1,345 @@
# editorconfig.org
# This file contains temporary overrides for higher level .editorconfig rules.
# These need removed as particular rules get fixed. Marking as suggestion so
# codefixes and defaults are still available.
# C# and VB files
[*.{cs,vb}]
dotnet_style_prefer_collection_expression = when_types_exactly_match:suggestion
csharp_prefer_system_threading_lock = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
# NOTE: If existing public API, CA1036 should be suppressed individually
# in the GlobalSuppressions file.
# CA1036: Override methods on comparable types
dotnet_diagnostic.CA1036.severity = suggestion
# CA1052: Static holder types should be Static or NotInheritable
dotnet_diagnostic.CA1052.severity = suggestion
# NOTE: If existing public API, CA1066 should be suppressed individually
# in the GlobalSuppressions file.
# CA1066: Implement IEquatable when overriding Object.Equals
dotnet_diagnostic.CA1066.severity = suggestion
# NOTE: If existing public API, CA1067 should be suppressed individually
# in the GlobalSuppressions file.
# CA1067: Override Object.Equals(object) when implementing IEquatable<T>
dotnet_diagnostic.CA1067.severity = suggestion
# NOTE: If existing public API, CA1070 should be suppressed individually
# in the GlobalSuppressions file.
# CA1070: Do not declare event fields as virtual
dotnet_diagnostic.CA1070.severity = suggestion
# CA1310: Specify StringComparison for correctness
dotnet_diagnostic.CA1310.severity = suggestion
# CA1419: Provide a parameterless constructor that is as visible as the containing type for concrete types derived from 'System.Runtime.InteropServices.SafeHandle'
dotnet_diagnostic.CA1419.severity = suggestion
# CA1507: Use nameof in place of string
dotnet_diagnostic.CA1507.severity = suggestion
# CA1510: Use ArgumentNullException throw helper
dotnet_diagnostic.CA1510.severity = suggestion
# NOTE: If existing public API, CA2211 should be suppressed individually
# in the GlobalSuppressions file.
# CA2211: Non-constant fields should not be visible
dotnet_diagnostic.CA2211.severity = suggestion
# CA1512: Use ArgumentOutOfRangeException throw helper
dotnet_diagnostic.CA1512.severity = suggestion
# CA1513: Use ObjectDisposedException throw helper
dotnet_diagnostic.CA1513.severity = suggestion
# CA1514: Avoid redundant length argument
dotnet_diagnostic.CA1514.severity = suggestion
# CA5394: Do not use insecure randomness
dotnet_diagnostic.CA5394.severity = suggestion
# NOTE: If existing public API, CA1725 should be suppressed individually
# in the GlobalSuppressions file.
# CA1725: Parameter names should match base declaration
dotnet_diagnostic.CA1725.severity = suggestion
# CA1802: Use literals where appropriate
dotnet_diagnostic.CA1802.severity = suggestion
# CA1805: Do not initialize unnecessarily
dotnet_diagnostic.CA1805.severity = suggestion
# CA1810: Initialize reference type static fields inline
dotnet_diagnostic.CA1810.severity = suggestion
# NOTE: If existing public API, CA1815 should be suppressed individually
# in the GlobalSuppressions file.
# CA1815: Override equals and operator equals on value types
dotnet_diagnostic.CA1815.severity = none
# CA1822: Mark members as static
dotnet_diagnostic.CA1822.severity = suggestion
# CA1823: Avoid unused private fields
dotnet_diagnostic.CA1823.severity = suggestion
# CA1825: Avoid zero-length array allocations
dotnet_diagnostic.CA1825.severity = suggestion
# CA1834: Use StringBuilder.Append(char) for single character strings
dotnet_diagnostic.CA1834.severity = suggestion
# This will go away as part of porting to CsWin32
# CA1838: Avoid StringBuilder parameters for P/Invokes
dotnet_diagnostic.CA1838.severity = suggestion
# CA1845: Use span-based 'string.Concat'
dotnet_diagnostic.CA1845.severity = suggestion
# CA1846: Prefer AsSpan over Substring
dotnet_diagnostic.CA1846.severity = suggestion
# CA1847: Use string.Contains(char) instead of string.Contains(string) with single characters
dotnet_diagnostic.CA1847.severity = suggestion
# CA1851: Possible multiple enumerations of IEnumerable collection
dotnet_diagnostic.CA1851.severity = suggestion
# CA1852: Seal internal types
dotnet_diagnostic.CA1852.severity = suggestion
# CA1853: Unnecessary call to 'Dictionary.ContainsKey(key)'
dotnet_diagnostic.CA1853.severity = suggestion
# CA1854: Prefer the IDictionary.TryGetValue(TKey, out TValue) method
dotnet_diagnostic.CA1854.severity = suggestion
# CA1858: Use StartsWith instead of IndexOf
dotnet_diagnostic.CA1858.severity = suggestion
# CA1859: Use concrete types when possible for improved performance
dotnet_diagnostic.CA1859.severity = suggestion
# CA2011: Do not assign property within its setter
dotnet_diagnostic.CA2011.severity = suggestion
# CA2019: ThreadStatic fields should not use inline initialization
dotnet_diagnostic.CA2019.severity = suggestion
# Should change all internal IntPtr/UIntPtr to nint/uint. IntPtr/UIntPtr no
# longer do checked operations so they are now equivalent.
# CA2020: Prevent behavioral change caused by built-in operators of IntPtr/UIntPtr
dotnet_diagnostic.CA2020.severity = suggestion
# NOTE: If thrown externally, CA2201 should be suppressed individually
# in the GlobalSuppressions file.
# CA2201: Do not raise reserved exception types
dotnet_diagnostic.CA2201.severity = suggestion
# CA2207: Initialize value type static fields inline
dotnet_diagnostic.CA2207.severity = suggestion
# CA2208: Instantiate argument exceptions correctly
dotnet_diagnostic.CA2208.severity = suggestion
# CA2219: Do not raise exceptions in finally clauses
dotnet_diagnostic.CA2219.severity = suggestion
# CA2242: Test for NaN correctly
dotnet_diagnostic.CA2242.severity = suggestion
# CA2249: Consider using 'string.Contains' instead of 'string.IndexOf'
dotnet_diagnostic.CA2249.severity = suggestion
# CA2251: Use String.Equals over String.Compare
dotnet_diagnostic.CA2251.severity = suggestion
# CA2300: Do not use insecure deserializer BinaryFormatter
dotnet_diagnostic.CA2300.severity = suggestion
# CA2302: Ensure BinaryFormatter.Binder is set before calling BinaryFormatter.Deserialize
dotnet_diagnostic.CA2302.severity = suggestion
# CA5350: Do Not Use Weak Cryptographic Algorithms
dotnet_diagnostic.CA5350.severity = suggestion
# CA5351: Do Not Use Broken Cryptographic Algorithms
dotnet_diagnostic.CA5351.severity = suggestion
# CA5362: Potential reference cycle in deserialized object graph
dotnet_diagnostic.CA5362.severity = suggestion
# CSIsNull001: Use 'is' pattern check
dotnet_diagnostic.CSIsNull001.severity = suggestion
# CSIsNull002: Use 'is not' pattern check
dotnet_diagnostic.CSIsNull002.severity = suggestion
# IDE0005: Using directive is unnecessary.
dotnet_diagnostic.IDE0005.severity = suggestion
# IDE0017: Simplify object initialization
dotnet_diagnostic.IDE0017.severity = suggestion
# IDE0019: Use pattern matching to avoid as followed by a null check
dotnet_diagnostic.IDE0019.severity = suggestion
# IDE0020: Use pattern matching to avoid is check followed by a cast (with variable)
dotnet_diagnostic.IDE0020.severity = suggestion
# IDE0029: Use coalesce expression
dotnet_diagnostic.IDE0029.severity = suggestion
# IDE0030: Null check can be simplified
dotnet_diagnostic.IDE0030.severity = suggestion
# IDE0031: Use null propagation
dotnet_diagnostic.IDE0031.severity = suggestion
# IDE0034: Simplify 'default' expression
dotnet_diagnostic.IDE0034.severity = suggestion
# IDE0036: Order modifiers
dotnet_diagnostic.IDE0036.severity = suggestion
# IDE0040: Add accessibility modifiers
dotnet_diagnostic.IDE0040.severity = suggestion
# IDE0041: Use 'is null' check
dotnet_diagnostic.IDE0041.severity = suggestion
# IDE0044: Add readonly modifier
dotnet_diagnostic.IDE0044.severity = suggestion
# IDE0051: Remove unused private members
dotnet_diagnostic.IDE0051.severity = suggestion
# IDE0052: Remove unread private members
dotnet_diagnostic.IDE0052.severity = suggestion
# IDE0057: Use range operator
dotnet_diagnostic.IDE0057.severity = suggestion
# IDE0060: Remove unused parameter
dotnet_diagnostic.IDE0060.severity = suggestion
# IDE0062: Make local function 'static'
dotnet_diagnostic.IDE0062.severity = suggestion
# IDE0063: Use simple 'using' statement
dotnet_diagnostic.IDE0063.severity = suggestion
# IDE0065: Misplaced using directive
dotnet_diagnostic.IDE0065.severity = suggestion
# IDE0066: Convert switch statement to expression
dotnet_diagnostic.IDE0066.severity = suggestion
# IDE0073: The file header is missing or not located at the top of the file
dotnet_diagnostic.IDE0073.severity = suggestion
# IDE0074: Use compound assignment
dotnet_diagnostic.IDE0074.severity = suggestion
# IDE0075: Simplify conditional expression
dotnet_diagnostic.IDE0075.severity = suggestion
# IDE0076: Invalid global 'SuppressMessageAttribute'
dotnet_diagnostic.IDE0076.severity = suggestion
# IDE0077: Avoid legacy global suppression format
dotnet_diagnostic.IDE0077.severity = suggestion
# IDE0078: Use pattern matching
dotnet_diagnostic.IDE0078.severity = suggestion
# IDE0082: 'typeof' can be converted to 'nameof'
dotnet_diagnostic.IDE0082.severity = suggestion
# IDE0100: Remove redundant equality
dotnet_diagnostic.IDE0100.severity = suggestion
# IDE0150: Prefer 'null' check over type check
dotnet_diagnostic.IDE0150.severity = suggestion
# IDE0180: Use tuple to swap values
dotnet_diagnostic.IDE0180.severity = suggestion
# IDE0251: Make member 'readonly'
dotnet_diagnostic.IDE0251.severity = suggestion
# IDE0270: Use coalesce expression
dotnet_diagnostic.IDE0270.severity = suggestion
# IDE0300: Simplify collection initialization
dotnet_diagnostic.IDE0300.severity = suggestion
# NOTE: For thread statics (t_), IDE1006 should be suppressed individually
# in the GlobalSuppressions file.
# IDE1006: Naming Styles
dotnet_diagnostic.IDE1006.severity = suggestion
# SA1001: Commas should not be preceded by whitespace
dotnet_diagnostic.SA1001.severity = suggestion
# SA1005: Single line comment should begin with a space
dotnet_diagnostic.SA1005.severity = suggestion
# SA1014: Opening generic brackets should not be preceded by a space
dotnet_diagnostic.SA1014.severity = suggestion
# SA1027: Tabs and spaces should be used correctly
dotnet_diagnostic.SA1027.severity = suggestion
# SA1028: Code should not contain trailing whitespace
dotnet_diagnostic.SA1028.severity = suggestion
# SA1121: Use built-in type alias
dotnet_diagnostic.SA1121.severity = suggestion
# SA1129: Do not use default value type constructor
dotnet_diagnostic.SA1129.severity = suggestion
# SA1131: Constant values should appear on the right-hand side of comparisons
dotnet_diagnostic.SA1131.severity = suggestion
# SA1400: Member should declare an access modifier
dotnet_diagnostic.SA1400.severity = suggestion
# SA1408: Conditional expressions should declare precedence
dotnet_diagnostic.SA1408.severity = suggestion
# SA1500: Braces for multi-line statements should not share line
dotnet_diagnostic.SA1500.severity = suggestion
# SA1505: An opening brace should not be followed by a blank line
dotnet_diagnostic.SA1505.severity = suggestion
# SA1507: Code should not contain multiple blank lines in a row
dotnet_diagnostic.SA1507.severity = suggestion
# SA1508: A closing brace should not be preceded by a blank line
dotnet_diagnostic.SA1508.severity = suggestion
# SA1513: Closing brace should be followed by blank line
dotnet_diagnostic.SA1513.severity = suggestion
# SA1518: Code should not contain blank lines at the end of the file
dotnet_diagnostic.SA1518.severity = suggestion
# SYSLIB1045: Convert to 'GeneratedRegexAttribute'.
dotnet_diagnostic.SYSLIB1045.severity = suggestion

Просмотреть файл

@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// The C++ version of these definitions is in inc\BuildInfo.hxx.

Просмотреть файл

@ -19,6 +19,7 @@
<UsePublicApiAnalyzers>true</UsePublicApiAnalyzers>
<RootNamespace />
<DefaultItemExcludes>$(DefaultItemExcludes);ref\**</DefaultItemExcludes>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>

Просмотреть файл

@ -2,9 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters.Binary;
using PresentationCore.Tests.TestUtilities;
using PresentationCore.Tests.FluentAssertions;
using System.Formats.Nrbf;

Просмотреть файл

@ -3,10 +3,7 @@
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.Serialization;
using PresentationCore.Tests.TestUtilities;
using PresentationCore.Tests.FluentAssertions;
namespace PresentationCore.Tests.BinaryFormat;

Просмотреть файл

@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using PresentationCore.Tests.TestUtilities;
using PresentationCore.Tests.FluentAssertions;
namespace PresentationCore.Tests.BinaryFormat;
@ -32,4 +31,4 @@ public class CountTests
{
((Count)5).ToString().Should().Be("5");
}
}
}

Просмотреть файл

@ -1,13 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using PresentationCore.Tests.TestUtilities;
using PresentationCore.Tests.FluentAssertions;
using System.Formats.Nrbf;
using System.Drawing;
using System.Windows;
using System.Threading;
namespace PresentationCore.Tests.BinaryFormat;
public class DataObjectTests

Просмотреть файл

@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Formats.Nrbf;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;

Просмотреть файл

@ -2,11 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections;
using System.Drawing;
using System.Runtime.Serialization.Formatters.Binary;
using System.Collections.Generic;
using System.Windows;
using FluentAssertions;
using PresentationCore.Tests.TestUtilities;
using PresentationCore.Tests.FluentAssertions;
using System.Formats.Nrbf;

Просмотреть файл

@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using PresentationCore.Tests.TestUtilities;
namespace PresentationCore.Tests.BinaryFormat;
public class NullTests

Просмотреть файл

@ -3,11 +3,6 @@
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Collections.Generic;
using System.Windows;
using FluentAssertions;
using System.IO;
using PresentationCore.Tests.TestUtilities;
using System.Globalization;
using System.Runtime.Serialization;
using System.Runtime.CompilerServices;

Просмотреть файл

@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using PresentationCore.Tests.TestUtilities;
namespace PresentationCore.Tests.BinaryFormat;
public class StringRecordsCollectionTests

Просмотреть файл

@ -1,9 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Drawing;
using PresentationCore.Tests.TestUtilities;
using PresentationCore.Tests.FluentAssertions;
using System.Formats.Nrbf;
namespace PresentationCore.Tests.BinaryFormat;

Просмотреть файл

@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Numerics;
using System;
namespace PresentationCore.Tests.FluentAssertions;

Просмотреть файл

@ -1,13 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Drawing;
using FluentAssertions;
using FluentAssertions.Collections;
using System.Collections.Generic;
using FluentAssertions.Numeric;
namespace PresentationCore.Tests.FluentAssertions;
namespace PresentationCore.Tests.FluentAssertions;
public static class FluentAssertExtensions
{

Просмотреть файл

@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Drawing;
namespace PresentationCore.Tests.FluentAssertions;
public class PointFAssertions(PointF value)

Просмотреть файл

@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Drawing;
namespace PresentationCore.Tests.FluentAssertions;
public class RectangleFAssertions(RectangleF value)
{

Просмотреть файл

@ -9,6 +9,7 @@
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
<!-- SYSLIB5005: System.Formats.Nrbf is experimental -->
<NoWarn>$(NoWarn);SYSLIB5005</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>

Просмотреть файл

@ -1,12 +1,9 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Windows;
using System.Formats.Nrbf;
namespace PresentationCore.Tests.TestUtilities;
@ -14,7 +11,7 @@ namespace PresentationCore.Tests.TestUtilities;
internal static class BinaryFormatTestExtensions
{
/// <summary>
/// Serializes the object using the <see cref="BinaryFormatter"/> and reads it into a <see cref="BinaryFormattedObject"/>.
/// Serializes the object using the <see cref="BinaryFormatter"/> and reads it into a <see cref="SerializationRecord"/>.
/// </summary>
public static SerializationRecord SerializeAndParse(this object source) => NrbfDecoder.Decode(source.Serialize());

Просмотреть файл

@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.Serialization.Formatters.Binary;
using System.Threading;
namespace System;

Просмотреть файл

@ -6,6 +6,7 @@
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<Nullable>enable</Nullable>
<Platforms>x64;x86;arm64</Platforms>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>

Просмотреть файл

@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using Xunit;
#pragma warning disable 0618
@ -14,7 +12,7 @@ public class AcceptedMarkupExtensionExpressionTypeAttributeTests
[Theory]
[InlineData(null)]
[InlineData(typeof(int))]
public void Ctor_Type(Type type)
public void Ctor_Type(Type? type)
{
var attribute = new AcceptedMarkupExtensionExpressionTypeAttribute(type);
Assert.Equal(type, attribute.Type);

Просмотреть файл

@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using System.Collections;
using System.Collections.Generic;
using Xunit;
@ -39,9 +38,9 @@ public class ArrayExtensionTests
public static IEnumerable<object[]> Ctor_Array_TestData()
{
yield return new object[] { new object[0], typeof(object) };
yield return new object[] { Array.Empty<object>(), typeof(object) };
yield return new object[] { new object[1], typeof(object) };
yield return new object[] { new int[0], typeof(int) };
yield return new object[] { Array.Empty<int>(), typeof(int) };
yield return new object[] { new int[] { 1, 2, 3, 4, 5, 6 }, typeof(int) };
yield return new object[] { new int[0, 0], typeof(int) };
yield return new object[] { new int[0, 1], typeof(int) };
@ -75,7 +74,7 @@ public class ArrayExtensionTests
[InlineData(null)]
[InlineData("string")]
[InlineData(1)]
public void AddChild_Invoke_AddsToItems(object value)
public void AddChild_Invoke_AddsToItems(object? value)
{
var extension = new ArrayExtension();
extension.AddChild(value);
@ -86,7 +85,7 @@ public class ArrayExtensionTests
[InlineData(null)]
[InlineData("")]
[InlineData("string")]
public void AddText_Invoke_AddsToItems(string text)
public void AddText_Invoke_AddsToItems(string? text)
{
var extension = new ArrayExtension();
extension.AddText(text);
@ -120,12 +119,14 @@ public class ArrayExtensionTests
[Theory]
[InlineData(null)]
[InlineData(typeof(int))]
public void Type_Set_GetReturnsExpected(Type value)
public void Type_Set_GetReturnsExpected(Type? value)
{
var extension = new ArrayExtension();
ArrayExtension extension = new()
{
// Set.
Type = value
};
// Set.
extension.Type = value;
Assert.Equal(value, extension.Type);
// Set same.

Просмотреть файл

@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using Xunit;
namespace System.Windows.Markup.Tests
@ -12,7 +11,7 @@ namespace System.Windows.Markup.Tests
[InlineData(null)]
[InlineData("")]
[InlineData("argumentName")]
public void Ctor_String(string argumentName)
public void Ctor_String(string? argumentName)
{
var attribute = new ConstructorArgumentAttribute(argumentName);
Assert.Equal(argumentName, attribute.ArgumentName);

Просмотреть файл

@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using Xunit;
namespace System.Windows.Markup.Tests;
@ -20,7 +18,7 @@ public class ContentPropertyAttributeTests
[InlineData(null)]
[InlineData("")]
[InlineData("name")]
public void Ctor_String(string name)
public void Ctor_String(string? name)
{
var attribute = new ContentPropertyAttribute(name);
Assert.Equal(name, attribute.Name);

Просмотреть файл

@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using Xunit;
@ -43,7 +42,7 @@ public class ContentWrapperAttributeTests
public void GetHashCode_Invoke_ReturnsExpected()
{
var attribute = new ContentWrapperAttribute(typeof(int));
Assert.Equal(typeof(int).GetHashCode(), attribute.GetHashCode());
Assert.Equal(typeof(int).GetHashCode(), attribute.GetHashCode());
}
[Fact]

Просмотреть файл

@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using System.Collections.Generic;
using System.Globalization;
using Xunit;
@ -10,16 +9,16 @@ namespace System.Windows.Markup.Tests;
public class DateTimeValueSerializerTests
{
public static IEnumerable<object[]> CanConvertFrom_TestData()
public static IEnumerable<object?[]> CanConvertFrom_TestData()
{
yield return new object[] { new DateTime(), true };
yield return new object[] { new object(), false };
yield return new object[] { null, false };
yield return new object?[] { new DateTime(), true };
yield return new object?[] { new object(), false };
yield return new object?[] { null, false };
}
[Theory]
[MemberData(nameof(CanConvertFrom_TestData))]
public void CanConvertToString_Invoke_ReturnsFalse(object value, bool expected)
public void CanConvertToString_Invoke_ReturnsFalse(object? value, bool expected)
{
var serializer = new DateTimeValueSerializer();
Assert.Equal(expected, serializer.CanConvertToString(value, null));
@ -42,11 +41,11 @@ public class DateTimeValueSerializerTests
var serializer = new DateTimeValueSerializer();
Assert.Equal(date.ToString(format, CultureInfo.InvariantCulture), serializer.ConvertToString(date, null));
}
[Theory]
[InlineData("notDateTime")]
[InlineData(null)]
public void ConvertToString_NotDateTime_ThrowsNotSupportedException(object value)
public void ConvertToString_NotDateTime_ThrowsNotSupportedException(object? value)
{
var serializer = new DateTimeValueSerializer();
Assert.Throws<NotSupportedException>(() => serializer.ConvertToString(value, null));
@ -81,6 +80,6 @@ public class DateTimeValueSerializerTests
public void ConvertFromString_NullString_ThrowsNotSupportedException()
{
var serializer = new DateTimeValueSerializer();
Assert.Throws<NotSupportedException>(() => serializer.ConvertFromString(null!, null));
Assert.Throws<NotSupportedException>(() => serializer.ConvertFromString(null!, null));
}
}

Просмотреть файл

@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using Xunit;
namespace System.Windows.Markup.Tests;
@ -12,7 +11,7 @@ public class DependsOnAttributeTests
[InlineData(null)]
[InlineData("")]
[InlineData("name")]
public void Ctor_String(string name)
public void Ctor_String(string? name)
{
var attribute = new DependsOnAttribute(name);
Assert.Equal(name, attribute.Name);

Просмотреть файл

@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using Xunit;
namespace System.Windows.Markup.Tests;
@ -13,7 +11,7 @@ public class DictionaryKeyPropertyAttributeTests
[InlineData(null)]
[InlineData("")]
[InlineData("name")]
public void Ctor_String(string name)
public void Ctor_String(string? name)
{
var attribute = new DictionaryKeyPropertyAttribute(name);
Assert.Equal(name, attribute.Name);

Просмотреть файл

@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Xunit;

Просмотреть файл

@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using Xunit;
#pragma warning disable 0618
@ -21,7 +20,7 @@ public class MarkupExtensionReturnTypeAttributeTests
[Theory]
[InlineData(null)]
[InlineData(typeof(int))]
public void Ctor_Type(Type returnType)
public void Ctor_Type(Type? returnType)
{
var attribute = new MarkupExtensionReturnTypeAttribute(returnType);
Assert.Equal(returnType, attribute.ReturnType);
@ -31,7 +30,7 @@ public class MarkupExtensionReturnTypeAttributeTests
[Theory]
[InlineData(null, null)]
[InlineData(typeof(int), typeof(string))]
public void Ctor_Type_Type(Type returnType, Type expressionType)
public void Ctor_Type_Type(Type? returnType, Type? expressionType)
{
var attribute = new MarkupExtensionReturnTypeAttribute(returnType, expressionType);
Assert.Equal(returnType, attribute.ReturnType);

Просмотреть файл

@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
@ -19,10 +17,10 @@ public class NameReferenceConverterTests
[InlineData(typeof(object), false)]
[InlineData(typeof(string), true)]
[InlineData(typeof(InstanceDescriptor), true)]
public void CanConvertFrom_Invoke_ReturnsExpected(Type type, bool expected)
public void CanConvertFrom_Invoke_ReturnsExpected(Type? type, bool expected)
{
var converter = new NameReferenceConverter();
Assert.Equal(expected, converter.CanConvertFrom(type));
Assert.Equal(expected, converter.CanConvertFrom(type!));
}
[Fact]
@ -47,7 +45,7 @@ public class NameReferenceConverterTests
[Theory]
[InlineData("fixup")]
[InlineData(null)]
public void ConvertFrom_ResolveUnsuccessful_ReturnsExpected(string fixup)
public void ConvertFrom_ResolveUnsuccessful_ReturnsExpected(string? fixup)
{
var converter = new NameReferenceConverter();
var context = new CustomTypeDescriptorContext
@ -58,7 +56,7 @@ public class NameReferenceConverterTests
return new CustomXamlNameResolver
{
ResolveAction = name => null!,
GetFixupTokenAction = (names, canAssignDirectly) => fixup
GetFixupTokenAction = (names, canAssignDirectly) => fixup!
};
}
};
@ -106,7 +104,7 @@ public class NameReferenceConverterTests
[InlineData(null)]
[InlineData(1)]
[InlineData("")]
public void ConvertFrom_InvalidValue_ThrowsInvalidOperationException(object value)
public void ConvertFrom_InvalidValue_ThrowsInvalidOperationException(object? value)
{
var converter = new NameReferenceConverter();
var context = new CustomTypeDescriptorContext
@ -120,9 +118,9 @@ public class NameReferenceConverterTests
Assert.Throws<InvalidOperationException>(() => converter.ConvertFrom(context, null, value));
}
public static IEnumerable<object[]> CanConvertTo_TestData()
public static IEnumerable<object?[]> CanConvertTo_TestData()
{
yield return new object[] { null, null, false };
yield return new object?[] { null, null, false };
yield return new object[] { new CustomTypeDescriptorContext { GetServiceAction = serviceType => null! }, typeof(string), false };
yield return new object[] { new CustomTypeDescriptorContext { GetServiceAction = serviceType => new object() }, typeof(string), false };
yield return new object[] { new CustomTypeDescriptorContext { GetServiceAction = serviceType => new CustomXamlNameProvider() }, typeof(int), false };
@ -140,7 +138,7 @@ public class NameReferenceConverterTests
[Theory]
[InlineData(null)]
[InlineData("name")]
public void ConvertTo_ValidService_ReturnsExpected(string name)
public void ConvertTo_ValidService_ReturnsExpected(string? name)
{
var converter = new NameReferenceConverter();
var context = new CustomTypeDescriptorContext
@ -150,7 +148,7 @@ public class NameReferenceConverterTests
Assert.Equal(typeof(IXamlNameProvider), serviceType);
return new CustomXamlNameProvider
{
GetNameAction = value => name
GetNameAction = value => name!
};
}
};
@ -202,16 +200,11 @@ public class NameReferenceConverterTests
public PropertyDescriptor PropertyDescriptor => throw new NotImplementedException();
public Func<Type, object> GetServiceAction { get; set; }
public Func<Type, object>? GetServiceAction { get; set; }
public object GetService(Type serviceType)
{
if (GetServiceAction is null)
{
throw new NotImplementedException();
}
return GetServiceAction(serviceType);
return GetServiceAction is null ? throw new NotImplementedException() : GetServiceAction(serviceType);
}
public void OnComponentChanged() => throw new NotImplementedException();
@ -223,24 +216,19 @@ public class NameReferenceConverterTests
{
public bool IsFixupTokenAvailable => throw new NotImplementedException();
public Func<string, object> ResolveAction { get; set; }
public Func<string, object>? ResolveAction { get; set; }
public object Resolve(string name)
{
if (ResolveAction is null)
{
throw new NotImplementedException();
}
return ResolveAction(name);
return ResolveAction is null ? throw new NotImplementedException() : ResolveAction(name);
}
public object Resolve(string name, out bool isFullyInitialized) => throw new NotImplementedException();
public object GetFixupToken(IEnumerable<string> names) => throw new NotImplementedException();
public Func<IEnumerable<string>, bool, object> GetFixupTokenAction { get; set; }
public Func<IEnumerable<string>, bool, object>? GetFixupTokenAction { get; set; }
public object GetFixupToken(IEnumerable<string> names, bool canAssignDirectly)
{
if (GetFixupTokenAction is null)
@ -263,16 +251,11 @@ public class NameReferenceConverterTests
private class CustomXamlNameProvider : IXamlNameProvider
{
public Func<object, string> GetNameAction { get; set; }
public Func<object, string>? GetNameAction { get; set; }
public string GetName(object value)
{
if (GetNameAction is null)
{
throw new NotImplementedException();
}
return GetNameAction(value);
return GetNameAction is null ? throw new NotImplementedException() : GetNameAction(value);
}
}
}

Просмотреть файл

@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using Xunit;
namespace System.Windows.Markup.Tests;
@ -12,7 +11,7 @@ public class NameScopePropertyAttributeTests
[InlineData(null)]
[InlineData("")]
[InlineData("name")]
public void Ctor_String(string name)
public void Ctor_String(string? name)
{
var attribute = new NameScopePropertyAttribute(name);
Assert.Equal(name, attribute.Name);
@ -23,7 +22,7 @@ public class NameScopePropertyAttributeTests
[InlineData(null, null)]
[InlineData("", typeof(int))]
[InlineData("name", typeof(string))]
public void Ctor_String_Type(string name, Type type)
public void Ctor_String_Type(string? name, Type? type)
{
var attribute = new NameScopePropertyAttribute(name, type);
Assert.Equal(name, attribute.Name);

Просмотреть файл

@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Xunit;

Просмотреть файл

@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Xunit;

Просмотреть файл

@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using System.Collections.Generic;
using System.Xaml;
using Xunit;
@ -22,7 +20,7 @@ public class ReferenceTests
[InlineData(null)]
[InlineData("")]
[InlineData("name")]
public void Ctor_String(string name)
public void Ctor_String(string? name)
{
var reference = new Reference(name);
Assert.Equal(name, reference.Name);
@ -46,7 +44,7 @@ public class ReferenceTests
[Theory]
[InlineData("fixup")]
[InlineData(null)]
public void ProvideValue_ResolveUnsuccessful_ReturnsExpected(string fixup)
public void ProvideValue_ResolveUnsuccessful_ReturnsExpected(string? fixup)
{
var reference = new Reference("name");
@ -55,7 +53,7 @@ public class ReferenceTests
ServiceAction = serviceType => new CustomXamlNameResolver
{
ResolveAction = name => null!,
GetFixupTokenAction = (names, canAssignDirectly) => fixup
GetFixupTokenAction = (names, canAssignDirectly) => fixup!
}
};
Assert.Equal(fixup, reference.ProvideValue(provider));
@ -71,12 +69,12 @@ public class ReferenceTests
[Theory]
[InlineData(null)]
[InlineData("string")]
public void ProvideValue_NonIXamlNameResolverProvider_ThrowsInvalidOperationException(object value)
public void ProvideValue_NonIXamlNameResolverProvider_ThrowsInvalidOperationException(object? value)
{
var reference = new Reference("name");
var provider = new CustomServiceProvider
{
ServiceAction = serviceType => value
ServiceAction = serviceType => value!
};
Assert.Throws<InvalidOperationException>(() => reference.ProvideValue(provider));
}
@ -84,7 +82,7 @@ public class ReferenceTests
[Theory]
[InlineData(null)]
[InlineData("")]
public void ProvideValue_NullOrEmptyName_ThrowsInvalidOperationException(string name)
public void ProvideValue_NullOrEmptyName_ThrowsInvalidOperationException(string? name)
{
var reference = new Reference(name);
var provider = new CustomServiceProvider
@ -93,57 +91,36 @@ public class ReferenceTests
};
Assert.Throws<InvalidOperationException>(() => reference.ProvideValue(provider));
}
private class CustomServiceProvider : IServiceProvider
{
public Func<Type, object> ServiceAction { get; set; }
public Func<Type, object>? ServiceAction { get; set; }
public object GetService(Type serviceType)
{
if (ServiceAction is null)
{
throw new NotImplementedException();
}
return ServiceAction(serviceType);
}
public object GetService(Type serviceType) =>
ServiceAction is null ? throw new NotImplementedException() : ServiceAction(serviceType);
}
private class CustomXamlNameResolver : IXamlNameResolver
{
public bool IsFixupTokenAvailable => throw new NotImplementedException();
public Func<string, object> ResolveAction { get; set; }
public Func<string, object>? ResolveAction { get; set; }
public object Resolve(string name)
{
if (ResolveAction is null)
{
throw new NotImplementedException();
}
return ResolveAction(name);
}
public object Resolve(string name) =>
ResolveAction is null ? throw new NotImplementedException() : ResolveAction(name);
public object Resolve(string name, out bool isFullyInitialized) => throw new NotImplementedException();
public object GetFixupToken(IEnumerable<string> names) => throw new NotImplementedException();
public Func<IEnumerable<string>, bool, object> GetFixupTokenAction { get; set; }
public object GetFixupToken(IEnumerable<string> names, bool canAssignDirectly)
{
if (GetFixupTokenAction is null)
{
throw new NotImplementedException();
}
public Func<IEnumerable<string>, bool, object>? GetFixupTokenAction { get; set; }
return GetFixupTokenAction(names, canAssignDirectly);
}
public object GetFixupToken(IEnumerable<string> names, bool canAssignDirectly) =>
GetFixupTokenAction is null ? throw new NotImplementedException() : GetFixupTokenAction(names, canAssignDirectly);
public IEnumerable<KeyValuePair<string, object>> GetAllNamesAndValuesInScope()
=> throw new NotImplementedException();
public IEnumerable<KeyValuePair<string, object>> GetAllNamesAndValuesInScope() =>
throw new NotImplementedException();
public event EventHandler OnNameScopeInitializationComplete
{

Просмотреть файл

@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using Xunit;
namespace System.Windows.Markup.Tests;
@ -12,7 +11,7 @@ public class RootNamespaceAttributeTests
[InlineData(null)]
[InlineData("")]
[InlineData("nameSpace")]
public void Ctor_String(string nameSpace)
public void Ctor_String(string? nameSpace)
{
var attribute = new RootNamespaceAttribute(nameSpace);
Assert.Equal(nameSpace, attribute.Namespace);

Просмотреть файл

@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using Xunit;
namespace System.Windows.Markup.Tests;
@ -12,7 +11,7 @@ public class RuntimeNamePropertyAttributeTests
[InlineData(null)]
[InlineData("")]
[InlineData("name")]
public void Ctor_String(string name)
public void Ctor_String(string? name)
{
var attribute = new RuntimeNamePropertyAttribute(name);
Assert.Equal(name, attribute.Name);

Просмотреть файл

@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Linq;
@ -123,12 +122,12 @@ public class StaticExtensionTests
[Theory]
[InlineData(1)]
[InlineData(null)]
public void ProvideValue_InvalidTypeResolver_ThrowsArgumentException(object service)
public void ProvideValue_InvalidTypeResolver_ThrowsArgumentException(object? service)
{
var extension = new StaticExtension("type.member");
var provider = new CustomServiceProvider
{
ServiceAction = serviceType => service
ServiceAction = serviceType => service!
};
Assert.Throws<ArgumentException>(() => extension.ProvideValue(provider));
}
@ -202,7 +201,7 @@ public class StaticExtensionTests
[InlineData(typeof(string), true)]
[InlineData(typeof(int), false)]
[InlineData(null, false)]
public void StaticExtensionConverter_CanConvertTo_ReturnsExpected(Type type, bool expected)
public void StaticExtensionConverter_CanConvertTo_ReturnsExpected(Type? type, bool expected)
{
var extension = new StaticExtension("member");
TypeConverter converter = TypeDescriptor.GetConverter(extension);
@ -243,54 +242,56 @@ public class StaticExtensionTests
TypeConverter converter = TypeDescriptor.GetConverter(extension);
Assert.Throws<NotSupportedException>(() => converter.ConvertTo(extension, typeof(int)));
}
private class CustomServiceProvider : IServiceProvider
{
public Func<Type, object> ServiceAction { get; set; }
public Func<Type, object>? ServiceAction { get; set; }
public object GetService(Type serviceType)
{
if (ServiceAction is null)
{
throw new NotImplementedException();
}
return ServiceAction(serviceType);
}
public object GetService(Type serviceType) =>
ServiceAction is null ? throw new NotImplementedException() : ServiceAction(serviceType);
}
private class CustomXamlTypeResolver : IXamlTypeResolver
{
public Func<string, Type> ResolveAction { get; set; }
public Type Resolve(string qualifiedTypeName)
{
if (ResolveAction is null)
{
throw new NotImplementedException();
}
public Func<string, Type>? ResolveAction { get; set; }
return ResolveAction(qualifiedTypeName);
}
public Type Resolve(string qualifiedTypeName) =>
ResolveAction is null ? throw new NotImplementedException() : ResolveAction(qualifiedTypeName);
}
public class BaseType
{
#pragma warning disable CA2211 // Non-constant fields should not be visible
public static int s_inheritedField = 1;
#pragma warning disable IDE1006 // Naming Styles
public static int InheritedProperty = 2;
#pragma warning restore IDE1006
#pragma warning restore CA2211
}
#pragma warning disable 0169
#pragma warning disable CA1051 // Do not declare visible instance fields
public class CustomType : BaseType
{
#pragma warning disable CA2211 // Non-constant fields should not be visible
public static int s_field = 3;
#pragma warning restore CA2211
public static int StaticProperty { get; set; } = 4;
#pragma warning disable CA1823 // Avoid unused private fields
#pragma warning disable IDE0044 // Add readonly modifier
#pragma warning disable IDE0051 // Remove unused private members
private static int s_privateField;
#pragma warning restore IDE0051
#pragma warning restore IDE0044
#pragma warning restore CA1823
public int _field;
#pragma warning disable IDE0051 // Remove unused private members
private static int PrivateStaticProperty { get; set; }
#pragma warning restore IDE0051
public int Property { get; set; }
}
#pragma warning restore CA1051
#pragma warning restore 0169
}

Просмотреть файл

@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using Xunit;
namespace System.Windows.Markup.Tests;
@ -25,7 +24,7 @@ public class StringValueSerializerTests
[Theory]
[InlineData(null)]
[InlineData("value")]
public void GetSerializerFor_StringConvertToString_ReturnsValue(object value)
public void GetSerializerFor_StringConvertToString_ReturnsValue(object? value)
{
ValueSerializer serializer = ValueSerializer.GetSerializerFor(typeof(string))!;
Assert.Equal(value, serializer.ConvertToString(value, null));
@ -41,9 +40,9 @@ public class StringValueSerializerTests
[Theory]
[InlineData(null)]
[InlineData("value")]
public void GetSerializerFor_StringConvertFromString_ReturnsValue(string value)
public void GetSerializerFor_StringConvertFromString_ReturnsValue(string? value)
{
ValueSerializer serializer = ValueSerializer.GetSerializerFor(typeof(string))!;
Assert.Equal(value, serializer.ConvertFromString(value, null));
Assert.Equal(value, serializer.ConvertFromString(value!, null));
}
}

Просмотреть файл

@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Xunit;

Просмотреть файл

@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Linq;
@ -95,12 +93,12 @@ public class TypeExtensionTests
[Theory]
[InlineData(1)]
[InlineData(null)]
public void ProvideValue_InvalidTypeResolver_ThrowsInvalidOperationException(object service)
public void ProvideValue_InvalidTypeResolver_ThrowsInvalidOperationException(object? service)
{
var extension = new TypeExtension("typeName");
var provider = new CustomServiceProvider
{
ServiceAction = serviceType => service
ServiceAction = serviceType => service!
};
Assert.Throws<InvalidOperationException>(() => extension.ProvideValue(provider));
}
@ -164,7 +162,7 @@ public class TypeExtensionTests
[InlineData(typeof(string), true)]
[InlineData(typeof(int), false)]
[InlineData(null, false)]
public void TypeExtensionConverter_CanConvertTo_ReturnsExpected(Type type, bool expected)
public void TypeExtensionConverter_CanConvertTo_ReturnsExpected(Type? type, bool expected)
{
var extension = new TypeExtension("member");
TypeConverter converter = TypeDescriptor.GetConverter(extension);
@ -208,31 +206,17 @@ public class TypeExtensionTests
private class CustomServiceProvider : IServiceProvider
{
public Func<Type, object> ServiceAction { get; set; }
public Func<Type, object>? ServiceAction { get; set; }
public object GetService(Type serviceType)
{
if (ServiceAction is null)
{
throw new NotImplementedException();
}
return ServiceAction(serviceType);
}
public object GetService(Type serviceType) =>
ServiceAction is null ? throw new NotImplementedException() : ServiceAction(serviceType);
}
private class CustomXamlTypeResolver : IXamlTypeResolver
{
public Func<string, Type> ResolveAction { get; set; }
public Func<string, Type>? ResolveAction { get; set; }
public Type Resolve(string qualifiedTypeName)
{
if (ResolveAction is null)
{
throw new NotImplementedException();
}
return ResolveAction(qualifiedTypeName);
}
public Type Resolve(string qualifiedTypeName) =>
ResolveAction is null ? throw new NotImplementedException() : ResolveAction(qualifiedTypeName);
}
}

Просмотреть файл

@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using Xunit;
namespace System.Windows.Markup.Tests;
@ -12,7 +11,7 @@ public class UidPropertyAttributeTests
[InlineData(null)]
[InlineData("")]
[InlineData("name")]
public void Ctor_String(string name)
public void Ctor_String(string? name)
{
var attribute = new UidPropertyAttribute(name);
Assert.Equal(name, attribute.Name);

Просмотреть файл

@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Xunit;

Просмотреть файл

@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.ComponentModel;
@ -8,7 +7,7 @@ using System.Globalization;
using Xunit;
namespace System.Windows.Markup.Tests;
public class ValueSerializerTests
{
public static IEnumerable<object?[]> CanConvertToString_TestData()
@ -440,7 +439,7 @@ public class ValueSerializerTests
public ValueSerializer? SerializerResult { get; set; }
public ValueSerializer? GetValueSerializerFor(Type type) => SerializerResult;
public ValueSerializer? GetValueSerializerFor(PropertyDescriptor type) => SerializerResult;
public IContainer Container => throw new NotImplementedException();
@ -459,9 +458,9 @@ public class ValueSerializerTests
public class CustomTypeConverter : TypeConverter
{
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? sourceType)
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
{
Assert.Equal(typeof(string), sourceType);
Assert.Equal(typeof(string), destinationType);
return true;
}
@ -484,7 +483,7 @@ public class CustomTypeConverter : TypeConverter
public class CannotConvertToTypeConverter : TypeConverter
{
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? sourceType)
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
{
return false;
}
@ -497,7 +496,7 @@ public class CannotConvertToTypeConverter : TypeConverter
public class CannotConvertFromTypeConverter : TypeConverter
{
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? sourceType)
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
{
return true;
}
@ -519,7 +518,7 @@ internal class InternalClass : TypeConverter
public class NestedPublicClass { }
}
class PrivateClass : TypeConverter
internal class PrivateClass : TypeConverter
{
public class NestedPublicClass { }
}

Просмотреть файл

@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Xunit;

Просмотреть файл

@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using System.IO;
using System.Xml;
using Xunit;
@ -21,7 +20,7 @@ public class XDataTests
[InlineData(null)]
[InlineData("")]
[InlineData("text")]
public void Text_Set_GetReturnsExpected(string value)
public void Text_Set_GetReturnsExpected(string? value)
{
var data = new XData { Text = value };
Assert.Equal(value, data.Text);

Просмотреть файл

@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Xunit;

Просмотреть файл

@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using Xunit;
namespace System.Windows.Markup.Tests;
@ -12,7 +11,7 @@ public class XamlSetMarkupExtensionAttributeTests
[InlineData(null)]
[InlineData("")]
[InlineData("xamlSetMarkupExtensionHandler")]
public void Ctor_String(string xamlSetMarkupExtensionHandler)
public void Ctor_String(string? xamlSetMarkupExtensionHandler)
{
var attribute = new XamlSetMarkupExtensionAttribute(xamlSetMarkupExtensionHandler);
Assert.Equal(xamlSetMarkupExtensionHandler, attribute.XamlSetMarkupExtensionHandler);

Просмотреть файл

@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Xaml;

Просмотреть файл

@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using Xunit;
namespace System.Windows.Markup.Tests;
@ -12,7 +11,7 @@ public class XamlSetTypeConverterAttributeTests
[InlineData(null)]
[InlineData("")]
[InlineData("xamlSetTypeConverterHandler")]
public void Ctor_String(string xamlSetTypeConverterHandler)
public void Ctor_String(string? xamlSetTypeConverterHandler)
{
var attribute = new XamlSetTypeConverterAttribute(xamlSetTypeConverterHandler);
Assert.Equal(xamlSetTypeConverterHandler, attribute.XamlSetTypeConverterHandler);

Просмотреть файл

@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.ComponentModel;

Просмотреть файл

@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Xaml;

Просмотреть файл

@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using Xunit;
namespace System.Windows.Markup.Tests;
@ -12,7 +11,7 @@ public class XmlLangPropertyAttributeTests
[InlineData(null)]
[InlineData("")]
[InlineData("name")]
public void Ctor_String(string name)
public void Ctor_String(string? name)
{
var attribute = new XmlLangPropertyAttribute(name);
Assert.Equal(name, attribute.Name);

Просмотреть файл

@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Xunit;

Просмотреть файл

@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Xunit;

Просмотреть файл

@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Xunit;

Просмотреть файл

@ -2,4 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
global using Xunit;
#pragma warning disable IDE0005 // Using directive is unnecessary. New project, this will be used.
global using FluentAssertions;
#pragma warning restore IDE0005

Просмотреть файл

@ -5,6 +5,7 @@
<Platforms>x64;x86;arm64</Platforms>
<RootNamespace />
<TargetFramework Condition="!$(TargetFramework.Contains('windows'))">$(TargetFramework)-windows</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>