Skip to content

Commit

Permalink
zzre: Fix release build
Browse files Browse the repository at this point in the history
  • Loading branch information
Helco committed Feb 12, 2024
1 parent 019a06a commit b9e099b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion zzre/Program.RenderDoc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private static void SetupRenderDocKeys(SdlWindow window)
}
#else
private static void AddGlobalRenderDocOption(RootCommand _) { }
private static void LoadRenderDoc(InvocationContext _) { }
private static void LoadRenderDoc(ITagContainer _) { }
private static void SetupRenderDocKeys(SdlWindow _) { }
#endif
}
21 changes: 16 additions & 5 deletions zzre/tools/OpenDocumentSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ public bool TryGetEditorFor(IResource resource, [NotNullWhen(true)] out IDocumen
return openEditor != null;
}

public TEditor OpenWith<TEditor>(string pathText) where TEditor : IDocumentEditor =>
public TEditor OpenWith<
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TEditor
>(string pathText) where TEditor : IDocumentEditor =>
OpenWith<TEditor>(new FilePath(pathText));

public TEditor OpenWith<TEditor>(FilePath path) where TEditor : IDocumentEditor
public TEditor OpenWith<
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TEditor
>(FilePath path) where TEditor : IDocumentEditor
{
var resourcePool = diContainer.GetTag<IResourcePool>();
var resource = resourcePool.FindFile(path.ToPOSIXString());
Expand All @@ -49,7 +53,9 @@ public TEditor OpenWith<TEditor>(FilePath path) where TEditor : IDocumentEditor
return OpenWith<TEditor>(resource);
}

public TEditor OpenWith<TEditor>(IResource resource) where TEditor : IDocumentEditor
public TEditor OpenWith<
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TEditor
>(IResource resource) where TEditor : IDocumentEditor
{
if (TryGetEditorFor(resource, out var prevEditor))
{
Expand All @@ -62,7 +68,9 @@ public TEditor OpenWith<TEditor>(IResource resource) where TEditor : IDocumentEd
return newEditor;
}

public void AddEditorType<TEditor>(string extension) where TEditor : IDocumentEditor
public void AddEditorType<
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TEditor
>(string extension) where TEditor : IDocumentEditor
{
editorTypes.Add(extension.ToLowerInvariant(), typeof(TEditor));
_ = GetConstructorFor<TEditor>();
Expand Down Expand Up @@ -94,7 +102,10 @@ public IDocumentEditor Open(IResource resource)
}

private static readonly Dictionary<Type, Func<ITagContainer, object>> knownConstructors = new();
private static Func<ITagContainer, TEditor> GetConstructorFor<TEditor>() where TEditor : IDocumentEditor

private static Func<ITagContainer, TEditor> GetConstructorFor<
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TEditor>()
where TEditor : IDocumentEditor
{
var type = typeof(TEditor);
if (knownConstructors.TryGetValue(type, out var prevCtor))
Expand Down

0 comments on commit b9e099b

Please sign in to comment.