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

Do not say the wrong default behavior for blittable arrays in ComInterfaceGenerator warning #88212

Merged
merged 33 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
dc6356f
Fully qualify return type on UnreachableException methods
jtschuster Jun 15, 2023
0cc937e
Merge branch 'main' of https://github.com/dotnet/runtime
jtschuster Jun 16, 2023
a16a7d6
Merge branch 'main' of https://github.com/dotnet/runtime
jtschuster Jun 19, 2023
cca57d3
Merge branch 'main' of https://github.com/dotnet/runtime
jtschuster Jun 28, 2023
d56e81c
Merge branch 'main' of https://github.com/dotnet/runtime into InWarni…
jtschuster Jun 29, 2023
3ac3f6f
Say correct default for blittable arrays in warning
jtschuster Jun 29, 2023
e901baa
wip - SupportsByValueKind returns diag now
jtschuster Jul 6, 2023
2fd1d44
Use one resources file for all generators and tests, change byvalue attr
jtschuster Jul 6, 2023
e95fd73
Fix changes to SR names
jtschuster Jul 6, 2023
b7f4d21
[In] is allowed but not necessary
jtschuster Jul 6, 2023
2f135c2
wip
jtschuster Jul 7, 2023
5839779
wip about to merge main
jtschuster Jul 10, 2023
5b194d9
Merge branch 'main' of https://github.com/dotnet/runtime into InWarni…
jtschuster Jul 10, 2023
7d2ac74
Test cases done, filed / prepped issues for problems I hit
jtschuster Jul 10, 2023
797617a
Merge branch 'main' of https://github.com/dotnet/runtime into InWarni…
jtschuster Jul 10, 2023
a698ae2
undo unnecessary changes
jtschuster Jul 10, 2023
0a84827
Update src/libraries/System.Runtime.InteropServices/gen/Microsoft.Int…
jtschuster Jul 11, 2023
c48213e
Don't generate invalid UnmanagedCallersOnly wrappers. Instead, just s…
jkoritzinsky Jul 11, 2023
d324406
Only filter on the unmanaged to managed stub diagnostics.
jkoritzinsky Jul 11, 2023
d3f00a8
Only skip on error diagnostics (we don't want to skip generation beca…
jkoritzinsky Jul 11, 2023
b4659f1
PR Feedback
jtschuster Jul 11, 2023
53f5249
Merge remote-tracking branch 'jkoritzinsky/no-invalid-uco' into InWar…
jtschuster Jul 11, 2023
91c5b0d
PR Feedback
jtschuster Jul 11, 2023
8262e7d
Update src/libraries/System.Runtime.InteropServices/gen/Microsoft.Int…
jtschuster Jul 11, 2023
64725ae
Update src/libraries/System.Runtime.InteropServices/gen/Microsoft.Int…
jtschuster Jul 11, 2023
789a023
Update src/libraries/System.Runtime.InteropServices/gen/Microsoft.Int…
jtschuster Jul 11, 2023
acd847e
Update src/libraries/System.Runtime.InteropServices/gen/ComInterfaceG…
jtschuster Jul 11, 2023
2877315
Update src/libraries/System.Runtime.InteropServices/gen/Microsoft.Int…
jtschuster Jul 11, 2023
6536dcb
Update src/libraries/System.Runtime.InteropServices/gen/Microsoft.Int…
jtschuster Jul 11, 2023
7dfed5e
Update src/libraries/System.Runtime.InteropServices/gen/Microsoft.Int…
jtschuster Jul 11, 2023
41c11ea
Merge ref and value type default by value
jtschuster Jul 11, 2023
3ca63bc
Add issue for commented test cases
jtschuster Jul 11, 2023
f1f510c
Fix JS generator build
jtschuster Jul 12, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -2592,11 +2592,11 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\PortableThreadPool.Windows.cs" Condition="'$(TargetsWindows)' == 'true'" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\LowLevelLifoSemaphore.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\LowLevelLifoSemaphore.Windows.cs" Condition="'$(TargetsWindows)' == 'true'" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\PreAllocatedOverlapped.Windows.cs" Condition="'$(TargetsWindows)' == 'true'"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\PreAllocatedOverlapped.Windows.cs" Condition="'$(TargetsWindows)' == 'true'" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\PreAllocatedOverlapped.Unix.cs" Condition="'$(TargetsUnix)' == 'true' or '$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true'" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\PreAllocatedOverlapped.Portable.cs" Condition="('$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true') or '$(FeatureWasmThreads)' == 'true'" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\RegisteredWaitHandle.Windows.cs" Condition="'$(TargetsWindows)' == 'true'"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\RegisteredWaitHandle.Unix.cs" Condition="'$(TargetsWindows)' != 'true'"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\RegisteredWaitHandle.Windows.cs" Condition="'$(TargetsWindows)' == 'true'" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\RegisteredWaitHandle.Unix.cs" Condition="'$(TargetsWindows)' != 'true'" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\RegisteredWaitHandle.Portable.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\LowLevelLifoSemaphoreBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadPoolBoundHandle.Portable.cs" />
Expand Down Expand Up @@ -2666,4 +2666,4 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Numerics\IUnaryPlusOperators.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Numerics\IUnsignedNumber.cs" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices.JavaScript;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
using System.Runtime.InteropServices.JavaScript;

namespace Microsoft.Interop.JavaScript
{
Expand All @@ -26,7 +26,8 @@ protected BaseJSGenerator(MarshalerType marshalerType, IMarshallingGenerator inn
public virtual bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => _inner.UsesNativeIdentifier(info, context);
public SignatureBehavior GetNativeSignatureBehavior(TypePositionInfo info) => _inner.GetNativeSignatureBehavior(info);
public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) => _inner.GetValueBoundaryBehavior(info, context);
public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => _inner.SupportsByValueMarshalKind(marshalKind, context);
public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, TypePositionInfo info, StubCodeContext context, out GeneratorDiagnostic? diagnostic)
=> _inner.SupportsByValueMarshalKind(marshalKind, info, context, out diagnostic);

public virtual IEnumerable<ExpressionSyntax> GenerateBind(TypePositionInfo info, StubCodeContext context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ internal sealed class EmptyJSGenerator : IJSMarshallingGenerator
public SignatureBehavior GetNativeSignatureBehavior(TypePositionInfo info) => SignatureBehavior.ManagedTypeAndAttributes;
public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) => ValueBoundaryBehavior.ManagedIdentifier;
public bool IsSupported(TargetFramework target, Version version) => false;
public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => ByValueMarshalKindSupport.NotSupported;
public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, TypePositionInfo info, StubCodeContext context, out GeneratorDiagnostic? diagnostic)
=> ByValueMarshalKindSupportDescriptor.ReferenceTypeParameterDefault.GetSupport(marshalKind, info, context, out diagnostic);
public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<NoWarn>RS2008;RS1038;$(NoWarn)</NoWarn>
<AnalyzerLanguage>cs</AnalyzerLanguage>
<DefineConstants>$(DefineConstants);MICROSOFT_INTEROP_COMINTERFACEGENERATOR</DefineConstants>
<StringResourcesPath>../Common/Resources/Strings.resx</StringResourcesPath>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,38 @@ public class Ids

