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

fix: Intellisense does not show internal members #445

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions AvaloniaVS.Shared/Views/AvaloniaDesigner.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -559,15 +559,17 @@ private void RebuildMetadata(string assemblyPath)
string intermediateOutputPath = GetIntermediateOutputPath(storage);
if (metadata.CompletionMetadata == null || metadata.NeedInvalidation)
{
CreateCompletionMetadataAsync(intermediateOutputPath, metadata).FireAndForget();
CreateCompletionMetadataAsync(intermediateOutputPath, assemblyPath, metadata).FireAndForget();
}
}
}

private static Dictionary<string, Task<Metadata>> _metadataCache;
private static readonly MetadataReader _metadataReader = new(new DnlibMetadataProvider());

private static async Task CreateCompletionMetadataAsync(
string intermediateOutputPath,
string xamlAssemblyPath,
XamlBufferMetadata target)
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
Expand All @@ -592,8 +594,7 @@ private static async Task CreateCompletionMetadataAsync(
{
metadataLoad = Task.Run(() =>
{
var metadataReader = new MetadataReader(new DnlibMetadataProvider());
return metadataReader.GetForTargetAssembly(new AvaloniaCompilationAssemblyProvider(intermediateOutputPath));
return _metadataReader.GetForTargetAssembly(new AvaloniaCompilationAssemblyProvider(intermediateOutputPath, xamlAssemblyPath));
});
_metadataCache[intermediateOutputPath] = metadataLoad;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace Avalonia.Ide.CompletionEngine.DnlibMetadataProvider;

public class DnlibMetadataProvider : IMetadataProvider
{

public IMetadataReaderSession GetMetadata(IEnumerable<string> paths)
maxkatz6 marked this conversation as resolved.
Show resolved Hide resolved
{
return new DnlibMetadataProviderSession(paths.ToArray());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Avalonia.Ide.CompletionEngine.AssemblyMetadata
public class AvaloniaCompilationAssemblyProvider : IAssemblyProvider
{
private readonly string _path;
private readonly string _xamlPrimaryAssemblyPath;

/// <summary>
/// Create a new instance of <see cref="AvaloniaCompilationAssemblyProvider"/>—an implementation of <see cref="IAssemblyProvider"/>.
Expand All @@ -22,12 +23,14 @@ public class AvaloniaCompilationAssemblyProvider : IAssemblyProvider
/// - <c>C:\Repos\RepoRoot\src\artifacts\obj\MyApp\debug_net8.0\Avalonia\references</c><br/>
/// See <see href="https://learn.microsoft.com/en-us/dotnet/core/sdk/artifacts-output#examples">Artifacts output layout &amp;gt; Examples</see> for more 'artifacts' path examples.
/// </param>
/// <param name="xamlPrimaryAssemblyPath">Promary XAML Assembly path</param>
/// <exception cref="ArgumentNullException"><paramref name="path"/> is null or empty</exception>
public AvaloniaCompilationAssemblyProvider(string path)
public AvaloniaCompilationAssemblyProvider(string path, string xamlPrimaryAssemblyPath)
{
if (string.IsNullOrEmpty(path))
throw new ArgumentNullException(nameof(path));
_path = path;
_xamlPrimaryAssemblyPath = xamlPrimaryAssemblyPath;
}

/// <summary>
Expand All @@ -37,9 +40,14 @@ public AvaloniaCompilationAssemblyProvider(string path)
/// <exception cref="IOException">Failed to read the project's references file.</exception>
public IEnumerable<string> GetAssemblies()
{
List<string> result = new List<string>(300);
if (!string.IsNullOrEmpty(_xamlPrimaryAssemblyPath))
{
result.Add(_xamlPrimaryAssemblyPath);
}
try
{
return File.ReadAllText(_path).Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
result.AddRange(File.ReadAllLines(_path));
}
catch (Exception ex) when
(ex is DirectoryNotFoundException || ex is FileNotFoundException)
Expand All @@ -50,6 +58,7 @@ public IEnumerable<string> GetAssemblies()
{
throw new IOException($"Failed to read file '{_path}'.", ex);
}
return result;
}
}
}