Skip to content

Commit

Permalink
fix bug in ref diagnostic being thrown
Browse files Browse the repository at this point in the history
  • Loading branch information
j0shuams committed Jan 25, 2021
1 parent 00da995 commit 31fe428
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/Authoring/WinRT.SourceGenerator/DiagnosticHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private void ParameterHasAttributeErrors(MethodDeclarationSyntax method)
// Nothing can be marked `ref`
if (HasModifier(param, SyntaxKind.RefKeyword))
{
Report(WinRTRules.RefParameterFound, method.GetLocation(), param.Identifier);
Report(WinRTRules.RefParameterFound, method.GetLocation(), method.Identifier, param.Identifier);
}

if (ParamHasInOrOutAttribute(param))
Expand Down
32 changes: 16 additions & 16 deletions src/Authoring/WinRT.SourceGenerator/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ private static string GetCsWinRTWindowsMetadata(GeneratorExecutionContext contex
return cswinrtWindowsMetadata;
}

private static string GetCsWinRTDependentMetadata(GeneratorExecutionContext context)
{
context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.CsWinRTAuthoringInputs", out var winmds);
return winmds;
}

private static string GetCsWinRTDependentMetadata(GeneratorExecutionContext context)
{
context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.CsWinRTAuthoringInputs", out var winmds);
return winmds;
}

private string GetTempFolder(bool clearSourceFilesFromFolder = false)
{
if(_tempFolder == null || !File.Exists(_tempFolder))
Expand Down Expand Up @@ -113,15 +113,15 @@ private void GenerateSources(GeneratorExecutionContext context)
string winmdFile = GetWinmdOutputFile(context);
string outputDir = GetTempFolder(true);
string windowsMetadata = GetCsWinRTWindowsMetadata(context);
string winmds = GetCsWinRTDependentMetadata(context);

string arguments = string.Format(
"-component -input \"{0}\" -input {1} -include {2} -output \"{3}\" -input {4} -verbose",
winmdFile,
windowsMetadata,
assemblyName,
outputDir,
winmds);
string winmds = GetCsWinRTDependentMetadata(context);

string arguments = string.Format(
"-component -input \"{0}\" -input {1} -include {2} -output \"{3}\" -input {4} -verbose",
winmdFile,
windowsMetadata,
assemblyName,
outputDir,
winmds);
Logger.Log("Running " + cswinrtExe + " " + arguments);

var processInfo = new ProcessStartInfo
Expand Down Expand Up @@ -201,7 +201,7 @@ public void Execute(GeneratorExecutionContext context)
{
return;
}

Logger.Initialize(context);


Expand Down
6 changes: 3 additions & 3 deletions src/Authoring/WinRT.SourceGenerator/WinRTRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ private static DiagnosticDescriptor MakeRule(string id, string title, string mes
public static DiagnosticDescriptor UnsupportedTypeRule = MakeRule(
"CsWinRT1006",
"Exposing unsupported type",
"The member '{0}' has the type '{1}' in its signature. The type '{1}' is not a valid Windows Runtime type\n"
+ "Yet, the type (or its generic parameters) implement interfaces that are valid Windows Runtime types\n"
+ "Consider changing the type '{1} in the member signature to one of the following types from System.Collections.Generic:\n{2}");
"The member '{0}' has the type '{1}' in its signature. The type '{1}' is not a valid Windows Runtime type. "
+ "Yet, the type (or its generic parameters) implement interfaces that are valid Windows Runtime types. "
+ "Consider changing the type '{1} in the member signature to one of the following types from System.Collections.Generic: {2}.");

public static DiagnosticDescriptor StructWithNoFieldsRule = MakeRule(
"CsWinRT1007",
Expand Down

0 comments on commit 31fe428

Please sign in to comment.