Skip to content

Commit

Permalink
Merge pull request #547 from microsoft/implicitUsings
Browse files Browse the repository at this point in the history
Turn on implicit usings and apply formatting rules
  • Loading branch information
AArnott committed May 14, 2022
2 parents fe0775f + b913812 commit 14e48cf
Show file tree
Hide file tree
Showing 34 changed files with 185 additions and 247 deletions.
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<BaseOutputPath Condition=" '$(BaseOutputPath)' == '' ">$(RepoRootPath)bin\$(MSBuildProjectName)\</BaseOutputPath>
<PackageOutputPath>$(RepoRootPath)bin\Packages\$(Configuration)\</PackageOutputPath>
<LangVersion>10.0</LangVersion>
<ImplicitUsings>true</ImplicitUsings>
<Nullable>enable</Nullable>
<AnalysisLevel>latest</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
Expand Down
4 changes: 4 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
<EmbedUntrackedSources Condition=" '$(UseWPF)' == 'true' ">false</EmbedUntrackedSources>
</PropertyGroup>

<ItemGroup>
<Using Remove="System.Net.Http" />
</ItemGroup>

<Import Project="$(_WpfTempProjectNuGetFilePathNoExt).targets" Condition="'$(_WpfTempProjectNuGetFilePathNoExt)' != '' and Exists('$(_WpfTempProjectNuGetFilePathNoExt).targets')"/>
</Project>
3 changes: 1 addition & 2 deletions src/Microsoft.Windows.CsWin32/ArrayTypeHandleInfo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Runtime.InteropServices;
Expand All @@ -17,7 +16,7 @@ internal record ArrayTypeHandleInfo(TypeHandleInfo ElementType, ArrayShape Shape

internal override TypeSyntaxAndMarshaling ToTypeSyntax(TypeSyntaxSettings inputs, CustomAttributeHandleCollection? customAttributes, ParameterAttributes parameterAttributes)
{
var element = this.ElementType.ToTypeSyntax(inputs, customAttributes);
TypeSyntaxAndMarshaling element = this.ElementType.ToTypeSyntax(inputs, customAttributes);
ArrayTypeSyntax arrayType = ArrayType(element.Type, SingletonList(ArrayRankSpecifier().AddSizes(this.Shape.Sizes.Select(size => LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(size))).ToArray<ExpressionSyntax>())));
MarshalAsAttribute? marshalAs = element.MarshalAsAttribute is object ? new MarshalAsAttribute(UnmanagedType.LPArray) { ArraySubType = element.MarshalAsAttribute.Value } : null;
return new TypeSyntaxAndMarshaling(arrayType, marshalAs);
Expand Down
6 changes: 1 addition & 5 deletions src/Microsoft.Windows.CsWin32/BindingRedirects.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -40,7 +36,7 @@ internal static void ApplyBindingRedirects()
AssemblyName expected = new(args.Name);
if (LocalAssemblies.Value.TryGetValue(expected.Name, out string? path))
{
AssemblyName actual = AssemblyName.GetAssemblyName(path);
var actual = AssemblyName.GetAssemblyName(path);
if (actual.Version >= expected.Version)
{
return Assembly.LoadFile(path);
Expand Down
3 changes: 1 addition & 2 deletions src/Microsoft.Windows.CsWin32/CustomAttributeTypeProvider.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Reflection.Metadata;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
Expand All @@ -21,7 +20,7 @@ private CustomAttributeTypeProvider()
public TypeSyntax GetTypeFromReference(MetadataReader reader, TypeReferenceHandle handle, byte rawTypeKind)
{
// CONSIDER: reuse GetNestingQualifiedName (with namespace support added) here.
var tr = reader.GetTypeReference(handle);
TypeReference tr = reader.GetTypeReference(handle);
string name = reader.GetString(tr.Name);
string ns = reader.GetString(tr.Namespace);
return ParseName(ns + "." + name);
Expand Down
6 changes: 1 addition & 5 deletions src/Microsoft.Windows.CsWin32/Docs.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using MessagePack;
using Microsoft.Windows.SDK.Win32Docs;

Expand Down Expand Up @@ -41,7 +37,7 @@ public static Docs Get(string docsPath)
}

using FileStream docsStream = File.OpenRead(docsPath);
var data = MessagePackSerializer.Deserialize<Dictionary<string, ApiDetails>>(docsStream);
Dictionary<string, ApiDetails>? data = MessagePackSerializer.Deserialize<Dictionary<string, ApiDetails>>(docsStream);
var docs = new Docs(data);

lock (DocsByPath)
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.Windows.CsWin32/FastSyntaxFactory.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Globalization;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.Windows.CsWin32/GenerationFailedException.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;

namespace Microsoft.Windows.CsWin32;

/// <summary>
Expand Down
Loading

0 comments on commit 14e48cf

Please sign in to comment.