Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more interceptors tests #68462

Merged
merged 7 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Compilers/CSharp/Portable/CSharpResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -7592,4 +7592,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="ERR_InterceptorCannotInterceptNameof" xml:space="preserve">
<value>A nameof operator cannot be intercepted.</value>
</data>
<data name="ERR_InterceptorCannotUseUnmanagedCallersOnly" xml:space="preserve">
<value>An interceptor cannot be marked with 'UnmanagedCallersOnlyAttribute'.</value>
</data>
</root>
50 changes: 25 additions & 25 deletions src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2192,31 +2192,31 @@ internal enum ErrorCode
ERR_ConstantValueOfTypeExpected = 9135,
ERR_UnsupportedPrimaryConstructorParameterCapturingRefAny = 9136,

// PROTOTYPE(ic): pack errors
ERR_InterceptorsFeatureNotEnabled = 27000,
ERR_InterceptorCannotBeGeneric = 27001,
ERR_InterceptorPathNotInCompilation = 27002,
ERR_InterceptorPathNotInCompilationWithCandidate = 27003,
ERR_InterceptorPositionBadToken = 27004,
ERR_InterceptorLineOutOfRange = 27005,
ERR_InterceptorCharacterOutOfRange = 27006,
ERR_InterceptorSignatureMismatch = 27007,
ERR_InterceptorPathNotInCompilationWithUnmappedCandidate = 27008,
ERR_InterceptorMethodMustBeOrdinary = 27009,
ERR_InterceptorMustReferToStartOfTokenPosition = 27010,
ERR_InterceptorMustHaveMatchingThisParameter = 27011,
ERR_InterceptorMustNotHaveThisParameter = 27012,
ERR_InterceptorFilePathCannotBeNull = 27013,
ERR_InterceptorNameNotInvoked = 27014,
ERR_InterceptorNonUniquePath = 27015,
ERR_DuplicateInterceptor = 27016,
WRN_InterceptorSignatureMismatch = 27017,
ERR_InterceptorNotAccessible = 27018,
ERR_InterceptorScopedMismatch = 27019,
ERR_InterceptorLineCharacterMustBePositive = 27020,
WRN_NullabilityMismatchInReturnTypeOnInterceptor = 27021,
WRN_NullabilityMismatchInParameterTypeOnInterceptor = 27022,
ERR_InterceptorCannotInterceptNameof = 27023,
ERR_InterceptorsFeatureNotEnabled = 9137,
ERR_InterceptorCannotBeGeneric = 9138,
ERR_InterceptorPathNotInCompilation = 9139,
ERR_InterceptorPathNotInCompilationWithCandidate = 9140,
ERR_InterceptorPositionBadToken = 9141,
ERR_InterceptorLineOutOfRange = 9142,
ERR_InterceptorCharacterOutOfRange = 9143,
ERR_InterceptorSignatureMismatch = 9144,
ERR_InterceptorPathNotInCompilationWithUnmappedCandidate = 9145,
ERR_InterceptorMethodMustBeOrdinary = 9146,
ERR_InterceptorMustReferToStartOfTokenPosition = 9147,
ERR_InterceptorMustHaveMatchingThisParameter = 9148,
ERR_InterceptorMustNotHaveThisParameter = 9149,
ERR_InterceptorFilePathCannotBeNull = 9150,
ERR_InterceptorNameNotInvoked = 9151,
ERR_InterceptorNonUniquePath = 9152,
ERR_DuplicateInterceptor = 9153,
WRN_InterceptorSignatureMismatch = 9154,
ERR_InterceptorNotAccessible = 9155,
ERR_InterceptorScopedMismatch = 9156,
ERR_InterceptorLineCharacterMustBePositive = 9157,
WRN_NullabilityMismatchInReturnTypeOnInterceptor = 9158,
WRN_NullabilityMismatchInParameterTypeOnInterceptor = 9159,
ERR_InterceptorCannotInterceptNameof = 9160,
ERR_InterceptorCannotUseUnmanagedCallersOnly = 9161,