private const string Category = "ComInterfaceGenerator";

/// <inheritdoc cref="SR.RequiresAllowUnsafeBlocksMessage"/>
/// <inheritdoc cref="SR.RequiresAllowUnsafeBlocksMessageCom"/>
public static readonly DiagnosticDescriptor RequiresAllowUnsafeBlocks =
new DiagnosticDescriptor(
Ids.RequiresAllowUnsafeBlocks,
GetResourceString(nameof(SR.RequiresAllowUnsafeBlocksTitle)),
GetResourceString(nameof(SR.RequiresAllowUnsafeBlocksMessage)),
GetResourceString(nameof(SR.RequiresAllowUnsafeBlocksTitleCom)),
GetResourceString(nameof(SR.RequiresAllowUnsafeBlocksMessageCom)),
Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.RequiresAllowUnsafeBlocksDescription)));
description: GetResourceString(nameof(SR.RequiresAllowUnsafeBlocksDescriptionCom)));

/// <inheritdoc cref="SR.InvalidAttributedMethodSignatureMessage"/>
/// <inheritdoc cref="SR.InvalidAttributedMethodSignatureMessageCom"/>
public static readonly DiagnosticDescriptor InvalidAttributedMethodSignature =
new DiagnosticDescriptor(
Ids.InvalidLibraryImportAttributeUsage,
GetResourceString(nameof(SR.InvalidVirtualMethodIndexAttributeUsage)),
GetResourceString(nameof(SR.InvalidAttributedMethodSignatureMessage)),
GetResourceString(nameof(SR.InvalidAttributedMethodSignatureMessageCom)),
Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.InvalidAttributedMethodDescription)));
description: GetResourceString(nameof(SR.InvalidAttributedMethodDescriptionCom)));

