Skip to content

Commit 4c3cbad

Browse files
committed
C#: Prepare stub generator for unit testing and expose internals to the Test project.
1 parent f7daa86 commit 4c3cbad

File tree

4 files changed

+51
-6
lines changed

4 files changed

+51
-6
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using Microsoft.CodeAnalysis;
2+
3+
namespace Semmle.Extraction.CSharp.StubGenerator;
4+
5+
internal interface IRelevantSymbol
6+
{
7+
bool IsRelevantNamedType(INamedTypeSymbol symbol);
8+
bool IsRelevantNamespace(INamespaceSymbol symbol);
9+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Semmle.Extraction.CSharp.StubGenerator")]
9+
[assembly: AssemblyDescription("Stub generator for C#")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("Semmle.Extraction.CSharp.StubGenerator")]
13+
[assembly: AssemblyCopyright("Copyright © 2023")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("6d55ca39-615a-4c1b-a648-a4010995e1ea")]
24+
25+
// Expose internals for testing purposes.
26+
[assembly: InternalsVisibleTo("Semmle.Extraction.Tests")]
27+
28+
// Version information for an assembly consists of the following four values:
29+
//
30+
// Major Version
31+
// Minor Version
32+
// Build Number
33+
// Revision
34+
//
35+
// You can specify all the values or you can default the Build and Revision Numbers
36+
// by using the '*' as shown below:
37+
// [assembly: AssemblyVersion("1.0.*")]
38+
[assembly: AssemblyVersion("1.0.0.0")]
39+
[assembly: AssemblyFileVersion("1.0.0.0")]

csharp/extractor/Semmle.Extraction.CSharp.StubGenerator/RelevantSymbol.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
using System.Linq;
2-
32
using Microsoft.CodeAnalysis;
4-
using Microsoft.CodeAnalysis.CSharp;
5-
63
using Semmle.Util;
74

85
namespace Semmle.Extraction.CSharp.StubGenerator;
96

10-
internal class RelevantSymbol
7+
internal class RelevantSymbol : IRelevantSymbol
118
{
129
private readonly IAssemblySymbol assembly;
1310
private readonly MemoizedFunc<INamedTypeSymbol, bool> isRelevantNamedType;

csharp/extractor/Semmle.Extraction.CSharp.StubGenerator/StubVisitor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ namespace Semmle.Extraction.CSharp.StubGenerator;
1212
internal sealed class StubVisitor : SymbolVisitor
1313
{
1414
private readonly TextWriter stubWriter;
15-
private readonly RelevantSymbol relevantSymbol;
15+
private readonly IRelevantSymbol relevantSymbol;
1616

17-
public StubVisitor(TextWriter stubWriter, RelevantSymbol relevantSymbol)
17+
public StubVisitor(TextWriter stubWriter, IRelevantSymbol relevantSymbol)
1818
{
1919
this.stubWriter = stubWriter;
2020
this.relevantSymbol = relevantSymbol;

0 commit comments

Comments
 (0)