Skip to content

Commit

Permalink
Merge pull request #445 from workgroupengineering/fixes/Intellisense/…
Browse files Browse the repository at this point in the history
…Internal_Members

fix: Intellisense does not show internal members
  • Loading branch information
maxkatz6 authored Apr 5, 2024
2 parents afcb081 + 4259920 commit a297a69
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
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)
{
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;
}
}
}

0 comments on commit a297a69

Please sign in to comment.