Skip to content

Commit

Permalink
Merge branch 'main' into 67697-UnscopedRef-Property
Browse files Browse the repository at this point in the history
  • Loading branch information
jjonescz committed Apr 17, 2023
2 parents 2227aaf + 9f323e7 commit 6c9adcd
Show file tree
Hide file tree
Showing 154 changed files with 4,118 additions and 1,427 deletions.
5 changes: 5 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -389,3 +389,8 @@ stages:

- script: ./eng/build.sh --solution Roslyn.sln --restore --build --configuration Debug --prepareMachine --ci --binaryLog --runanalyzers --warnaserror /p:RoslynEnforceCodeStyle=true
displayName: Build with analyzers

- template: eng/pipelines/publish-logs.yml
parameters:
jobName: Correctness_Analyzers
configuration: Debug
1 change: 1 addition & 0 deletions docs/Language Feature Status.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ efforts behind them.

| Feature | Branch | State | Developer | Reviewer | LDM Champ |
| ------- | ------ | ----- | --------- | -------- | --------- |
| [Inline Arrays](https://github.com/dotnet/csharplang/blob/main/proposals/inline-arrays.md) | [InlineArrays](https://github.com/dotnet/roslyn/tree/features/InlineArrays) | [In Progress](https://github.com/dotnet/roslyn/issues/67826) | [AlekseyTs](https://github.com/AlekseyTs) | [cston](https://github.com/cston), [jjonescz](https://github.com/jjonescz) | |
| [Using aliases for any type](https://github.com/dotnet/csharplang/issues/4284) | [UsingAliasTypes](https://github.com/dotnet/roslyn/tree/features/UsingAliasTypes) | [Merged into 17.6.P3](https://github.com/dotnet/roslyn/issues/56323) | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) | [jcouv](https://github.com/jcouv) [cston](https://github.com/cston) | |
| [Primary Constructors](https://github.com/dotnet/csharplang/issues/2691) | [PrimaryConstructors](https://github.com/dotnet/roslyn/tree/features/PrimaryConstructors) | [Merged into 17.6.P2](https://github.com/dotnet/roslyn/issues/65697) | [AlekseyTs](https://github.com/AlekseyTs) | [cston](https://github.com/cston), [jjonescz](https://github.com/jjonescz) | [MadsTorgersen](https://github.com/MadsTorgersen) |
| [Semi-auto-properties](https://github.com/dotnet/csharplang/issues/140) | [semi-auto-props](https://github.com/dotnet/roslyn/tree/features/semi-auto-props) | [In Progress](https://github.com/dotnet/roslyn/issues/57012) | [Youssef1313](https://github.com/Youssef1313) | [333fred](https://github.com/333fred), [RikkiGibson](https://github.com/RikkiGibson) | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) |
Expand Down
66 changes: 57 additions & 9 deletions eng/targets/Settings.props
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,63 @@
<EnforceExtendedAnalyzerRules Condition="'$(IsAnalyzer)' == 'true'">true</EnforceExtendedAnalyzerRules>
</PropertyGroup>

<PropertyGroup>
<SourceBuildTargetFrameworks>net6.0</SourceBuildTargetFrameworks>
<SourceBuildTargetFrameworks Condition="'$(ContinuousIntegrationBuild)' == 'true'">net8.0;$(SourceBuildTargetFrameworks)</SourceBuildTargetFrameworks>
<SourceBuildTargetFrameworks Condition="'$(DotNetBuildFromSource)' == 'true'">net8.0</SourceBuildTargetFrameworks>
<!--
There are effectively four modes that are needed for our source build TFMs and this is where
we calculate them
-->
<Choose>
<!--
1. CI source build leg: this needs to build the current and previous source build TFM. Both are
necessary as the output of this leg is used in other CI source build legs. Those could be
targeting NetCurrent or NetPrevious hence we must produce both.
However the toolset package we produce must target NetPrevious. This package gets used as the
bootstrap toolset in other repos doing (1). Those can be using a NetPrevious runtime hence
the toolset must support that.
-->
<When Condition="'$(DotNetBuildFromSource)' == 'true' AND '$(DotNetBuildFromSourceFlavor)' != 'Product'">
<PropertyGroup>
<SourceBuildToolsetTargetFramework>$(NetPrevious)</SourceBuildToolsetTargetFramework>
<SourceBuildToolsetTargetFrameworks>$(SourceBuildToolsetTargetFramework)</SourceBuildToolsetTargetFrameworks>
<SourceBuildTargetFrameworks>$(NetCurrent);$(NetPrevious)</SourceBuildTargetFrameworks>
</PropertyGroup>
</When>

<SourceBuildTargetFrameworksNetFx>$(SourceBuildTargetFrameworks)</SourceBuildTargetFrameworksNetFx>
<SourceBuildTargetFrameworksNetFx Condition="'$(DotNetBuildFromSource)' != 'true'">$(SourceBuildTargetFrameworksNetFx);net472</SourceBuildTargetFrameworksNetFx>
</PropertyGroup>
<!--
2. Source build the product: this is the all up build of the product which needs only NetCurrent
-->
<When Condition="'$(DotNetBuildFromSource)' == 'true' AND '$(DotNetBuildFromSourceFlavor)' == 'Product'">
<PropertyGroup>
<SourceBuildToolsetTargetFramework>$(NetCurrent)</SourceBuildToolsetTargetFramework>
<SourceBuildToolsetTargetFrameworks>$(SourceBuildToolsetTargetFramework)</SourceBuildToolsetTargetFrameworks>
<SourceBuildTargetFrameworks>$(NetCurrent)</SourceBuildTargetFrameworks>
</PropertyGroup>
</When>

<!--
3. CI normal leg: this needs to build the union of all TFMs we support. That ensures we handle all
diagnostics and analyzers for all the TFMs that we support.
-->
<When Condition="'$(ContinuousIntegrationBuild)' == 'true'">
<PropertyGroup>
<SourceBuildToolsetTargetFramework>net6.0</SourceBuildToolsetTargetFramework>
<SourceBuildToolsetTargetFrameworks>$(NetCurrent);$(NetPrevious);$(SourceBuildToolsetTargetFramework)</SourceBuildToolsetTargetFrameworks>
<SourceBuildTargetFrameworks>$(SourceBuildToolsetTargetFrameworks)</SourceBuildTargetFrameworks>
</PropertyGroup>
</When>

<!--
4. Developer build: we do not want to build TFMs that are necessary only for source build as
it increases build time.
-->
<Otherwise>
<PropertyGroup>
<SourceBuildToolsetTargetFramework>net6.0</SourceBuildToolsetTargetFramework>
<SourceBuildToolsetTargetFrameworks>$(SourceBuildToolsetTargetFramework);net7.0</SourceBuildToolsetTargetFrameworks>
<SourceBuildTargetFrameworks>$(SourceBuildToolsetTargetFrameworks)</SourceBuildTargetFrameworks>
</PropertyGroup>
</Otherwise>
</Choose>

<!--
Disable Source Link and Xliff in WPF temp projects to avoid generating non-deterministic file names to obj dir.
Expand Down Expand Up @@ -149,8 +198,7 @@
-->
<ItemGroup Condition="'$(DotNetBuildFromSource)' != 'true'">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="$(MicrosoftCodeAnalysisNetAnalyzersVersion)" PrivateAssets="all" />
<!-- Disabled in net8.0 until https://github.com/dotnet/roslyn-analyzers/issues/6059 is resolved. -->
<PackageReference Include="Roslyn.Diagnostics.Analyzers" Version="$(RoslynDiagnosticsAnalyzersVersion)" Condition="'$(TargetFramework)' != 'net8.0'" PrivateAssets="all" />
<PackageReference Include="Roslyn.Diagnostics.Analyzers" Version="$(RoslynDiagnosticsAnalyzersVersion)" PrivateAssets="all" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="$(MicrosoftVisualStudioThreadingAnalyzersVersion)" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers" Version="$(MicrosoftCodeAnalysisPerformanceSensitiveAnalyzersVersion)" PrivateAssets="all" />
</ItemGroup>
Expand Down
7 changes: 4 additions & 3 deletions src/Compilers/CSharp/Portable/Binder/Binder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -739,21 +739,22 @@ internal static void ReportDiagnosticsIfObsoleteInternal(BindingDiagnosticBag di
}
}

internal static void ReportDiagnosticsIfUnmanagedCallersOnly(BindingDiagnosticBag diagnostics, MethodSymbol symbol, Location location, bool isDelegateConversion)
internal static void ReportDiagnosticsIfUnmanagedCallersOnly(BindingDiagnosticBag diagnostics, MethodSymbol symbol, SyntaxNodeOrToken syntax, bool isDelegateConversion)
{
var unmanagedCallersOnlyAttributeData = symbol.GetUnmanagedCallersOnlyAttributeData(forceComplete: false);
if (unmanagedCallersOnlyAttributeData != null)
{
// Either we haven't yet bound the attributes of this method, or there is an UnmanagedCallersOnly present.
// In the former case, we use a lazy diagnostic that may end up being ignored later, to avoid causing a
// binding cycle.
Debug.Assert(syntax.GetLocation() != null);
diagnostics.Add(unmanagedCallersOnlyAttributeData == UnmanagedCallersOnlyAttributeData.Uninitialized
? (DiagnosticInfo)new LazyUnmanagedCallersOnlyMethodCalledDiagnosticInfo(symbol, isDelegateConversion)
? new LazyUnmanagedCallersOnlyMethodCalledDiagnosticInfo(symbol, isDelegateConversion)
: new CSDiagnosticInfo(isDelegateConversion
? ErrorCode.ERR_UnmanagedCallersOnlyMethodsCannotBeConvertedToDelegate
: ErrorCode.ERR_UnmanagedCallersOnlyMethodsCannotBeCalledDirectly,
symbol),
location);
syntax.GetLocation()!);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ private Symbol GetMemberSymbol(string memberName, TextSpan memberSpan, NamedType
{
Debug.Assert(kind is SymbolKind.Method or SymbolKind.Property or SymbolKind.Event);

if (container is SourceMemberContainerTypeSymbol { PrimaryConstructor: not null } sourceMemberContainerTypeSymbol)
if (container is SourceMemberContainerTypeSymbol { HasPrimaryConstructor: true } sourceMemberContainerTypeSymbol)
{
foreach (Symbol sym in sourceMemberContainerTypeSymbol.GetMembersToMatchAgainstDeclarationSpan())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal partial class Binder
{
private BoundExpression BindAnonymousObjectCreation(AnonymousObjectCreationExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
MessageID.IDS_FeatureAnonymousTypes.CheckFeatureAvailability(diagnostics, node, node.NewKeyword.GetLocation());
MessageID.IDS_FeatureAnonymousTypes.CheckFeatureAvailability(diagnostics, node.NewKeyword);

// prepare
var initializers = node.Initializers;
Expand Down
3 changes: 1 addition & 2 deletions src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ internal static void BindAttributeTypes(
// Check the attribute type (unless the attribute type is already an error).
if (boundTypeSymbol.TypeKind != TypeKind.Error)
{
var location = attributeToBind.Name.GetLocation();
binder.CheckDisallowedAttributeDependentType(boundType, location, diagnostics);
binder.CheckDisallowedAttributeDependentType(boundType, attributeToBind.Name, diagnostics);
}

boundAttributeTypes[i] = boundTypeSymbol;
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/Binder/Binder_Await.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal partial class Binder
{
private BoundExpression BindAwait(AwaitExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
MessageID.IDS_FeatureAsync.CheckFeatureAvailability(diagnostics, node, node.AwaitKeyword.GetLocation());
MessageID.IDS_FeatureAsync.CheckFeatureAvailability(diagnostics, node.AwaitKeyword);

BoundExpression expression = BindRValueWithoutTargetType(node.Expression, diagnostics);

Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/Binder/Binder_Conversions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1477,7 +1477,7 @@ private bool MethodGroupConversionHasErrors(
CheckValidScopedMethodConversion(syntax, selectedMethod, delegateOrFuncPtrType, isExtensionMethod, diagnostics);
if (!isAddressOf)
{
ReportDiagnosticsIfUnmanagedCallersOnly(diagnostics, selectedMethod, location, isDelegateConversion: true);
ReportDiagnosticsIfUnmanagedCallersOnly(diagnostics, selectedMethod, syntax, isDelegateConversion: true);
}
ReportDiagnosticsIfObsolete(diagnostics, selectedMethod, syntax, hasBaseReceiver: false);

Expand Down
Loading

0 comments on commit 6c9adcd

Please sign in to comment.