2014-04-29 10 views
5

Tôi đang sử dụng Reshaper với Specflow và Kiểm tra ResharperCode đang gắn cờ Định nghĩa bước, Ràng buộc và móc không bao giờ được sử dụng.Làm cách nào để có được Resharper để xử lý Ràng buộc luồng, các chú thích Bước Def vv như được sử dụng ngầm

tôi cố gắng sử dụng các câu trả lời từ here

nhưng đã không thể thành công được chú thích bên ngoài để được đón một cách chính xác. Đây là những gì tôi đã cố gắng trong tập tin chú thích bên ngoài: -

<assembly name="TechTalk.SpecFlow.dll"> 
    <member name="T:TechTalk.SpecFlow.BindingAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.GivenAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.WhenAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.ThenAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
</assembly> 

mà tôi đã cố gắng tiết kiệm trong C: \ Program Files (x86) \ JetBrains \ ReSharper \ v8.2 \ Bin và C: \ Program Files (x86) \ JetBrains \ ReSharper \ v8.2 \ Bin \ ExternalAnnotations (không quá rõ ràng nơi nó nên đi vì thư mục ExternalAnnotations không tồn tại trong cài đặt mặc định)

nhưng khi tôi đóng và mở lại VS, Kiểm tra vẫn chọn Bindings và bước defs như unused: -

Solution qdf.AcceptanceTests.sln 
Project Alpari.QualityAssurance.SpecFlowExtensions 
    Alpari.QualityAssurance.SpecFlowExtensions\Steps\CrossStepDefinitionFileTwo.cs:7 Class 'CrossStepDefinitionFileTwo' is never used 
    Alpari.QualityAssurance.SpecFlowExtensions\Steps\CrossStepDefinitionFileTwo.cs:10 Method 'GivenICreateAnInstanceOfStepDefinitionOneFromStepDefinitionTwo' is never used 
    Alpari.QualityAssurance.SpecFlowExtensions\Steps\CrossStepDefinitionFileTwo.cs:42 Method 'GivenICallAMethodInStepDefinitionTwoThatCallsTheSameMethodInStepDefinitionFileOne' is never used 

Bất cứ ai có thể cho tôi biết tôi ' đã làm sai trong cấu hình này xin vui lòng?

EDIT hoàn xml mà làm việc tốt sau khi làm theo bài của Alexander: -

<!--Deploy to %ReSharperInstallDir%\Bin\ExternalAnnotations 
    to check the ExternalAnnotations have worked, highlight one and press Ctrl-Shift-F1 
    see https://stackoverflow.com/questions/23359738/how-can-i-get-resharper-to-treat-specflow-bindings-step-def-etc-annotations-as 
    for additional info 
--> 
<assembly name="TechTalk.SpecFlow"> 
    <member name="T:TechTalk.SpecFlow.BindingAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.GivenAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.WhenAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.ThenAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.BeforeTestRunAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.AfterTestRunAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.BeforeFeatureAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.AfterFeatureAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.BeforeScenarioAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.AfterScenarioAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.BeforeAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.AfterAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.BeforeScenarioBlockAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.AfterScenarioBlockAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.BeforeStepAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.AfterStepAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.StepArgumentTransformationAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.StepDefinitionAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
    <member name="T:TechTalk.SpecFlow.ScopeAttribute"> 
    <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> 
    </member> 
</assembly> 

Trả lời

7
  1. Đặt TechTalk.SpecFlow.xml của bạn vào C: \ Program Files (x86) \ JetBrains \ ReSharper \ v8.2 \ Bin \ ExternalAnnotations \;

  2. Xóa tiện ích ".dll" khỏi <assembly name="TechTalk.SpecFlow.dll"> trong xml bạn đã đề cập để nhận <assembly name="TechTalk.SpecFlow">;

  3. Mở lại Visual Studio;

  4. Làm sạch bộ đệm lưu trữ lại cho giải pháp;

+0

Cảm ơn lời khuyên của Alexander. Tôi đã thử tất cả những điều trên ngoại trừ điểm 4 - làm cách nào để xóa bộ nhớ cache chia sẻ lại? – Dave00Galloway

+0

http://resharper-support.jetbrains.com/entries/23853492-ReSharper-stopped-working-for-a-single-specific-solution –

+0

Cảm ơn tôi sẽ thử một lần khi tôi quay lại bàn làm việc của tôi – Dave00Galloway

2

Trông về bên phải, tuy nhiên kể từ ReSharper 8.2, các chú thích bên ngoài được triển khai như một phần mở rộng cho ReSharper (trong quản lý Extensions), để chúng không còn trong Program Files nữa. Bạn có thể làm gì, chỉ để kiểm tra xem điều này có hiệu quả không, chỉ cần đặt tên cho tệp là TechTalk.SpecFlow.ExternalAnnotations.xml và đặt nó bên cạnh tệp DLL của bạn (Tôi giả sử bạn đang sử dụng gói Node của SpecFlow), vì vậy hãy tạm thời đặt nó ở đó, trong thư mục lib.). Bạn cần tải lại giải pháp của mình. Sau đó, bạn sẽ có thể xem liệu các thuộc tính đã được áp dụng hay chưa. Bạn cũng có thể sử dụng tính năng QuickDoc, (bằng cách nhấn Ctrl-Q hoặc Ctrl-Shift-F1 trên thuộc tính) để xác định xem các thuộc tính được áp dụng, ví dụ như:

Nếu đây làm việc, bạn có thể sau đó phân phối các chú thích dưới dạng chính mình là ReSharper extension!

+0

Cảm ơn lời khuyên có Igal. Vì vậy, tôi nên đặt XML bên cạnh dll specflow bên trong gói nuget? Tôi có cần thêm tham chiếu hoặc bao gồm rõ ràng tệp trong dự án hoặc giải pháp của mình không? Ngoài ra, nếu đó là một tệp XML, tại sao đổi tên nó thành .dll? – Dave00Galloway

+0

Rất tiếc, bạn nói đúng, ý tôi là '.xml'! Tôi đã chỉnh sửa câu trả lời, cảm ơn! Tôi muốn bạn đặt nó bên cạnh các DLL trong nuget chỉ để xem nếu nó làm việc. ReSharper tìm chú thích trong Chú thích bên ngoài (sử dụng quy ước 'AssemblyName \ anything.xml') hoặc bên cạnh DLL thực, bằng cách sử dụng' DllName.ExternalAnnotations.quy ước xml'. Nếu nó hoạt động, đó là, ReSharper tải các chú thích, và nó làm cho các phương thức của bạn xuất hiện 'được sử dụng', sau đó bạn biết nó hoạt động và có thể tự đặt các chú thích trong một gói để phân phối cho tất cả mọi người. –

+0

Hãy xem phần Bao bì của tài liệu API R #, nó liệt kê các quy ước đặt tên cho chú thích bên ngoài: http://confluence.jetbrains.com/display/NETCOM/1.06+Packaging+%28R8%29 –

Các vấn đề liên quan