#endregion

Expand Down
1 change: 1 addition & 0 deletions src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2340,6 +2340,7 @@ internal static bool IsBuildOnlyDiagnostic(ErrorCode code)
case ErrorCode.ERR_InterceptorLineCharacterMustBePositive:
case ErrorCode.ERR_ConstantValueOfTypeExpected:
case ErrorCode.ERR_UnsupportedPrimaryConstructorParameterCapturingRefAny:
case ErrorCode.ERR_InterceptorCannotUseUnmanagedCallersOnly:
return false;
default:
// NOTE: All error codes must be explicitly handled in this switch statement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private void InterceptCallAndAdjustArguments(
{
case (not null, null):
case (not null, not null) when !methodThisParameter.Type.Equals(interceptorThisParameterForCompare.Type, TypeCompareKind.ObliviousNullableModifierMatchesAny)
|| methodThisParameter.RefKind != interceptorThisParameterForCompare.RefKind: // PROTOTYPE(ic): and ref custom modifiers are equal?
|| methodThisParameter.RefKind != interceptorThisParameterForCompare.RefKind:
RikkiGibson marked this conversation as resolved.
Show resolved Hide resolved
this._diagnostics.Add(ErrorCode.ERR_InterceptorMustHaveMatchingThisParameter, attributeLocation, methodThisParameter, method);
return;
case (null, not null):
Expand All @@ -214,8 +214,6 @@ private void InterceptCallAndAdjustArguments(
{
// Special case when intercepting an extension method call in reduced form with a non-extension.
this._diagnostics.Add(ErrorCode.ERR_InterceptorMustHaveMatchingThisParameter, attributeLocation, method.Parameters[0], method);
// PROTOTYPE(ic): use a symbol display format which includes the 'this' modifier?
//this._diagnostics.Add(ErrorCode.ERR_InterceptorMustHaveMatchingThisParameter, attributeLocation, new FormattedSymbol(method.Parameters[0], SymbolDisplayFormat.CSharpErrorMessageFormat), method);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ internal sealed class MemberSignatureComparer : IEqualityComparer<Symbol>
considerCallingConvention: false,
considerRefKindDifferences: true,
considerArity: false,
typeComparison: TypeCompareKind.AllNullableIgnoreOptions | TypeCompareKind.IgnoreTupleNames);
typeComparison: TypeCompareKind.AllNullableIgnoreOptions);

/// <summary>
/// This instance is used to check whether one member overrides another, according to the C# definition.
Expand Down Expand Up @@ -384,7 +384,7 @@ private MemberSignatureComparer(
bool considerTypeConstraints,
bool considerCallingConvention,
bool considerRefKindDifferences,
bool considerArity = true, // PROTOTYPE(ic): remove default value?
bool considerArity = true,
TypeCompareKind typeComparison = TypeCompareKind.IgnoreDynamic | TypeCompareKind.IgnoreNativeIntegers)
{
Debug.Assert(!considerExplicitlyImplementedInterfaces || considerName, "Doesn't make sense to consider interfaces separately from name.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,14 @@ private void DecodeInterceptsLocationAttribute(DecodeWellKnownAttributeArguments
return;
}

Debug.Assert(_lazyCustomAttributesBag.IsEarlyDecodedWellKnownAttributeDataComputed);
var unmanagedCallersOnly = this.GetUnmanagedCallersOnlyAttributeData(forceComplete: false);
if (unmanagedCallersOnly != null)
{
diagnostics.Add(ErrorCode.ERR_InterceptorCannotUseUnmanagedCallersOnly, attributeLocation);
return;
}

var syntaxTrees = DeclaringCompilation.SyntaxTrees;
var matchingTrees = DeclaringCompilation.GetSyntaxTreesByMappedPath(attributeFilePath);
if (matchingTrees.Count == 0)
Expand Down
5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf

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

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf

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

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf

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

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf

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

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf

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

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf

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

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf

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

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf

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

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf

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

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf

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

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf

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

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

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

Loading