-
Notifications
You must be signed in to change notification settings - Fork 420
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
Omnisharp VS Code Issue 1814 Fix #1007
Changes from all commits
868c002
debcfec
71a318b
e74060a
f8e6896
94459ae
c33df39
cd8954f
978efe6
f7ac87b
ace2701
9a1e814
9445b4b
c91c3f0
fff464b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,36 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
|
||
|
||
namespace OmniSharp.Roslyn.CSharp.Services.Signatures | ||
{ | ||
internal class InvocationContext | ||
{ | ||
public SemanticModel SemanticModel { get; set; } | ||
public int Position { get; set; } | ||
public SyntaxNode Receiver { get; set; } | ||
public ArgumentListSyntax ArgumentList { get; set; } | ||
} | ||
public SemanticModel SemanticModel { get; } | ||
public int Position { get; } | ||
public SyntaxNode Receiver { get; } | ||
public IEnumerable<TypeInfo> ArgumentTypes { get; } | ||
public IEnumerable<SyntaxToken> Separators { get; } | ||
|
||
public InvocationContext(SemanticModel semModel, int position, SyntaxNode receiver, ArgumentListSyntax argList) | ||
{ | ||
SemanticModel = semModel; | ||
Position = position; | ||
Receiver = receiver; | ||
ArgumentTypes = argList.Arguments.Select(argument => semModel.GetTypeInfo(argument.Expression)); | ||
Separators = argList.Arguments.GetSeparators(); | ||
} | ||
|
||
public InvocationContext(SemanticModel semModel, int position, SyntaxNode receiver, AttributeArgumentListSyntax argList) | ||
{ | ||
SemanticModel = semModel; | ||
Position = position; | ||
Receiver = receiver; | ||
ArgumentTypes = argList.Arguments.Select(argument => semModel.GetTypeInfo(argument.Expression)); | ||
Separators = argList.Arguments.GetSeparators(); | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,7 +115,7 @@ public async Task TestForParameterLabels() | |
public static void Main(){ | ||
Foo($$); | ||
} | ||
pubic static Foo(bool b, int n = 1234) | ||
public static Foo(bool b, int n = 1234) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. have we verified that this code was not intentionally invalid previously? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, didn't verify that. Should I revert it back to the previous state ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't think so. This doesn't look intentional to me based on the test name. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should look at the test and decide whether the typo was intentional :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My guess, based on what's being tested, is that it was unintentional. |
||
{ | ||
} | ||
}"; | ||
|
@@ -152,6 +152,112 @@ private int Foo(int one, int two, int three) | |
Assert.Equal(0, actual.ActiveParameter); | ||
} | ||
|
||
[Fact] | ||
public async Task SignatureHelpforAttributeCtorSingleParam() | ||
{ | ||
const string source = | ||
@"using System; | ||
[MyTest($$)] | ||
public class TestClass | ||
{ | ||
public static void Main() | ||
{ | ||
} | ||
} | ||
public class MyTestAttribute : Attribute | ||
{ | ||
public MyTestAttribute(int value) | ||
{ | ||
} | ||
}"; | ||
var actual = await GetSignatureHelp(source); | ||
Assert.Equal(0, actual.ActiveParameter); | ||
|
||
var signature = actual.Signatures.ElementAt(0); | ||
Assert.Single(signature.Parameters); | ||
Assert.Equal("value", signature.Parameters.ElementAt(0).Name); | ||
Assert.Equal("int value", signature.Parameters.ElementAt(0).Label); | ||
} | ||
|
||
[Fact] | ||
public async Task SignatureHelpforAttributeCtorTestParameterLabels() | ||
{ | ||
const string source = | ||
@"using System; | ||
[MyTest($$)] | ||
public class TestClass | ||
{ | ||
public static void Main() | ||
{ | ||
} | ||
} | ||
public class MyTestAttribute : Attribute | ||
{ | ||
public MyTestAttribute(int value1,double value2) | ||
{ | ||
} | ||
} | ||
"; | ||
var actual = await GetSignatureHelp(source); | ||
Assert.Equal(0, actual.ActiveParameter); | ||
|
||
var signature = actual.Signatures.ElementAt(0); | ||
Assert.Equal(2, signature.Parameters.Count()); | ||
Assert.Equal("value1", signature.Parameters.ElementAt(0).Name); | ||
Assert.Equal("int value1", signature.Parameters.ElementAt(0).Label); | ||
Assert.Equal("value2", signature.Parameters.ElementAt(1).Name); | ||
Assert.Equal("double value2", signature.Parameters.ElementAt(1).Label); | ||
} | ||
|
||
[Fact] | ||
public async Task SignatureHelpforAttributeCtorActiveParamBasedOnComma() | ||
{ | ||
const string source = | ||
@"using System; | ||
[MyTest(2,$$)] | ||
public class TestClass | ||
{ | ||
public static void Main() | ||
{ | ||
} | ||
} | ||
public class MyTestAttribute : Attribute | ||
{ | ||
public MyTestAttribute(int value1,double value2) | ||
{ | ||
} | ||
} | ||
"; | ||
var actual = await GetSignatureHelp(source); | ||
Assert.Equal(1, actual.ActiveParameter); | ||
} | ||
|
||
[Fact] | ||
public async Task SignatureHelpforAttributeCtorNoParam() | ||
{ | ||
const string source = | ||
@"using System; | ||
[MyTest($$)] | ||
public class TestClass | ||
{ | ||
public static void Main() | ||
{ | ||
} | ||
} | ||
public class MyTestAttribute : Attribute | ||
{ | ||
public MyTestAttribute() | ||
{ | ||
} | ||
}"; | ||
var actual = await GetSignatureHelp(source); | ||
Assert.Single(actual.Signatures); | ||
Assert.Equal(0, actual.ActiveParameter); | ||
Assert.Equal(0, actual.ActiveSignature); | ||
Assert.Equal("MyTestAttribute", actual.Signatures.ElementAt(0).Name); | ||
Assert.Empty(actual.Signatures.ElementAt(0).Parameters); | ||
} | ||
|
||
[Fact] | ||
public async Task ActiveParameterIsBasedOnComma2() | ||
{ | ||
|
@@ -323,7 +429,7 @@ private int Foo(string m, int n) | |
} | ||
|
||
[Fact] | ||
public async Task SigantureHelpForCtor() | ||
public async Task SignatureHelpForCtor() | ||
{ | ||
const string source = | ||
@"class Program | ||
|
@@ -348,7 +454,7 @@ public Program(Program p) | |
} | ||
|
||
[Fact] | ||
public async Task SigantureHelpForCtorWithOverloads() | ||
public async Task SignatureHelpForCtorWithOverloads() | ||
{ | ||
const string source = | ||
@"class Program | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol