Skip to content

Commit c8e13eb

Browse files
committed
Added WhitelistAssembly to allow to whitelist whole assemblies at once
1 parent e79f6c4 commit c8e13eb

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Source/Stationeers.Addons/PluginCompiler/PluginWhitelist.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,34 @@ private bool IsPropertyWhitelisted(IPropertySymbol symbol)
186186
return false;
187187
}
188188

189+
public void WhitelistAssembly(Type baseAssemblyType, params Type[] excludedTypes)
190+
{
191+
var excludedNamespaces = new List<string>();
192+
foreach (var type in excludedTypes)
193+
{
194+
Debug.Assert(type != null, "type is null!");
195+
var symbol = GetNamedTypeSymbol(type);
196+
excludedNamespaces.Add(symbol.ContainingNamespace.ToDisplayString());
197+
}
198+
199+
var assembly = baseAssemblyType.Assembly;
200+
201+
// Whitelist all namespaces from the assembly
202+
foreach (var type in assembly.GetTypes())
203+
{
204+
var symbol = GetNamedTypeSymbol(type);
205+
if (symbol != null)
206+
{
207+
var namespaceName = symbol.ContainingNamespace.ToDisplayString();
208+
209+
if (excludedNamespaces.Contains(namespaceName))
210+
continue;
211+
212+
_namespaceWhitelist.Add(namespaceName);
213+
}
214+
}
215+
}
216+
189217
public void WhitelistTypesNamespaces(params Type[] types)
190218
{
191219
foreach (var type in types)

0 commit comments

Comments
 (0)