/// <inheritdoc cref="SR.InvalidAttributedMethodContainingTypeMissingModifiersMessage"/>
/// <inheritdoc cref="SR.InvalidAttributedMethodContainingTypeMissingModifiersMessageCom"/>
public static readonly DiagnosticDescriptor InvalidAttributedMethodContainingTypeMissingModifiers =
new DiagnosticDescriptor(
Ids.InvalidLibraryImportAttributeUsage,
GetResourceString(nameof(SR.InvalidVirtualMethodIndexAttributeUsage)),
GetResourceString(nameof(SR.InvalidAttributedMethodContainingTypeMissingModifiersMessage)),
GetResourceString(nameof(SR.InvalidAttributedMethodContainingTypeMissingModifiersMessageCom)),
Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.InvalidAttributedMethodDescription)));
description: GetResourceString(nameof(SR.InvalidAttributedMethodDescriptionCom)));

/// <inheritdoc cref="SR.InvalidGeneratedComInterfaceUsageMissingPartialModifier"/>
public static readonly DiagnosticDescriptor InvalidAttributedInterfaceMissingPartialModifiers =
Expand All @@ -83,7 +83,7 @@ public class Ids
Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.InvalidAttributedMethodDescription)));
description: GetResourceString(nameof(SR.InvalidAttributedMethodDescriptionCom)));

/// <inheritdoc cref="SR.InvalidStringMarshallingConfigurationOnInterfaceMessage"/>
public static readonly DiagnosticDescriptor InvalidStringMarshallingMismatchBetweenBaseAndDerived =
Expand Down Expand Up @@ -150,27 +150,27 @@ public class Ids
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.InvalidExceptionMarshallingConfigurationDescription)));

/// <inheritdoc cref="SR.InvalidExceptionMarshallingConfigurationMessage"/>
/// <inheritdoc cref="SR.TypeNotSupportedMessageParameterCom"/>
public static readonly DiagnosticDescriptor ParameterTypeNotSupported =
new DiagnosticDescriptor(
Ids.TypeNotSupported,
GetResourceString(nameof(SR.TypeNotSupportedTitle)),
GetResourceString(nameof(SR.TypeNotSupportedMessageParameter)),
GetResourceString(nameof(SR.TypeNotSupportedMessageParameterCom)),
Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.TypeNotSupportedDescription)));
description: GetResourceString(nameof(SR.TypeNotSupportedDescriptionCom)));

/// <inheritdoc cref="SR.TypeNotSupportedMessageReturn"/>
/// <inheritdoc cref="SR.TypeNotSupportedMessageReturnCom"/>
public static readonly DiagnosticDescriptor ReturnTypeNotSupported =
new DiagnosticDescriptor(
Ids.TypeNotSupported,
GetResourceString(nameof(SR.TypeNotSupportedTitle)),
GetResourceString(nameof(SR.TypeNotSupportedMessageReturn)),
GetResourceString(nameof(SR.TypeNotSupportedMessageReturnCom)),
Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.TypeNotSupportedDescription)));
description: GetResourceString(nameof(SR.TypeNotSupportedDescriptionCom)));

/// <inheritdoc cref="SR.TypeNotSupportedMessageParameterWithDetails"/>
public static readonly DiagnosticDescriptor ParameterTypeNotSupportedWithDetails =
Expand All @@ -181,7 +181,7 @@ public class Ids
Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.TypeNotSupportedDescription)));
description: GetResourceString(nameof(SR.TypeNotSupportedDescriptionCom)));

/// <inheritdoc cref="SR.TypeNotSupportedMessageReturnWithDetails"/>
public static readonly DiagnosticDescriptor ReturnTypeNotSupportedWithDetails =
Expand All @@ -192,84 +192,84 @@ public class Ids
Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.TypeNotSupportedDescription)));
description: GetResourceString(nameof(SR.TypeNotSupportedDescriptionCom)));

