Skip to content

Commit

Permalink
Migrate to R#10 SDK.
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyTeplyakov committed Jan 24, 2016
1 parent be72ca7 commit b9c69f6
Show file tree
Hide file tree
Showing 11 changed files with 174 additions and 144 deletions.
6 changes: 4 additions & 2 deletions ContractExtensions.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>ReSharper.ContractExtensions</id>
<version>0.9.2.5</version>
<version>0.10.0.1</version>
<!-- update plugin ver in AssemblyInfo.cs plz -->
<title>Code Contract editing extensions</title>
<authors>Sergey Teplyakov, https://github.com/Diagonactic</authors>
Expand All @@ -15,9 +15,11 @@
Detects Code Contract error/warnings in the IDE.
</description>
<dependencies>
<dependency id="Wave" version="[3.0, 4.0)" />
<dependency id="Wave" version="[4.0,4.1)" />
</dependencies>
<releaseNotes>
*What's new in 0.10.0.1*
Support for R# 10

*What's new in 0.9.2.4*
Updated to API for ReSharper 9.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ private void AddContractClassForAttributeTo(IClassDeclaration contractClass)
private IAttribute CreateExcludeFromCodeCoverageAttribute()
{
ITypeElement type = TypeFactory.CreateTypeByCLRName(
typeof(ExcludeFromCodeCoverageAttribute).FullName,
_provider.PsiModule, _currentFile.GetResolveContext()).GetTypeElement();
typeof(ExcludeFromCodeCoverageAttribute).FullName, _provider.PsiModule).GetTypeElement();

return _factory.CreateAttribute(type);
}
Expand Down Expand Up @@ -342,8 +341,7 @@ private string GenerateUniqueContractClassName()
private IAttribute CreateContractClassAttribute(IClassDeclaration contractClass)
{
ITypeElement attributeType = TypeFactory.CreateTypeByCLRName(
typeof(ContractClassAttribute).FullName,
_provider.PsiModule, _currentFile.GetResolveContext()).GetTypeElement();
typeof(ContractClassAttribute).FullName, _provider.PsiModule).GetTypeElement();

var declaredType = contractClass.DeclaredElement;
var typeofExpression = _factory.CreateExpression("typeof($0)", declaredType);
Expand All @@ -362,8 +360,7 @@ private IAttribute CreateContractClassForAttribute(IClassLikeDeclaration contrac
{
var declaredType = _addContractForAvailability.DeclaredType.GetTypeElement();
ITypeElement type = TypeFactory.CreateTypeByCLRName(
typeof(ContractClassForAttribute).FullName,
_provider.PsiModule, _currentFile.GetResolveContext()).GetTypeElement();
typeof(ContractClassForAttribute).FullName, _provider.PsiModule).GetTypeElement();

var expression = _factory.CreateExpression("typeof($0)", declaredType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using JetBrains.ReSharper.Psi.Impl.Types;
using JetBrains.ReSharper.Psi.Modules;
using JetBrains.ReSharper.Psi.Tree;
using JetBrains.Util.Lazy;

namespace ReSharper.ContractExtensions.ContextActions.Infrastructure
{
Expand Down Expand Up @@ -82,8 +81,7 @@ protected ITypeElement CreateDeclaredType(IClrTypeName clrTypeName)
Contract.Requires(clrTypeName != null);
Contract.Ensures(Contract.Result<ITypeElement>() != null);

return new DeclaredTypeFromCLRName(clrTypeName, _psiModule, _currentFile.GetResolveContext())
.GetTypeElement();
return new DeclaredTypeFromCLRName(clrTypeName, _psiModule).GetTypeElement();
}

[Pure]
Expand All @@ -99,8 +97,7 @@ protected ITypeElement CreateDeclaredType(System.Type type)
protected PredefinedType GetPredefinedType()
{
Contract.Ensures(Contract.Result<PredefinedType>() != null);
return _psiModule.GetPredefinedType(
_currentFile.GetResolveContext());
return _psiModule.GetPredefinedType();
}

public ITypeElement ContractType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ private IMethodDeclaration AddObjectInvariantMethodIfNecessary()
private void AddContractInvariantAttribute(IMethodDeclaration method)
{
ITypeElement type = TypeFactory.CreateTypeByCLRName(
typeof(ContractInvariantMethodAttribute).FullName,
_provider.PsiModule, _currentFile.GetResolveContext()).GetTypeElement();
typeof(ContractInvariantMethodAttribute).FullName, _provider.PsiModule).GetTypeElement();

var attribute = _factory.CreateAttribute(type);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public sealed class CodeContractStatement : ContractStatement
/// </summary>
private readonly IInvocationExpression _invocationExpression;
private readonly CodeContractStatementType _statementType;
private JetBrains.Util.Lazy.Lazy<CodeContractAssertion> _codeContractExpression;
private System.Lazy<CodeContractAssertion> _codeContractExpression;

private CodeContractStatement(ICSharpStatement statement,
IInvocationExpression invocationExpression,
Expand All @@ -44,8 +44,8 @@ private CodeContractStatement(ICSharpStatement statement,

// Due to weird bug in CC compiler, I can't use the same variable in Contract.Requires
// and in lambda expression.
_codeContractExpression = JetBrains.Util.Lazy.Lazy.Of(
() => Assertions.ContractStatementFactory.TryCreateAssertion(_invocationExpression));
_codeContractExpression = JetBrains.Util.Lazy.Of(
() => Assertions.ContractStatementFactory.TryCreateAssertion(_invocationExpression), true);
}

public CodeContractStatementType StatementType
Expand All @@ -61,8 +61,8 @@ public bool IsPostcondition
StatementType == CodeContractStatementType.EnsuresOnThrow;
}
}

public JetBrains.Util.Lazy.Lazy<CodeContractAssertion> CodeContractExpression
public Lazy<CodeContractAssertion> CodeContractExpression
{
get
{
Expand Down
Loading

0 comments on commit b9c69f6

Please sign in to comment.