Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into forbid-inumber
Browse files Browse the repository at this point in the history
* upstream/main: (66 commits)
  Merge release/dev17.3 to main (dotnet#62573)
  Fix
  Find the right symbol when following type forwards (dotnet#62406)
  Remove unused parameter (dotnet#62685)
  Fix NRE in nullable walker (dotnet#62773)
  Delete obsolete internal options (dotnet#62746)
  Optimize away unchecked conversions between nint and nuint types. (dotnet#62774)
  Delete
  Inline members
  Clean up global options usage in tests (dotnet#62692)
  Update dependencies from https://github.com/dotnet/source-build-externals build 20220719.2 (dotnet#62787)
  Update src/Workspaces/Remote/ServiceHub/Services/Renamer/RemoteRenamerService.cs
  No need to roundtrip symbol
  Unused variable
  formatting
  Get document properly
  Lint
  Simplify
  Remove unnecessary callbacks
  Add telemetry
  ...
  • Loading branch information
333fred committed Jul 20, 2022
2 parents 17d61ef + a3c05ab commit 505bc89
Show file tree
Hide file tree
Showing 189 changed files with 3,043 additions and 1,277 deletions.
6 changes: 3 additions & 3 deletions azure-pipelines-pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ variables:
- group: DotNet-Roslyn-SDLValidation-Params
- group: DotNet-Roslyn-Insertion-Variables

# To retrieve OptProf data we need to authenticate to the VS drop storage.
# If the pipeline is running in DevDiv, the account has access to the VS drop storage.
# Get $AccessToken-dotnet-build-bot-public-repo from DotNet-GitHub-Versions-Repo-Write
- group: DotNet-GitHub-Versions-Repo-Write
# To retrieve OptProf data we need to authenticate to the VS drop storage.
# If the pipeline is running in DevDiv, the account has access to the VS drop storage.
- name: _DevDivDropAccessToken
value: $(System.AccessToken)
value: ''

stages:
- stage: build
Expand Down
8 changes: 8 additions & 0 deletions eng/Signing.props
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,13 @@
<FileSignInfo Include="Nerdbank.Streams.dll" CertificateName="3PartySHA2" />
<FileSignInfo Include="Newtonsoft.Json.dll" CertificateName="3PartySHA2" />
<FileSignInfo Include="Validation.dll" CertificateName="3PartySHA2" />

<!-- Sign VS/Microsoft dlls we crossgen'd and included in the vsix for our .NET remote host with Microsoft cert -->
<FileSignInfo Include="Microsoft.CodeAnalysis.Elfie.dll" CertificateName="MicrosoftSHA2" />
<FileSignInfo Include="Microsoft.ServiceHub.Framework.dll" CertificateName="MicrosoftSHA2" />
<FileSignInfo Include="Microsoft.VisualStudio.Composition.dll" CertificateName="MicrosoftSHA2" />
<FileSignInfo Include="Microsoft.VisualStudio.Telemetry.dll" CertificateName="MicrosoftSHA2" />
<FileSignInfo Include="Microsoft.VisualStudio.Threading.dll" CertificateName="MicrosoftSHA2" />
<FileSignInfo Include="StreamJsonRpc.dll" CertificateName="MicrosoftSHA2" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<Sha>7e80445ee82adbf9a8e6ae601ac5e239d982afaa</Sha>
<SourceBuild RepoName="xliff-tasks" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-externals" Version="7.0.0-alpha.1.22363.1">
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-externals" Version="7.0.0-alpha.1.22369.2">
<Uri>https://github.com/dotnet/source-build-externals</Uri>
<Sha>abff160e44e7b81ade066d176639fc6d78527478</Sha>
<Sha>3a88d1dbd4557702aa2cb89d5f8bf927bb263a3b</Sha>
<SourceBuild RepoName="source-build-externals" ManagedOnly="true" />
</Dependency>
</ProductDependencies>
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
repository. This must be lower than MicrosoftNetCompilersToolsetVersion,
but not higher than our minimum dogfoodable Visual Studio version, or else
the generators we build would load on the command line but not load in IDEs. -->
<SourceGeneratorMicrosoftCodeAnalysisVersion>3.8.0</SourceGeneratorMicrosoftCodeAnalysisVersion>
<SourceGeneratorMicrosoftCodeAnalysisVersion>4.1.0</SourceGeneratorMicrosoftCodeAnalysisVersion>
<MicrosoftILVerificationVersion>7.0.0-alpha.1.22060.1</MicrosoftILVerificationVersion>
<MicrosoftServiceHubVersion>3.1.4097</MicrosoftServiceHubVersion>
<MicrosoftVisualStudioThreadingPackagesVersion>17.2.32</MicrosoftVisualStudioThreadingPackagesVersion>
Expand Down
4 changes: 2 additions & 2 deletions eng/pipelines/build-windows-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ jobs:
displayName: Restore
inputs:
filePath: eng/build.ps1
arguments: -configuration ${{ parameters.configuration }} -prepareMachine -ci -restore -binaryLog
arguments: -configuration ${{ parameters.configuration }} -prepareMachine -ci -restore -binaryLog /p:UsingToolPdbConverter=false /p:UsingToolVSSDK=false /p:GenerateSatelliteAssemblies=false

- task: PowerShell@2
displayName: Build
inputs:
filePath: eng/build.ps1
arguments: -configuration ${{ parameters.configuration }} -prepareMachine -ci -build -publish -binaryLog -skipDocumentation ${{ parameters.buildArguments }}
arguments: -configuration ${{ parameters.configuration }} -prepareMachine -ci -build -binaryLog -skipDocumentation /p:UsingToolPdbConverter=false /p:UsingToolVSSDK=false /p:GenerateSatelliteAssemblies=false /p:PublishReadyToRun=false ${{ parameters.buildArguments }}

- task: PowerShell@2
displayName: Prepare Unit Tests
Expand Down
7 changes: 7 additions & 0 deletions eng/targets/DoNotDeployToSymStore_Workaround.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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. -->
<Project>
<!-- There is no way to disable this expensive target other than to override it -->
<Target Name="DeployToSymStore"
BeforeTargets="AfterBuild" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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. -->
<Project>
<!-- There is no way to disable generating satellite assemblies other than to override the target definitions -->
<Target Name="CoreGenerateSatelliteAssemblies" />
<Target Name="GenerateSatelliteAssemblies" />
</Project>
5 changes: 4 additions & 1 deletion eng/targets/Imports.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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. -->
<Project>
<Import Project="VisualStudio.targets"/>
<Import Project="VisualStudio.targets" Condition="'$(UsingToolVSSDK)' == 'true'"/>
<Import Project="XUnit.targets" Condition="'$(IsTestProject)' == 'true'" />

<!--
Expand Down Expand Up @@ -358,4 +358,7 @@
AlwaysCreate="true"
Condition="'@(ReferencesCopiedInThisBuild)' != ''"/>
</Target>

<Import Project="DoNotDeployToSymStore_Workaround.targets" Condition="'$(UsingToolPdbConverter)' == 'false'" />
<Import Project="DoNotGenerateSatelliteAssemblies_Workaround.targets" Condition="'$(GenerateSatelliteAssemblies)' == 'false'" />
</Project>
10 changes: 10 additions & 0 deletions eng/targets/Settings.props
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
Microsoft.Common.CurrentVersion.targets to see how it is consumed -->
<WindowsAppContainer>false</WindowsAppContainer>

<!-- Used to control the running of the GenerateSatelliteAssemblies and CoreGenerateSatelliteAssemblies targets -->
<GenerateSatelliteAssemblies>true</GenerateSatelliteAssemblies>

<EnableDefaultNoneItems>false</EnableDefaultNoneItems>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -53,6 +56,13 @@
<DeterministicSourcePaths>false</DeterministicSourcePaths>
<EnableXlfLocalization>false</EnableXlfLocalization>
</PropertyGroup>

<!--
Disable Xliff if it's not necessary to generate satellite assemblies.
-->
<PropertyGroup Condition="'$(GenerateSatelliteAssemblies)' == 'false'">
<EnableXlfLocalization>false</EnableXlfLocalization>
</PropertyGroup>

<PropertyGroup Condition="'$(IsTestProject)' == 'true'" >
<!--
Expand Down
4 changes: 2 additions & 2 deletions eng/targets/Vsdconfig.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="Microsoft.VSSDK.Debugger.VSDConfigTool" Version="$(MicrosoftVSSDKVSDConfigToolVersion)"
Condition="'$(IsWpfTempProject)' != 'true'">
Condition="'$(IsWpfTempProject)' != 'true' and '$(UsingToolVSSDK)' == 'true'">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<Target Name="VsdConfigOutputGroup" Outputs="@(VsdConfigOutputGroupOutput)"
Condition="'@(VsdConfigXmlFiles)'!=''"
Condition="'@(VsdConfigXmlFiles)'!='' and '$(UsingToolVSSDK)' == 'true'"
DependsOnTargets="AddVsdbgConfigFileToOutputGroup">
<ItemGroup>
<VsdConfigOutputGroupOutput Include="$(OutDir)\$(AssemblyName).vsdconfig" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@ namespace Microsoft.CodeAnalysis.CodeStyle
{
internal abstract partial class AbstractBuiltInCodeStyleDiagnosticAnalyzer : DiagnosticAnalyzer, IBuiltInAnalyzer
{
protected readonly string? DescriptorId;

protected readonly DiagnosticDescriptor Descriptor;

protected readonly LocalizableString _localizableTitle;
protected readonly LocalizableString _localizableMessageFormat;

private AbstractBuiltInCodeStyleDiagnosticAnalyzer(
string descriptorId,
EnforceOnBuild enforceOnBuild,
Expand All @@ -35,24 +30,18 @@ internal abstract partial class AbstractBuiltInCodeStyleDiagnosticAnalyzer : Dia
|| this is AbstractBuiltInUnnecessaryCodeStyleDiagnosticAnalyzer
|| this is AbstractParenthesesDiagnosticAnalyzer);

DescriptorId = descriptorId;
_localizableTitle = title;
_localizableMessageFormat = messageFormat ?? title;

Descriptor = CreateDescriptorWithId(DescriptorId, enforceOnBuild, _localizableTitle, _localizableMessageFormat, isUnnecessary: isUnnecessary, isConfigurable: configurable);
Descriptor = CreateDescriptorWithId(descriptorId, enforceOnBuild, title, messageFormat ?? title, isUnnecessary: isUnnecessary, isConfigurable: configurable);
SupportedDiagnostics = ImmutableArray.Create(Descriptor);
}

/// <summary>
/// Constructor for a code style analyzer with a multiple diagnostic descriptors such that all the descriptors have no unique code style option to configure the descriptors.
/// </summary>
protected AbstractBuiltInCodeStyleDiagnosticAnalyzer(ImmutableArray<DiagnosticDescriptor> supportedDiagnostics)
private AbstractBuiltInCodeStyleDiagnosticAnalyzer(ImmutableArray<DiagnosticDescriptor> supportedDiagnostics)
{
SupportedDiagnostics = supportedDiagnostics;

Descriptor = SupportedDiagnostics[0];
_localizableTitle = Descriptor.Title;
_localizableMessageFormat = Descriptor.MessageFormat;
}

public CodeActionRequestPriority RequestPriority => CodeActionRequestPriority.Normal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@
// 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.Immutable;
using System.IO;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Diagnostics;
using Roslyn.Utilities;
using Microsoft.CodeAnalysis.Options;

namespace Microsoft.CodeAnalysis.FileHeaders
{
internal abstract class AbstractFileHeaderDiagnosticAnalyzer : AbstractBuiltInCodeStyleDiagnosticAnalyzer
{
private static readonly LocalizableString s_invalidHeaderTitle = new LocalizableResourceString(nameof(AnalyzersResources.The_file_header_does_not_match_the_required_text), AnalyzersResources.ResourceManager, typeof(AnalyzersResources));
private static readonly LocalizableString s_invalidHeaderMessage = new LocalizableResourceString(nameof(AnalyzersResources.A_source_file_contains_a_header_that_does_not_match_the_required_text), AnalyzersResources.ResourceManager, typeof(AnalyzersResources));
private static readonly DiagnosticDescriptor s_invalidHeaderDescriptor = CreateDescriptorForFileHeader(s_invalidHeaderTitle, s_invalidHeaderMessage);

private static readonly LocalizableString s_missingHeaderTitle = new LocalizableResourceString(nameof(AnalyzersResources.The_file_header_is_missing_or_not_located_at_the_top_of_the_file), AnalyzersResources.ResourceManager, typeof(AnalyzersResources));
private static readonly LocalizableString s_missingHeaderMessage = new LocalizableResourceString(nameof(AnalyzersResources.A_source_file_is_missing_a_required_header), AnalyzersResources.ResourceManager, typeof(AnalyzersResources));
private static readonly DiagnosticDescriptor s_missingHeaderDescriptor = CreateDescriptorForFileHeader(s_missingHeaderTitle, s_missingHeaderMessage);

private static DiagnosticDescriptor CreateDescriptorForFileHeader(LocalizableString title, LocalizableString message)
=> CreateDescriptorWithId(IDEDiagnosticIds.FileHeaderMismatch, EnforceOnBuildValues.FileHeaderMismatch, title, message);

protected AbstractFileHeaderDiagnosticAnalyzer(string language)
: base(
IDEDiagnosticIds.FileHeaderMismatch,
EnforceOnBuildValues.FileHeaderMismatch,
CodeStyleOptions2.FileHeaderTemplate,
language,
new LocalizableResourceString(nameof(AnalyzersResources.The_file_header_is_missing_or_not_located_at_the_top_of_the_file), AnalyzersResources.ResourceManager, typeof(AnalyzersResources)),
new LocalizableResourceString(nameof(AnalyzersResources.A_source_file_is_missing_a_required_header), AnalyzersResources.ResourceManager, typeof(AnalyzersResources)))
: base(ImmutableDictionary<DiagnosticDescriptor, ILanguageSpecificOption>.Empty
.Add(s_invalidHeaderDescriptor, CodeStyleOptions2.FileHeaderTemplate)
.Add(s_missingHeaderDescriptor, CodeStyleOptions2.FileHeaderTemplate),
language)
{
RoslynDebug.AssertNotNull(DescriptorId);

var invalidHeaderTitle = new LocalizableResourceString(nameof(AnalyzersResources.The_file_header_does_not_match_the_required_text), AnalyzersResources.ResourceManager, typeof(AnalyzersResources));
var invalidHeaderMessage = new LocalizableResourceString(nameof(AnalyzersResources.A_source_file_contains_a_header_that_does_not_match_the_required_text), AnalyzersResources.ResourceManager, typeof(AnalyzersResources));
InvalidHeaderDescriptor = CreateDescriptorWithId(DescriptorId, EnforceOnBuildValues.FileHeaderMismatch, invalidHeaderTitle, invalidHeaderMessage);
}

protected abstract AbstractFileHeaderHelper FileHeaderHelper { get; }

internal DiagnosticDescriptor MissingHeaderDescriptor => Descriptor;

internal DiagnosticDescriptor InvalidHeaderDescriptor { get; }

public override DiagnosticAnalyzerCategory GetAnalyzerCategory()
=> DiagnosticAnalyzerCategory.SyntaxTreeWithoutSemanticsAnalysis;

Expand All @@ -59,14 +59,14 @@ private void HandleSyntaxTree(SyntaxTreeAnalysisContext context)
var fileHeader = FileHeaderHelper.ParseFileHeader(root);
if (fileHeader.IsMissing)
{
context.ReportDiagnostic(Diagnostic.Create(MissingHeaderDescriptor, fileHeader.GetLocation(tree)));
context.ReportDiagnostic(Diagnostic.Create(s_missingHeaderDescriptor, fileHeader.GetLocation(tree)));
return;
}

var expectedFileHeader = fileHeaderTemplate.Replace("{fileName}", Path.GetFileName(tree.FilePath));
if (!CompareCopyrightText(expectedFileHeader, fileHeader.CopyrightText))
{
context.ReportDiagnostic(Diagnostic.Create(InvalidHeaderDescriptor, fileHeader.GetLocation(tree)));
context.ReportDiagnostic(Diagnostic.Create(s_invalidHeaderDescriptor, fileHeader.GetLocation(tree)));
return;
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/Compilers/CSharp/Portable/CSharpResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -6637,6 +6637,12 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="WRN_AnalyzerReferencesFramework_Title" xml:space="preserve">
<value>The loaded assembly references .NET Framework, which is not supported.</value>
</data>
<data name="WRN_AnalyzerReferencesNewerCompiler" xml:space="preserve">
<value>The analyzer assembly '{0}' references version '{1}' of the compiler, which is newer than the currently running version '{2}'.</value>
</data>
<data name="WRN_AnalyzerReferencesNewerCompiler_Title" xml:space="preserve">
<value>The analyzer assembly references a newer version of the compiler than the currently running version.</value>
</data>
<data name="ERR_BadFieldTypeInRecord" xml:space="preserve">
<value>The type '{0}' may not be used for a field of a record.</value>
</data>
Expand Down
1 change: 1 addition & 0 deletions src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2105,6 +2105,7 @@ internal enum ErrorCode
ERR_FileTypeNested = 9054,
ERR_GlobalUsingStaticFileType = 9055,
ERR_FileTypeNameDisallowed = 9056,
WRN_AnalyzerReferencesNewerCompiler = 9057,
ERR_FeatureNotAvailableInVersion11 = 9058,
ERR_RefFieldInNonRefStruct = 9059,
ERR_CannotMatchOnINumberBase = 9060,
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ internal static int GetWarningLevel(ErrorCode code)
case ErrorCode.WRN_UnassignedThisAutoPropertySupportedVersion:
case ErrorCode.WRN_UnassignedThisSupportedVersion:
case ErrorCode.WRN_ObsoleteMembersShouldNotBeRequired:
case ErrorCode.WRN_AnalyzerReferencesNewerCompiler:
return 1;
default:
return 0;
Expand Down Expand Up @@ -2206,6 +2207,7 @@ internal static bool IsBuildOnlyDiagnostic(ErrorCode code)
case ErrorCode.ERR_FileTypeNameDisallowed:
case ErrorCode.ERR_FeatureNotAvailableInVersion11:
case ErrorCode.ERR_RefFieldInNonRefStruct:
case ErrorCode.WRN_AnalyzerReferencesNewerCompiler:
case ErrorCode.ERR_CannotMatchOnINumberBase:
return false;
default:
Expand Down
1 change: 1 addition & 0 deletions src/Compilers/CSharp/Portable/Errors/MessageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ internal override bool ShouldAssertExpectedMessageArgumentsLength(int errorCode)
public override int WRN_NoAnalyzerInAssembly => (int)ErrorCode.WRN_NoAnalyzerInAssembly;
public override int WRN_UnableToLoadAnalyzer => (int)ErrorCode.WRN_UnableToLoadAnalyzer;
public override int WRN_AnalyzerReferencesFramework => (int)ErrorCode.WRN_AnalyzerReferencesFramework;
public override int WRN_AnalyzerReferencesNewerCompiler => (int)ErrorCode.WRN_AnalyzerReferencesNewerCompiler;
public override int INF_UnableToLoadSomeTypesInAnalyzer => (int)ErrorCode.INF_UnableToLoadSomeTypesInAnalyzer;
public override int ERR_CantReadRulesetFile => (int)ErrorCode.ERR_CantReadRulesetFile;
public override int ERR_CompileCancelled => (int)ErrorCode.ERR_CompileCancelled;
Expand Down
4 changes: 3 additions & 1 deletion src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7875,12 +7875,13 @@ void reportBadDelegateParameter(BindingDiagnosticBag bag, MethodSymbol sourceInv
_ => (null, ImmutableArray<ParameterSymbol>.Empty),
};

#nullable enable
case ConversionKind.AnonymousFunction:
if (conversionOperand is BoundLambda lambda)
{
var delegateType = targetType.GetDelegateType();
VisitLambda(lambda, delegateType, stateForLambda);
if (reportRemainingWarnings)
if (reportRemainingWarnings && delegateType is not null)
{
ReportNullabilityMismatchWithTargetDelegate(diagnosticLocationOpt, delegateType, lambda);
}
Expand All @@ -7890,6 +7891,7 @@ void reportBadDelegateParameter(BindingDiagnosticBag bag, MethodSymbol sourceInv
return TypeWithState.Create(targetType, NullableFlowState.NotNull);
}
break;
#nullable disable

case ConversionKind.FunctionType:
resultState = NullableFlowState.NotNull;
Expand Down

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

Loading

0 comments on commit 505bc89

Please sign in to comment.