/// <inheritdoc cref="SR.ConfigurationNotSupportedMessageParameter"/>
/// <inheritdoc cref="SR.ConfigurationNotSupportedMessageParameterCom"/>
public static readonly DiagnosticDescriptor ParameterConfigurationNotSupported =
new DiagnosticDescriptor(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitle)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageParameter)),
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleCom)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageParameterCom)),
Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescription)));
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescriptionCom)));

/// <inheritdoc cref="SR.ConfigurationNotSupportedMessageReturn"/>
/// <inheritdoc cref="SR.ConfigurationNotSupportedMessageReturnCom"/>
public static readonly DiagnosticDescriptor ReturnConfigurationNotSupported =
new DiagnosticDescriptor(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitle)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageReturn)),
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleCom)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageReturnCom)),
Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescription)));
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescriptionCom)));

/// <inheritdoc cref="SR.MarshalAsConfigurationNotSupportedMessageParameter"/>
/// <inheritdoc cref="SR.MarshalAsConfigurationNotSupportedMessageParameterCom"/>
public static readonly DiagnosticDescriptor MarshalAsParameterConfigurationNotSupported =
new DiagnosticDescriptor(
GeneratorDiagnostics.Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitle)),
GetResourceString(nameof(SR.MarshalAsConfigurationNotSupportedMessageParameter)),
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleCom)),
GetResourceString(nameof(SR.MarshalAsConfigurationNotSupportedMessageParameterCom)),
Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescription)));
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescriptionCom)));

/// <inheritdoc cref="SR.MarshalAsConfigurationNotSupportedMessageReturn"/>
/// <inheritdoc cref="SR.MarshalAsConfigurationNotSupportedMessageReturnCom"/>
public static readonly DiagnosticDescriptor MarshalAsReturnConfigurationNotSupported =
new DiagnosticDescriptor(
GeneratorDiagnostics.Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitle)),
GetResourceString(nameof(SR.MarshalAsConfigurationNotSupportedMessageReturn)),
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleCom)),
GetResourceString(nameof(SR.MarshalAsConfigurationNotSupportedMessageReturnCom)),
Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescription)));
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescriptionCom)));

/// <inheritdoc cref="SR.ConfigurationNotSupportedMessage"/>
/// <inheritdoc cref="SR.ConfigurationNotSupportedMessageCom"/>
public static readonly DiagnosticDescriptor ConfigurationNotSupported =
new DiagnosticDescriptor(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitle)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessage)),
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleCom)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageCom)),
Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescription)));
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescriptionCom)));

/// <inheritdoc cref="SR.ConfigurationNotSupportedMessageValue"/>
/// <inheritdoc cref="SR.ConfigurationNotSupportedMessageValueCom"/>
public static readonly DiagnosticDescriptor ConfigurationValueNotSupported =
new DiagnosticDescriptor(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitle)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageValue)),
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleCom)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageValueCom)),
Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescription)));
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescriptionCom)));

/// <inheritdoc cref="SR.ConfigurationNotSupportedMessageMarshallingInfo"/>
/// <inheritdoc cref="SR.ConfigurationNotSupportedMessageMarshallingInfoCom"/>
public static readonly DiagnosticDescriptor MarshallingAttributeConfigurationNotSupported =
new DiagnosticDescriptor(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitle)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageMarshallingInfo)),
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleCom)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageMarshallingInfoCom)),
Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescription)));
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescriptionCom)));

/// <inheritdoc cref="SR.MethodNotDeclaredInAttributedInterfaceMessage"/>
public static readonly DiagnosticDescriptor MethodNotDeclaredInAttributedInterface =
Expand Down Expand Up @@ -414,6 +414,7 @@ public class Ids
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.ClassDoesNotImplementAnyGeneratedComInterfacesDescription)));

/// <inheritdoc cref="SR.UnnecessaryParameterMarshallingInfoMessage"/>
public static readonly DiagnosticDescriptor UnnecessaryParameterMarshallingInfo =
new DiagnosticDescriptor(
Ids.UnnecessaryMarshallingInfo,
Expand All @@ -428,6 +429,7 @@ public class Ids
WellKnownDiagnosticTags.Unnecessary
});

/// <inheritdoc cref="SR.UnnecessaryReturnMarshallingInfoMessage"/>
public static readonly DiagnosticDescriptor UnnecessaryReturnMarshallingInfo =
new DiagnosticDescriptor(
Ids.UnnecessaryMarshallingInfo,
Expand Down
Loading