286 references to TypeNames
Microsoft.Interop.ComInterfaceGenerator (88)
Analyzers\AddGeneratedComClassAnalyzer.cs (2)
25
var generatedComClassAttributeType = context.Compilation.GetBestTypeByMetadataName(
TypeNames
.GeneratedComClassAttribute);
26
var generatedComInterfaceAttributeType = context.Compilation.GetBestTypeByMetadataName(
TypeNames
.GeneratedComInterfaceAttribute);
Analyzers\AddGeneratedComClassFixer.cs (2)
33
var attribute = gen.Attribute(gen.TypeExpression(editor.SemanticModel.Compilation.GetBestTypeByMetadataName(
TypeNames
.GeneratedComClassAttribute)).WithAdditionalAnnotations(Simplifier.AddImportsAnnotation));
47
var comVisibleAttributeType = editor.SemanticModel.Compilation.GetBestTypeByMetadataName(
TypeNames
.System_Runtime_InteropServices_ComVisibleAttribute);
Analyzers\AddMarshalAsToElementFixer.cs (2)
52
TypeNames
.System_Runtime_InteropServices_MarshalAsAttribute,
55
gen.DottedName(
TypeNames
.System_Runtime_InteropServices_UnmanagedType),
Analyzers\ComClassGeneratorDiagnosticsAnalyzer.cs (2)
32
INamedTypeSymbol? generatedComClassAttributeType = context.Compilation.GetBestTypeByMetadataName(
TypeNames
.GeneratedComClassAttribute);
38
? context.Compilation.GetBestTypeByMetadataName(
TypeNames
.GeneratedComInterfaceAttribute)
Analyzers\ComHostingDoesNotSupportGeneratedComInterfaceAnalyzer.cs (3)
32
INamedTypeSymbol? generatedComClassAttribute = context.Compilation.GetBestTypeByMetadataName(
TypeNames
.GeneratedComClassAttribute);
33
INamedTypeSymbol? generatedComInterfaceAttribute = context.Compilation.GetBestTypeByMetadataName(
TypeNames
.GeneratedComInterfaceAttribute);
34
INamedTypeSymbol? comVisibleAttribute = context.Compilation.GetBestTypeByMetadataName(
TypeNames
.System_Runtime_InteropServices_ComVisibleAttribute)!;
Analyzers\ComInterfaceGeneratorDiagnosticsAnalyzer.cs (1)
75
INamedTypeSymbol? generatedComInterfaceAttrType = compilationContext.Compilation.GetBestTypeByMetadataName(
TypeNames
.GeneratedComInterfaceAttribute);
Analyzers\ConvertComImportToGeneratedComInterfaceAnalyzer.cs (3)
36
INamedTypeSymbol? interfaceTypeAttribute = context.Compilation.GetBestTypeByMetadataName(
TypeNames
.InterfaceTypeAttribute)!;
37
INamedTypeSymbol? generatedComInterfaceAttribute = context.Compilation.GetBestTypeByMetadataName(
TypeNames
.GeneratedComInterfaceAttribute);
80
AttributeData comImportAttribute = type.GetAttributes().First(attr => attr.AttributeClass.ToDisplayString() ==
TypeNames
.System_Runtime_InteropServices_ComImportAttribute);
Analyzers\ConvertComImportToGeneratedComInterfaceFixer.cs (4)
82
var generatedComInterfaceAttribute = gen.Attribute(gen.TypeExpression(comp.GetTypeByMetadataName(
TypeNames
.GeneratedComInterfaceAttribute)).WithAdditionalAnnotations(Simplifier.AddImportsAnnotation));
90
gen.AttributeArgument("StringMarshalling", gen.MemberAccessExpression(gen.DottedName(
TypeNames
.StringMarshalling), gen.IdentifierName(nameof(StringMarshalling.Custom)))),
91
gen.AttributeArgument("StringMarshallingCustomType", gen.TypeOfExpression(gen.TypeExpression(comp.GetTypeByMetadataName(
TypeNames
.BStrStringMarshaller))))
101
var comImportAttributeType = comp.GetTypeByMetadataName(
TypeNames
.System_Runtime_InteropServices_ComImportAttribute);
Analyzers\GeneratedComInterfaceAttributeAnalyzer.cs (5)
40
if (GetAttribute(typeSymbol,
TypeNames
.GeneratedComInterfaceAttribute, out _)
41
&& GetAttribute(typeSymbol,
TypeNames
.InterfaceTypeAttribute, out AttributeData? comInterfaceAttribute)
62
case
TypeNames
.ComInterfaceType:
65
case
TypeNames
.System_Int16:
66
case
TypeNames
.@short:
Analyzers\RuntimeComApiUsageWithSourceGeneratedComAnalyzer.cs (4)
29
INamedTypeSymbol? marshalType = context.Compilation.GetBestTypeByMetadataName(
TypeNames
.System_Runtime_InteropServices_Marshal);
30
INamedTypeSymbol? generatedComClassAttribute = context.Compilation.GetBestTypeByMetadataName(
TypeNames
.GeneratedComClassAttribute);
31
INamedTypeSymbol? generatedComInterfaceAttribute = context.Compilation.GetBestTypeByMetadataName(
TypeNames
.GeneratedComInterfaceAttribute);
32
INamedTypeSymbol? comObjectType = context.Compilation.GetBestTypeByMetadataName(
TypeNames
.System_Runtime_InteropServices_Marshalling_ComObject);
Analyzers\VtableIndexStubDiagnosticsAnalyzer.cs (2)
45
INamedTypeSymbol? virtualMethodIndexAttrType = compilationContext.Compilation.GetBestTypeByMetadataName(
TypeNames
.VirtualMethodIndexAttribute);
135
if (!method.ContainingType.GetAttributes().Any(att => att.AttributeClass.IsOfType(
TypeNames
.UnmanagedObjectUnwrapperAttribute)))
ComClassGenerator.cs (2)
23
TypeNames
.GeneratedComClassAttribute,
31
INamedTypeSymbol? generatedComInterfaceAttributeType = compilation.GetBestTypeByMetadataName(
TypeNames
.GeneratedComInterfaceAttribute);
ComInterfaceGenerator.cs (6)
27
TypeNames
.GeneratedComInterfaceAttribute,
160
return (HintName: interfaceContext.Info.Type.FullTypeName.Replace(
TypeNames
.GlobalAlias, "").Replace("@", ""), Source: writer.ToString());
214
generatorDiagnostics.ReportConfigurationNotSupported(lcidConversionAttr, nameof(
TypeNames
.LCIDConversionAttribute));
300
environment.Compilation.GetTypeByMetadataName(
TypeNames
.System_Exception),
975
if (attrInfo.Type is "global::" +
TypeNames
.MarshalUsingAttribute
976
or "global::" +
TypeNames
.System_Runtime_InteropServices_MarshalAsAttribute)
ComInterfaceGeneratorHelpers.cs (1)
17
=> DefaultMarshallingGeneratorResolver.Create(env, direction,
TypeNames
.GeneratedComInterfaceAttribute_ShortName,
ComInterfaceInfo.cs (5)
240
attrInfo.StringMarshallingCustomType.FullTypeName.Replace(
TypeNames
.GlobalAlias, ""),
322
exceptionToUnmanagedMarshallerType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat).Replace(
TypeNames
.GlobalAlias, ""),
349
if (attr.AttributeClass?.ToDisplayString() ==
TypeNames
.GeneratedComInterfaceAttribute)
384
if (attrDisplayString is
TypeNames
.System_Runtime_InteropServices_GuidAttribute)
386
else if (attrDisplayString is
TypeNames
.InterfaceTypeAttribute)
ComMethodInfo.cs (3)
562
if (attr.AttributeClass?.ToDisplayString() ==
TypeNames
.MarshalUsingAttribute
625
if (attrName !=
TypeNames
.MarshalUsingAttribute
626
&& attrName !=
TypeNames
.System_Runtime_InteropServices_MarshalAsAttribute)
GeneratedComInterfaceAttributeData.cs (2)
46
&& attr.AttributeClass?.ToDisplayString() ==
TypeNames
.GeneratedComInterfaceAttribute)
63
Debug.Assert(attr.AttributeClass.ToDisplayString() ==
TypeNames
.GeneratedComInterfaceAttribute);
Marshallers\ComInterfaceDispatchMarshallingResolver.cs (5)
31
$"{
TypeNames
.GlobalAlias +
TypeNames
.System_Runtime_InteropServices_ComWrappers_ComInterfaceDispatch}*",
32
$"{
TypeNames
.System_Runtime_InteropServices_ComWrappers_ComInterfaceDispatch}*",
43
writer.WriteLine($"{managed} = {
TypeNames
.GlobalAlias}{
TypeNames
.System_Runtime_InteropServices_ComWrappers_ComInterfaceDispatch}.GetInstance<{info.ManagedType.FullTypeName}>({native});");
Marshallers\KeepAliveThisMarshaller.cs (2)
18
writer.WriteLine($"{
TypeNames
.GlobalAlias}{
TypeNames
.System_GC}.KeepAlive(this);");
Marshallers\ManagedHResultExceptionGeneratorResolver.cs (2)
45
writer.WriteLine($"{
TypeNames
.GlobalAlias}{
TypeNames
.System_Runtime_InteropServices_Marshal}.ThrowExceptionForHR({managedIdentifier}, new({interfaceId}), (nint){VirtualMethodPointerStubGenerator.NativeThisParameterIdentifier});");
Marshallers\ObjectUnwrapperResolver.cs (2)
40
writer.WriteLine($"{managedIdentifier} = ({info.ManagedType.FullTypeName}){
TypeNames
.GlobalAlias}{
TypeNames
.UnmanagedObjectUnwrapper}.GetObjectForUnmanagedWrapper<{unwrapperType}>({nativeIdentifier});");
Marshallers\StructAsHResultMarshallerFactory.cs (4)
36
writer.WriteLine($"{unmanaged} = {
TypeNames
.GlobalAlias}{
TypeNames
.System_Runtime_CompilerServices_Unsafe}.BitCast<{info.ManagedType.FullTypeName}, {AsNativeType(info).FullTypeName}>({managed});");
42
writer.WriteLine($"{managed} = {
TypeNames
.GlobalAlias}{
TypeNames
.System_Runtime_CompilerServices_Unsafe}.BitCast<{AsNativeType(info).FullTypeName}, {info.ManagedType.FullTypeName}>({unmanaged});");
parent\Common\ConvertToSourceGeneratedInteropFixer.cs (7)
241
&& !parameter.GetAttributes().Any(attr => attr.AttributeClass?.ToDisplayString() ==
TypeNames
.System_Runtime_InteropServices_MarshalAsAttribute))
250
&& !methodSymbol.GetReturnTypeAttributes().Any(attr => attr.AttributeClass?.ToDisplayString() ==
TypeNames
.System_Runtime_InteropServices_MarshalAsAttribute))
260
=> generator.Attribute(
TypeNames
.System_Runtime_InteropServices_MarshalAsAttribute,
263
generator.DottedName(
TypeNames
.System_Runtime_InteropServices_UnmanagedType),
271
&& !methodSymbol.GetReturnTypeAttributes().Any(attr => attr.AttributeClass?.ToDisplayString() ==
TypeNames
.System_Runtime_InteropServices_MarshalAsAttribute))
289
=> generator.Attribute(
TypeNames
.System_Runtime_InteropServices_MarshalAsAttribute,
292
generator.DottedName(
TypeNames
.System_Runtime_InteropServices_UnmanagedType),
VirtualMethodPointerStubGenerator.cs (7)
45
writer.WriteLine($"var ({NativeThisParameterIdentifier}, {VirtualMethodTableIdentifier}) = (({
TypeNames
.GlobalAlias}{
TypeNames
.IUnmanagedVirtualMethodTableProvider})this).GetVirtualMethodTableInfoForKey(typeof({methodStub.TypeKeyOwner.FullTypeName}));");
100
string unmanagedCallersOnlyAttribute =
TypeNames
.GlobalAlias +
TypeNames
.UnmanagedCallersOnlyAttribute;
178
new ReferenceTypeInfo(
TypeNames
.GlobalAlias +
TypeNames
.System_Exception,
TypeNames
.System_Exception),
VtableIndexStubGenerator.cs (9)
27
TypeNames
.VirtualMethodIndexAttribute,
283
INamedTypeSymbol? lcidConversionAttrType = environment.Compilation.GetTypeByMetadataName(
TypeNames
.LCIDConversionAttribute);
284
INamedTypeSymbol? suppressGCTransitionAttrType = environment.Compilation.GetTypeByMetadataName(
TypeNames
.SuppressGCTransitionAttribute);
285
INamedTypeSymbol? unmanagedCallConvAttrType = environment.Compilation.GetTypeByMetadataName(
TypeNames
.UnmanagedCallConvAttribute);
286
INamedTypeSymbol iUnmanagedInterfaceTypeType = environment.Compilation.GetTypeByMetadataName(
TypeNames
.IUnmanagedInterfaceType_Metadata)!;
295
&& attr.AttributeClass.ToDisplayString() ==
TypeNames
.VirtualMethodIndexAttribute)
355
generatorDiagnostics.ReportConfigurationNotSupported(lcidConversionAttr, nameof(
TypeNames
.LCIDConversionAttribute));
387
var unmanagedObjectUnwrapper = symbol.ContainingType.GetAttributes().FirstOrDefault(att => att.AttributeClass.IsOfType(
TypeNames
.UnmanagedObjectUnwrapperAttribute));
441
compilation.GetTypeByMetadataName(
TypeNames
.System_Exception),
VtableIndexStubGeneratorHelpers.cs (1)
19
=> DefaultMarshallingGeneratorResolver.Create(env, direction,
TypeNames
.VirtualMethodIndexAttribute_ShortName,
Microsoft.Interop.JavaScript.JSImportGenerator (4)
Marshaling\BaseJSGenerator.cs (2)
38
writer.WriteLine($"{
TypeNames
.GlobalAlias}{
TypeNames
.System_Runtime_CompilerServices_Unsafe}.SkipInit(out {js});");
Marshaling\ImplicitArgumentGenerator.cs (2)
13
writer.WriteLine($"{
TypeNames
.GlobalAlias}{
TypeNames
.System_Runtime_CompilerServices_Unsafe}.SkipInit(out {js});");
Microsoft.Interop.LibraryImportGenerator (63)
Analyzers\AddDisableRuntimeMarshallingAttributeFixer.cs (1)
66
editor.Generator.Attribute(editor.Generator.DottedName(
TypeNames
.System_Runtime_CompilerServices_DisableRuntimeMarshallingAttribute))));
Analyzers\ConvertToLibraryImportAnalyzer.cs (5)
55
INamedTypeSymbol? libraryImportAttrType = context.Compilation.GetBestTypeByMetadataName(
TypeNames
.LibraryImportAttribute);
142
AttributeData dllImportAttribute = method.GetAttributes().First(attr => attr.AttributeClass.ToDisplayString() ==
TypeNames
.DllImportAttribute);
150
var factory = new ByValueContentsMarshalKindValidator(DefaultMarshallingGeneratorResolver.Create(env.EnvironmentFlags, MarshalDirection.ManagedToUnmanaged,
TypeNames
.LibraryImportAttribute_ShortName, []));
186
AttributeData? bestFitMappingContainingType = method.ContainingType.GetAttributes().FirstOrDefault(attr => attr.AttributeClass.ToDisplayString() ==
TypeNames
.System_Runtime_InteropServices_BestFitMappingAttribute);
192
AttributeData? bestFitMappingContainingAssembly = method.ContainingAssembly.GetAttributes().FirstOrDefault(attr => attr.AttributeClass.ToDisplayString() ==
TypeNames
.System_Runtime_InteropServices_BestFitMappingAttribute);
Analyzers\ConvertToLibraryImportFixer.cs (9)
217
INamedTypeSymbol? dllImportAttrType = editor.SemanticModel.Compilation.GetBestTypeByMetadataName(
TypeNames
.DllImportAttribute);
222
INamedTypeSymbol libraryImportAttrType = editor.SemanticModel.Compilation.GetBestTypeByMetadataName(
TypeNames
.LibraryImportAttribute)!;
426
TypeNames
.System_Runtime_InteropServices_Marshal)),
477
ITypeSymbol stringMarshallingType = editor.SemanticModel.Compilation.GetBestTypeByMetadataName(
TypeNames
.StringMarshalling)!;
486
ITypeSymbol stringMarshallingType = editor.SemanticModel.Compilation.GetBestTypeByMetadataName(
TypeNames
.StringMarshalling)!;
494
generator.TypeOfExpression(generator.TypeExpression(editor.SemanticModel.Compilation.GetBestTypeByMetadataName(
TypeNames
.AnsiStringMarshaller)))));
598
if (editor.SemanticModel.Compilation.GetBestTypeByMetadataName(
TypeNames
.UnmanagedCallConvAttribute) is null)
641
generator.TypeExpression(editor.SemanticModel.Compilation.GetBestTypeByMetadataName(
TypeNames
.System_Type)),
644
unmanagedCallConvAttribute = generator.Attribute(
TypeNames
.UnmanagedCallConvAttribute,
Analyzers\CustomMarshallerAttributeAnalyzer.cs (3)
621
if (context.Compilation.GetBestTypeByMetadataName(
TypeNames
.CustomMarshallerAttribute) is { } customMarshallerAttribute)
639
_spanOfT = compilation.GetBestTypeByMetadataName(
TypeNames
.System_Span_Metadata);
640
_readOnlySpanOfT = compilation.GetBestTypeByMetadataName(
TypeNames
.System_ReadOnlySpan_Metadata);
Analyzers\CustomMarshallerAttributeFixer.cs (4)
209
INamedTypeSymbol spanOfT = editor.SemanticModel.Compilation.GetBestTypeByMetadataName(
TypeNames
.System_Span_Metadata)!;
210
INamedTypeSymbol readOnlySpanOfT = editor.SemanticModel.Compilation.GetBestTypeByMetadataName(
TypeNames
.System_ReadOnlySpan_Metadata)!;
405
INamedTypeSymbol spanOfT = editor.SemanticModel.Compilation.GetBestTypeByMetadataName(
TypeNames
.System_Span_Metadata)!;
406
INamedTypeSymbol readOnlySpanOfT = editor.SemanticModel.Compilation.GetBestTypeByMetadataName(
TypeNames
.System_ReadOnlySpan_Metadata)!;
Analyzers\LibraryImportDiagnosticsAnalyzer.cs (3)
56
INamedTypeSymbol? libraryImportAttrType = context.Compilation.GetBestTypeByMetadataName(
TypeNames
.LibraryImportAttribute);
283
generatorDiagnostics.ReportConfigurationNotSupported(attr, nameof(
TypeNames
.LCIDConversionAttribute));
306
TypeNames
.LibraryImportAttribute_ShortName,
Analyzers\NativeMarshallingAttributeAnalyzer.cs (1)
88
&& attrCreation.Type.ToDisplayString() ==
TypeNames
.NativeMarshallingAttribute)
Analyzers\ShapeBreakingDiagnosticSuppressor.cs (1)
61
attr => attr.AttributeClass?.ToDisplayString() ==
TypeNames
.CustomMarshallerAttribute
ErrorHandlingInfoParser.cs (7)
18
if (candidate.AttributeClass?.ToDisplayString() ==
TypeNames
.ErrorHandlerAttribute)
22
diagnostics.ReportConfigurationNotSupported(candidate, nameof(
TypeNames
.ErrorHandlerAttribute));
41
diagnostics.ReportConfigurationNotSupported(attribute, nameof(
TypeNames
.ErrorHandlerAttribute));
47
diagnostics.ReportConfigurationNotSupported(attribute, nameof(
TypeNames
.ErrorHandlerAttribute));
56
diagnostics.ReportConfigurationNotSupported(attribute, nameof(
TypeNames
.ErrorHandlerAttribute));
65
diagnostics.ReportConfigurationNotSupported(attribute, nameof(
TypeNames
.ErrorHandlerAttribute));
78
diagnostics.ReportConfigurationNotSupported(attribute, nameof(
TypeNames
.ErrorHandlerAttribute));
LibraryImportGenerator.cs (22)
46
TypeNames
.LibraryImportAttribute,
93
attributes.Add(
TypeNames
.GlobalAlias +
TypeNames
.SuppressGCTransitionAttribute);
98
attributes.Add(
TypeNames
.GlobalAlias +
TypeNames
.System_Diagnostics_StackTraceHiddenAttribute);
103
attributes.Add(
TypeNames
.GlobalAlias +
TypeNames
.System_Diagnostics_DebuggerHiddenAttribute);
108
string unmanagedCallConv =
TypeNames
.GlobalAlias +
TypeNames
.UnmanagedCallConvAttribute;
120
unmanagedCallConv += $"({CallConvsField} = new {
TypeNames
.GlobalAlias}{
TypeNames
.System_Type}[] {initializer})";
128
attributes.Add($"{
TypeNames
.GlobalAlias}{
TypeNames
.DefaultDllImportSearchPathsAttribute}(({
TypeNames
.GlobalAlias}{
TypeNames
.DllImportSearchPath}){searchPaths})");
132
attributes.Add(
TypeNames
.GlobalAlias +
TypeNames
.WasmImportLinkageAttribute);
224
&& attr.AttributeClass.ToDisplayString() ==
TypeNames
.LibraryImportAttribute)
306
: DefaultMarshallingGeneratorResolver.Create(pinvokeStub.EnvironmentFlags, MarshalDirection.ManagedToUnmanaged,
TypeNames
.LibraryImportAttribute_ShortName, []);
380
return $"{
TypeNames
.GlobalAlias}{
TypeNames
.DllImportAttribute}({string.Join(", ", arguments)})";
384
=> $"{
TypeNames
.GlobalAlias}{typeof(T).FullName}.{value}";
parent\Common\ConvertToSourceGeneratedInteropFixer.cs (7)
241
&& !parameter.GetAttributes().Any(attr => attr.AttributeClass?.ToDisplayString() ==
TypeNames
.System_Runtime_InteropServices_MarshalAsAttribute))
250
&& !methodSymbol.GetReturnTypeAttributes().Any(attr => attr.AttributeClass?.ToDisplayString() ==
TypeNames
.System_Runtime_InteropServices_MarshalAsAttribute))
260
=> generator.Attribute(
TypeNames
.System_Runtime_InteropServices_MarshalAsAttribute,
263
generator.DottedName(
TypeNames
.System_Runtime_InteropServices_UnmanagedType),
271
&& !methodSymbol.GetReturnTypeAttributes().Any(attr => attr.AttributeClass?.ToDisplayString() ==
TypeNames
.System_Runtime_InteropServices_MarshalAsAttribute))
289
=> generator.Attribute(
TypeNames
.System_Runtime_InteropServices_MarshalAsAttribute,
292
generator.DottedName(
TypeNames
.System_Runtime_InteropServices_UnmanagedType),
Microsoft.Interop.LibraryImportGenerator.Downlevel (14)
DownlevelLibraryImportDiagnosticsAnalyzer.cs (3)
50
INamedTypeSymbol? libraryImportAttrType = context.Compilation.GetBestTypeByMetadataName(
TypeNames
.LibraryImportAttribute);
281
generatorDiagnostics.ReportConfigurationNotSupported(attr, nameof(
TypeNames
.LCIDConversionAttribute));
314
$"{nameof(
TypeNames
.LibraryImportAttribute)}{Type.Delimiter}{nameof(StringMarshalling)}",
DownlevelLibraryImportGenerator.cs (9)
79
TypeNames
.LibraryImportAttribute,
119
attributes.Add($"{
TypeNames
.GlobalAlias}{
TypeNames
.DefaultDllImportSearchPathsAttribute}(({
TypeNames
.GlobalAlias}{
TypeNames
.DllImportSearchPath}){searchPaths})");
200
&& attr.AttributeClass.ToDisplayString() ==
TypeNames
.LibraryImportAttribute)
326
return $"{
TypeNames
.GlobalAlias}{
TypeNames
.DllImportAttribute}({string.Join(", ", arguments)})";
330
=> $"{
TypeNames
.GlobalAlias}{typeof(T).FullName}.{value}";
DownlevelLibraryImportGeneratorHelpers.cs (2)
52
new NoMarshallingInfoErrorResolver(
TypeNames
.LibraryImportAttribute_ShortName),
53
new CharMarshallingGeneratorResolver(useBlittableMarshallerForUtf16: false,
TypeNames
.LibraryImportAttribute_ShortName),
Microsoft.Interop.SourceGeneration (117)
ArrayMarshallingInfoProvider.cs (2)
51
arrayMarshaller = compilation.GetTypeByMetadataName(
TypeNames
.System_Runtime_InteropServices_PointerArrayMarshaller_Metadata);
56
arrayMarshaller = compilation.GetTypeByMetadataName(
TypeNames
.System_Runtime_InteropServices_ArrayMarshaller_Metadata);
ComInterfaceMarshallingInfoProvider.cs (3)
25
public bool CanParseAttributeType(INamedTypeSymbol attributeType) => attributeType.ToDisplayString() ==
TypeNames
.GeneratedComInterfaceAttribute;
37
INamedTypeSymbol? comInterfaceMarshaller = compilation.GetTypeByMetadataName(
TypeNames
.System_Runtime_InteropServices_Marshalling_ComInterfaceMarshaller_Metadata);
139
if (attr.AttributeClass?.ToDisplayString() !=
TypeNames
.GeneratedComInterfaceAttribute)
CompilationExtensions.cs (2)
17
if (compilation.SourceModule.GetAttributes().Any(attr => attr.AttributeClass.ToDisplayString() ==
TypeNames
.System_Runtime_CompilerServices_SkipLocalsInitAttribute))
21
if (compilation.Assembly.GetAttributes().Any(attr => attr.AttributeClass.ToDisplayString() ==
TypeNames
.System_Runtime_CompilerServices_DisableRuntimeMarshallingAttribute))
GeneratedStatements.cs (2)
145
writer.WriteLine($"catch ({
TypeNames
.GlobalAlias}{
TypeNames
.System_Exception} {managed})");
IncrementalGeneratorInitializationContextExtensions.cs (2)
17
TypeNames
.System_Runtime_CompilerServices_SkipLocalsInitAttribute,
28
TypeNames
.System_Runtime_CompilerServices_DisableRuntimeMarshallingAttribute,
ManualTypeMarshallingHelper.cs (5)
113
&& entryPointType.GetAttributes().Any(attr => attr.AttributeClass.ToDisplayString() ==
TypeNames
.ContiguousCollectionMarshallerAttribute);
118
return entryPointType.GetAttributes().Any(attr => attr.AttributeClass.ToDisplayString() ==
TypeNames
.CustomMarshallerAttribute);
139
if (attr.AttributeClass?.ToDisplayString() !=
TypeNames
.CustomMarshallerAttribute
219
var attrs = entryPointType.GetAttributes().Where(attr => attr.AttributeClass.ToDisplayString() ==
TypeNames
.CustomMarshallerAttribute).ToArray();
452
if (innerType.ToDisplayString() !=
TypeNames
.CustomMarshallerAttributeGenericPlaceholder)
MarshalAsParser.cs (10)
33
writer.Write($"{
TypeNames
.GlobalAlias}{
TypeNames
.System_Runtime_InteropServices_MarshalAsAttribute}(({
TypeNames
.GlobalAlias}{
TypeNames
.System_Runtime_InteropServices_UnmanagedType}){(int)unmanagedType}");
98
writer.Write($", {nameof(ArraySubType)} = ({
TypeNames
.GlobalAlias}{
TypeNames
.System_Runtime_InteropServices_UnmanagedType}){(int)ArraySubType}");
137
public bool CanParseAttributeType(INamedTypeSymbol attributeType) => attributeType.ToDisplayString() ==
TypeNames
.System_Runtime_InteropServices_MarshalAsAttribute;
258
=> info.ManagedType.FullTypeName is
TypeNames
.System_Guid
259
or $"{
TypeNames
.GlobalAlias}{
TypeNames
.System_Guid}";
MarshalAsWithCustomMarshallersParser.cs (6)
35
public bool CanParseAttributeType(INamedTypeSymbol attributeType) => attributeType.ToDisplayString() ==
TypeNames
.System_Runtime_InteropServices_MarshalAsAttribute;
90
return CustomMarshallingInfoHelper.CreateMarshallingInfoByMarshallerTypeName(_compilation, type,
TypeNames
.ComVariantMarshaller);
102
UnmanagedType.BStr =>
TypeNames
.BStrStringMarshaller,
103
UnmanagedType.LPStr =>
TypeNames
.AnsiStringMarshaller,
104
UnmanagedType.LPTStr or UnmanagedType.LPWStr =>
TypeNames
.Utf16StringMarshaller,
105
MarshalAsInfo.UnmanagedType_LPUTF8Str =>
TypeNames
.Utf8StringMarshaller,
MarshallerShape.cs (4)
116
INamedTypeSymbol spanOfT = compilation.GetTypeByMetadataName(
TypeNames
.System_Span_Metadata)!;
120
INamedTypeSymbol readOnlySpanOfT = compilation.GetTypeByMetadataName(
TypeNames
.System_ReadOnlySpan_Metadata)!;
454
INamedTypeSymbol spanOfT = compilation.GetTypeByMetadataName(
TypeNames
.System_Span_Metadata)!;
459
INamedTypeSymbol readOnlySpanOfT = compilation.GetTypeByMetadataName(
TypeNames
.System_ReadOnlySpan_Metadata)!;
Marshalling\BreakingChangeDetector.cs (1)
26
if (info is { RefKind: RefKind.In or RefKind.RefReadOnlyParameter, MarshallingAttributeInfo: NativeMarshallingAttributeInfo(ManagedTypeInfo { DiagnosticFormattedName:
TypeNames
.ComVariantMarshaller }, _) }
Marshalling\DelegateMarshaller.cs (6)
35
writer.WriteLine($"{nativeIdentifier} = {managedIdentifier} != null ? {
TypeNames
.GlobalAlias}{
TypeNames
.System_Runtime_InteropServices_Marshal}.GetFunctionPointerForDelegate({managedIdentifier}) : default;");
42
writer.WriteLine($"{managedIdentifier} = {nativeIdentifier} != default ? {
TypeNames
.GlobalAlias}{
TypeNames
.System_Runtime_InteropServices_Marshal}.GetDelegateForFunctionPointer<{info.ManagedType.FullTypeName}>({nativeIdentifier}) : null;");
48
writer.WriteLine($"{
TypeNames
.GlobalAlias}{
TypeNames
.System_GC}.KeepAlive({managedIdentifier});");
Marshalling\ElementsMarshalling.cs (15)
24
protected const string MemoryMarshalType =
TypeNames
.GlobalAlias +
TypeNames
.System_Runtime_InteropServices_MemoryMarshal;
25
protected const string UnsafeType =
TypeNames
.GlobalAlias +
TypeNames
.System_Runtime_CompilerServices_Unsafe;
159
writer.WriteLine($"{
TypeNames
.System_ReadOnlySpan}<{elementMarshaller.TypeInfo.ManagedType.FullTypeName}> {managedSpanIdentifier} = {CollectionSource.GetManagedValuesSource(context)};");
160
writer.WriteLine($"{
TypeNames
.System_Span}<{unmanagedElementType}> {nativeSpanIdentifier} = {CollectionSource.GetUnmanagedValuesDestination(context)};");
179
writer.WriteLine($"{
TypeNames
.System_ReadOnlySpan}<{unmanagedElementType}> {nativeSpanIdentifier} = {CollectionSource.GetUnmanagedValuesSource(context)};");
180
writer.WriteLine($"{
TypeNames
.System_Span}<{elementMarshaller.TypeInfo.ManagedType.FullTypeName}> {managedSpanIdentifier} = {CollectionSource.GetManagedValuesDestination(context)};");
196
writer.WriteLine($"{
TypeNames
.System_Span}<{elementMarshaller.TypeInfo.ManagedType.FullTypeName}> {managedSpanIdentifier} = {MemoryMarshalType}.CreateSpan(ref {UnsafeType}.AsRef(in {CollectionSource.GetManagedValuesSource(context)}.GetPinnableReference()), {numElementsIdentifier});");
197
writer.WriteLine($"{
TypeNames
.System_Span}<{unmanagedElementType}> {nativeSpanIdentifier} = {CollectionSource.GetUnmanagedValuesDestination(context)};");
227
writer.WriteLine($"{
TypeNames
.System_ReadOnlySpan}<{unmanagedElementType}> {nativeSpanIdentifier} = {source};");
253
writer.WriteLine($"{
TypeNames
.System_Span}<{unmanagedElementType}> {nativeSpanIdentifier} = {MemoryMarshalType}.CreateSpan(ref {UnsafeType}.AsRef(in {CollectionSource.GetUnmanagedValuesSource(context)}.GetPinnableReference()), {numElementsIdentifier});");
254
writer.WriteLine($"{
TypeNames
.System_Span}<{elementMarshaller.TypeInfo.ManagedType.FullTypeName}> {managedSpanIdentifier} = {CollectionSource.GetManagedValuesDestination(context)};");
315
writer.WriteLine($"{elementSetupSubContext.GetIdentifiers(elementMarshaller.TypeInfo).native} = ({
TypeNames
.GlobalAlias}{
TypeNames
.System_IntPtr}){identifierContext.GetIdentifiers(elementMarshaller.TypeInfo).native};");
Marshalling\IidParameterIndexMarshallerResolver.cs (10)
50
writer.WriteLine($"{
TypeNames
.GlobalAlias}{
TypeNames
.System_IntPtr} {queriedInterfaceIdentifier} = 0;");
51
writer.WriteLine($"int {queryInterfaceHResultIdentifier} = {
TypeNames
.GlobalAlias}{
TypeNames
.System_Runtime_InteropServices_Marshal}.QueryInterface(({
TypeNames
.GlobalAlias}{
TypeNames
.System_IntPtr}){unknownIdentifier}, in {iidExpression}, out {queriedInterfaceIdentifier});");
59
writer.WriteLine($"{
TypeNames
.GlobalAlias}{
TypeNames
.System_Runtime_InteropServices_Marshal}.Release({queriedInterfaceIdentifier});");
63
writer.WriteLine($"{
TypeNames
.GlobalAlias}{
TypeNames
.System_Runtime_InteropServices_Marshal}.ThrowExceptionForHR({queryInterfaceHResultIdentifier});");
Marshalling\MarshallerHelpers.cs (10)
28
?
TypeNames
.GlobalAlias +
TypeNames
.System_IntPtr
37
FormattableString.Invariant($"{
TypeNames
.GlobalAlias}{
TypeNames
.System_Runtime_InteropServices_Marshal}.SetLastSystemError({errorCode});");
43
$"{lastErrorIdentifier} = {
TypeNames
.GlobalAlias}{
TypeNames
.System_Runtime_InteropServices_Marshal}.GetLastSystemError();";
50
$"{
TypeNames
.GlobalAlias}{
TypeNames
.System_Runtime_InteropServices_Marshal}.SetLastPInvokeError({lastErrorIdentifier});";
227
return $"{
TypeNames
.GlobalAlias}{
TypeNames
.System_Runtime_CompilerServices_Unsafe}.SkipInit(out {info.InstanceIdentifier});";
Marshalling\MarshallingGeneratorExtensions.cs (4)
102
attributes.Add(
TypeNames
.GlobalAlias +
TypeNames
.System_Runtime_InteropServices_InAttribute);
106
attributes.Add(
TypeNames
.GlobalAlias +
TypeNames
.System_Runtime_InteropServices_OutAttribute);
Marshalling\StatelessMarshallingStrategy.cs (1)
107
writer.WriteLine($"{
TypeNames
.System_Span}<{bufferElementType}> {bufferIdentifier} = stackalloc {bufferElementType}[{marshallerType}.{ShapeMemberNames.BufferSize}];");
MarshallingAttributeInfo.cs (7)
173
SpecialType.System_Void => CreateWellKnownComExceptionMarshallingData(
TypeNames
.ExceptionAsVoidMarshaller, unmanagedReturnType),
174
SpecialType.System_Int32 => CreateWellKnownComExceptionMarshallingData($"{
TypeNames
.ExceptionAsHResultMarshaller}<int>", unmanagedReturnType),
175
SpecialType.System_UInt32 => CreateWellKnownComExceptionMarshallingData($"{
TypeNames
.ExceptionAsHResultMarshaller}<uint>", unmanagedReturnType),
176
SpecialType.System_Single => CreateWellKnownComExceptionMarshallingData($"{
TypeNames
.ExceptionAsNaNMarshaller}<float>", unmanagedReturnType),
177
SpecialType.System_Double => CreateWellKnownComExceptionMarshallingData($"{
TypeNames
.ExceptionAsNaNMarshaller}<double>", unmanagedReturnType),
178
_ => CreateWellKnownComExceptionMarshallingData($"{
TypeNames
.ExceptionAsDefaultMarshaller}<{MarshallerHelpers.GetCompatibleGenericTypeParameter(unmanagedReturnType)}>", unmanagedReturnType),
183
ManagedTypeInfo marshallerTypeInfo = new ReferenceTypeInfo(
TypeNames
.GlobalAlias + marshallerName, marshallerName);
MarshalUsingAttributeParser.cs (2)
26
public bool CanParseAttributeType(INamedTypeSymbol attributeType) => attributeType.ToDisplayString() ==
TypeNames
.MarshalUsingAttribute;
30
Debug.Assert(attributeData.AttributeClass!.ToDisplayString() ==
TypeNames
.MarshalUsingAttribute);
NativeMarshallingAttributeParser.cs (2)
20
public bool CanParseAttributeType(INamedTypeSymbol attributeType) => attributeType.ToDisplayString() ==
TypeNames
.NativeMarshallingAttribute;
24
Debug.Assert(attributeData.AttributeClass!.ToDisplayString() ==
TypeNames
.NativeMarshallingAttribute);
SafeHandleMarshallingInfoProvider.cs (2)
18
private readonly INamedTypeSymbol? _safeHandleType = compilation.GetBestTypeByMetadataName(
TypeNames
.System_Runtime_InteropServices_SafeHandle);
19
private readonly INamedTypeSymbol? _safeHandleMarshallerType = compilation.GetBestTypeByMetadataName(
TypeNames
.System_Runtime_InteropServices_Marshalling_SafeHandleMarshaller_Metadata);
SignatureContext.cs (6)
78
additionalAttrs.Add($"{
TypeNames
.GlobalAlias}{
TypeNames
.System_CodeDom_Compiler_GeneratedCodeAttribute}({CodeWriterHelpers.StringLiteral(generatorName)}, {CodeWriterHelpers.StringLiteral(generatorVersion)})");
82
additionalAttrs.Add(
TypeNames
.GlobalAlias +
TypeNames
.System_Runtime_CompilerServices_SkipLocalsInitAttribute);
286
if (attributeName ==
TypeNames
.MarshalUsingAttribute)
340
=> a.AttributeClass?.ToDisplayString() ==
TypeNames
.System_Runtime_CompilerServices_SkipLocalsInitAttribute;
StringMarshallingInfoProvider.cs (2)
62
CharEncoding.Utf16 => CustomMarshallingInfoHelper.CreateMarshallingInfoByMarshallerTypeName(_compilation, type,
TypeNames
.Utf16StringMarshaller),
63
CharEncoding.Utf8 => CustomMarshallingInfoHelper.CreateMarshallingInfoByMarshallerTypeName(_compilation, type,
TypeNames
.Utf8StringMarshaller),
StubEnvironment.cs (7)
35
_lcidConversionAttrType = new Optional<INamedTypeSymbol?>(Compilation.GetTypeByMetadataName(
TypeNames
.LCIDConversionAttribute));
49
_suppressGCTransitionAttrType = new Optional<INamedTypeSymbol?>(Compilation.GetTypeByMetadataName(
TypeNames
.SuppressGCTransitionAttribute));
63
_unmanagedCallConvAttrType = new Optional<INamedTypeSymbol?>(Compilation.GetTypeByMetadataName(
TypeNames
.UnmanagedCallConvAttribute));
77
_defaultDllImportSearchPathsAttrType = new Optional<INamedTypeSymbol?>(Compilation.GetTypeByMetadataName(
TypeNames
.DefaultDllImportSearchPathsAttribute));
91
_wasmImportLinkageAttrType = new Optional<INamedTypeSymbol?>(Compilation.GetTypeByMetadataName(
TypeNames
.WasmImportLinkageAttribute));
105
_stackTraceHiddenAttrType = new Optional<INamedTypeSymbol?>(Compilation.GetTypeByMetadataName(
TypeNames
.System_Diagnostics_StackTraceHiddenAttribute));
119
_debuggerHiddenAttrType = new Optional<INamedTypeSymbol?>(Compilation.GetTypeByMetadataName(
TypeNames
.System_Diagnostics_DebuggerHiddenAttribute));
TypePositionInfo.cs (2)
114
INamedTypeSymbol outAttributeType = compilation.GetTypeByMetadataName(
TypeNames
.System_Runtime_InteropServices_OutAttribute)!;
115
INamedTypeSymbol inAttributeType = compilation.GetTypeByMetadataName(
TypeNames
.System_Runtime_InteropServices_InAttribute)!;
TypeSymbolExtensions.cs (4)
74
if (t.ToDisplayString() is
TypeNames
.System_Runtime_InteropServices_CLong // CLong is an interop intrinsic type for the C long type
75
or
TypeNames
.System_Runtime_InteropServices_CULong // CULong is an interop intrinsic type for the C ulong type
76
or
TypeNames
.System_Runtime_InteropServices_NFloat) // NFloat is an interop intrinsic type for a pointer-sized floating point type
83
if (t.ToDisplayString() ==
TypeNames
.System_Guid) // .NET has established that Guid is blittable and matches the shape of the Win32 GUID type exactly and always will.